1 /******************************************************************
\r
3 * Copyright 2015 Samsung Electronics All Rights Reserved.
\r
7 * Licensed under the Apache License, Version 2.0 (the "License");
\r
8 * you may not use this file except in compliance with the License.
\r
9 * You may obtain a copy of the License at
\r
11 * http://www.apache.org/licenses/LICENSE-2.0
\r
13 * Unless required by applicable law or agreed to in writing, software
\r
14 * distributed under the License is distributed on an "AS IS" BASIS,
\r
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
16 * See the License for the specific language governing permissions and
\r
17 * limitations under the License.
\r
19 ******************************************************************/
\r
21 #ifndef PROPERTIES_H_
\r
22 #define PROPERTIES_H_
\r
27 #include <boost/variant.hpp>
\r
28 #include <boost/lexical_cast.hpp>
\r
31 #include "AllowedValues.h"
\r
39 Properties(): m_min(INT_MAX), m_max(INT_MAX), m_multipleOf(INT_MAX) {}
\r
40 Properties(const std::string &name) : m_name(name), m_min(INT_MAX), m_max(INT_MAX),
\r
41 m_multipleOf(INT_MAX) {}
\r
43 inline std::string getName(void) const
\r
47 inline void setName(const std::string &name)
\r
51 template <typename T>
\r
55 return boost::get<T>(m_value);
\r
58 ValueVariant &getValue()
\r
63 int getValueType() const
\r
65 return m_value.which();
\r
69 return boost::lexical_cast<int> (m_value);
\r
71 std::string getValueString()
\r
73 return boost::lexical_cast<std::string> (m_value);
\r
76 template <typename T>
\r
77 void setValue(const T &value)
\r
81 inline void getRange(int &min, int &max, int &multipleOf) const
\r
85 multipleOf = m_multipleOf;
\r
87 inline void setMin(const int &min)
\r
91 inline void setMax(const int &max)
\r
95 inline void setMultipleOf(const int &multipleOf)
\r
97 m_multipleOf = multipleOf;
\r
100 template <typename T>
\r
101 bool setAllowedValues(const std::vector<T> &values)
\r
103 ValueVariant temp = values.at(0);
\r
104 if (temp.which() != m_value.which())
\r
109 m_allowedValues.addValues(values);
\r
112 inline int getAllowedValuesSize() const
\r
114 return m_allowedValues.size();
\r
116 inline std::vector<ValueVariant> getAllowedValues()
\r
118 return m_allowedValues.getValues();
\r
120 inline std::vector<int> getAllowedValuesInt()
\r
122 return m_allowedValues.getValuesInt();
\r
124 inline std::vector<std::string> getAllowedValuesString()
\r
126 return m_allowedValues.getValuesString();
\r
128 inline void setDescription(const std::string &description)
\r
130 m_description = description;
\r
132 inline std::string getDescription()
\r
134 return m_description;
\r
136 inline int getUpdateFrequencyTime()
\r
138 return m_updateInterval;
\r
140 inline void setUpdateFrequencyTime(int interval)
\r
142 m_updateInterval = interval;
\r
144 void setType(const std::string &type)
\r
148 std::string getType()
\r
152 void setPattern(const std::string &pattern)
\r
154 m_pattern = pattern;
\r
156 std::string getPattern()
\r
160 void setFormat(const std::string &format)
\r
164 std::string getFormat()
\r
168 void setItem(Items *item)
\r
170 m_items.push_back(item);
\r
172 std::vector<Items *> getItems()
\r
176 void setUnique( int value)
\r
178 if (value == cJSON_True) m_unique = true;
\r
179 else m_unique = false;
\r
187 void setAdditionalItems(int value)
\r
189 if (value == cJSON_True) m_additionalItems = true;
\r
190 else m_additionalItems = false;
\r
193 bool getAdditionalItems()
\r
195 return m_additionalItems;
\r
198 std::string m_name;
\r
199 ValueVariant m_value;
\r
203 AllowedValues m_allowedValues;
\r
204 int m_updateInterval;
\r
205 std::string m_type;
\r
206 std::string m_pattern;
\r
207 std::string m_format;
\r
208 std::string m_description;
\r
210 bool m_additionalItems;
\r
211 std::vector<Items *> m_items;
\r
213 typedef std::shared_ptr<Properties> PropertiesPtr;
\r