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
22 * @file Definitions.h
\r
24 * @brief This file provides data Model for Json Schema Definitions.
\r
27 #ifndef DEFINITIONS_H_
\r
28 #define DEFINITIONS_H_
\r
33 #include "Properties.h"
\r
39 * @class Definitions
\r
40 * @brief This class provides data Model for Json Schema Definitions.
\r
47 * Constructor of Definitions.
\r
49 Definitions() = default;
\r
52 * Constructor of Definitions.
\r
54 * @param name - Definitions name as string.
\r
56 Definitions(const std::string &name) : m_defName(name) {}
\r
59 * This method is for getting Name from Definitions.
\r
61 * @return Definitions name as string
\r
63 inline std::string getName(void) const
\r
69 * This method is for setting name to Definitions
\r
71 * @param name - Definitions name as string.
\r
73 inline void setName(const std::string &name)
\r
79 * This method is for getting Type from Definitions.
\r
81 * @return Definitions Type as string
\r
83 inline std::string getType(void) const
\r
89 * This method is for setting Type to Definitions
\r
91 * @param type - Definitions Type as string.
\r
93 inline void setType(const std::string &type)
\r
99 * This method is for getting RequiredValue from Definitions.
\r
101 * @return list of RequiredValue as string
\r
103 std::vector<std::string> const &getRequiredValues() const
\r
109 * This method is for setting RequiredValue to Definitions
\r
111 * @param reqValue - RequiredValue as string.
\r
113 void setRequiredValue(const std::string &reqValue)
\r
115 auto it = m_required.begin();
\r
116 for (; it != m_required.end(); ++it)
\r
118 if (*it == reqValue)
\r
121 if (m_required.end() != it)
\r
123 m_required.push_back(reqValue);
\r
128 * This method is for getting size of Properties from Definitions.
\r
130 * @return size of Properties map
\r
132 int propertiesSize() const { return m_properties.size(); }
\r
135 * This method is for getting Properties from Definitions.
\r
137 * @param propName - name of property as string.
\r
139 * @return pointer to Properties.
\r
141 inline PropertiesPtr getproperty(const std::string &propName )
\r
143 if (m_properties.end() != m_properties.find(propName))
\r
145 return m_properties[propName];
\r
151 * This method is for getting Properties from Definitions.
\r
153 * @return map of Property name and pointer to Properties
\r
155 inline std::map<std::string, PropertiesPtr> const &getProperties()
\r
157 return m_properties;
\r
161 * This method is for setting Properties to Definitions
\r
163 * @param propName - Definitions Type as string.
\r
164 * @param property - pointer to Properties.
\r
166 void addProperty(const std::string &propName, const PropertiesPtr &property)
\r
168 if (m_properties.end() == m_properties.find(propName))
\r
170 m_properties[propName] = property;
\r
174 std::map<std::string, PropertiesPtr > m_properties;
\r
175 std::string m_defName;
\r
176 std::string m_type;
\r
177 std::vector<std::string> m_required;
\r
181 /** DefinitionsPtr - shared Ptr to Definitions.*/
\r
182 typedef std::shared_ptr<Definitions> DefinitionsPtr;
\r