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
24 * @brief This file provides data Model for Json Schema Array Items.
\r
33 #include "Properties.h"
\r
34 #include "Helpers.h"
\r
35 #include "AllowedValues.h"
\r
41 class AllowedValues;
\r
44 * @brief This class provides data Model for Json Schema Array Items.
\r
50 * Constructor of Items.
\r
55 * This method is for setting Properties to Items
\r
57 * @param propName - Properties name as string.
\r
58 * @param property - pointer to Properties.
\r
60 void addProperty(const std::string &propName, const std::shared_ptr<Properties> &property)
\r
62 if (m_properties.end() == m_properties.find(propName))
\r
64 m_properties[propName] = property;
\r
69 * This method is for getting Properties from Items.
\r
71 * @param propName - Properties name as string.
\r
73 * @return pointer to Properties to put the value got
\r
75 std::shared_ptr<Properties> getproperty(const std::string &propName)
\r
77 if (m_properties.end() != m_properties.find(propName))
\r
79 return m_properties[propName];
\r
85 * This method is for getting Properties from Items.
\r
87 * @return map of Properties name as string and pointer to Properties
\r
89 std::map<std::string, std::shared_ptr<Properties> > const &getProperties()
\r
91 return m_properties;
\r
95 * This method is for setting Type to Items
\r
97 * @param type - Type as string.
\r
99 void setType(const std::string &type)
\r
105 * This method is for getting Type from Items.
\r
107 * @return Type as string
\r
109 std::string getType()
\r
115 * This method is for setting RequiredValue to Items
\r
117 * @param reqValue - RequiredValue as string.
\r
119 void setRequiredValue(const std::string &reqValue)
\r
121 auto it = m_required.begin();
\r
122 for (; it != m_required.end(); ++it)
\r
124 if (*it == reqValue)
\r
127 if (m_required.end() == it)
\r
129 m_required.push_back(reqValue);
\r
134 * This method is for getting RequiredValue from Items.
\r
136 * @return list of RequiredValue as string
\r
138 std::vector<std::string> const &getRequiredValues()
\r
144 * This method is for setting AllowedValues to Items
\r
146 * @param values -list of AllowedValues.
\r
148 template <typename T>
\r
149 bool setAllowedValues(const std::vector<T> &values)
\r
151 m_allowedValues.addValues(values);
\r
156 * This method is for getting size of AllowedValues from Items.
\r
158 * @return size of AllowedValues
\r
160 inline int getAllowedValuesSize() const
\r
162 return m_allowedValues.size();
\r
166 * This method is for getting AllowedValues from Items.
\r
168 * @return list of AllowedValues
\r
170 inline std::vector<ValueVariant> getAllowedValues()
\r
172 return m_allowedValues.getValues();
\r
176 * This method is for getting AllowedValues as Integer from Items.
\r
178 * @return list of AllowedValues as Integer
\r
180 inline std::vector<int> getAllowedValuesInt()
\r
182 return m_allowedValues.getValuesInt();
\r
186 * This method is for getting AllowedValues as String from Items.
\r
188 * @return list of AllowedValues as String
\r
190 inline std::vector<std::string> getAllowedValuesString()
\r
192 return m_allowedValues.getValuesString();
\r
195 std::map<std::string, std::shared_ptr<Properties> > m_properties;
\r
196 std::string m_type;
\r
197 std::vector<std::string> m_required;
\r
198 AllowedValues m_allowedValues;
\r
201 /** ItemsPtr - shared Ptr to Items.*/
\r
202 typedef std::shared_ptr<Items> ItemsPtr;
\r