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 #include "AbstractParam.h"
\r
26 std::string AbstractParam::getDefaultValue() const
\r
28 return m_defaultValue;
\r
30 void AbstractParam::setDefaultValue(const std::string &defaultValue)
\r
32 m_defaultValue = defaultValue;
\r
35 std::string AbstractParam::getDescription() const
\r
37 return m_description;
\r
40 void AbstractParam::setDescription(const std::string &description)
\r
42 m_description = description;
\r
45 std::string AbstractParam::getDisplayName() const
\r
47 return m_displayName;
\r
50 void AbstractParam::setDisplayName(const std::string &displayName)
\r
52 m_displayName = displayName;
\r
55 std::list<std::string> AbstractParam::getEnumeration() const
\r
57 return m_enumeration;
\r
60 void AbstractParam::setEnumeration(const std::string &enumeration)
\r
62 m_enumeration.push_back(enumeration);
\r
65 std::string AbstractParam::getExample() const
\r
70 void AbstractParam::setExample(const std::string &example)
\r
72 m_example = example;
\r
75 int AbstractParam::getMaxLength() const
\r
80 void AbstractParam::setMaxLength(int maxLength)
\r
82 m_maxLength = maxLength;
\r
85 int AbstractParam::getMaximum() const
\r
90 void AbstractParam::setMaximum(int maximum)
\r
92 m_maximum = maximum;
\r
95 int AbstractParam::getMinLength() const
\r
100 void AbstractParam::setMinLength(int minLength)
\r
102 m_minLength = minLength;
\r
105 int AbstractParam::getMinimum() const
\r
110 void AbstractParam::setMinimum(int minimum)
\r
112 m_minimum = minimum;
\r
115 std::string AbstractParam::getPattern() const
\r
120 void AbstractParam::setPattern(const std::string &pattern)
\r
122 m_pattern = pattern;
\r
125 std::string AbstractParam::getType() const
\r
130 void AbstractParam::setType(const std::string &type)
\r
135 bool AbstractParam::isRepeat() const
\r
140 void AbstractParam::setRepeat(bool repeat)
\r
145 bool AbstractParam::isRequired() const
\r
150 void AbstractParam::setRequired(bool required)
\r
152 m_required = required;
\r
155 void AbstractParam::readParameters(const YAML::Node &yamlNode)
\r
157 for ( YAML::const_iterator it = yamlNode.begin(); it != yamlNode.end(); ++it )
\r
159 std::string key = READ_NODE_AS_STRING(it->first);
\r
161 if (key == Keys::Description)
\r
162 setDescription(READ_NODE_AS_STRING(it->second));
\r
163 else if (key == Keys::Default)
\r
164 setDefaultValue(READ_NODE_AS_STRING(it->second));
\r
165 else if (key == Keys::DisplayName)
\r
166 setDisplayName(READ_NODE_AS_STRING(it->second));
\r
168 else if (key == Keys::Example)
\r
169 setExample(READ_NODE_AS_STRING(it->second));
\r
170 else if (key == Keys::Maximum)
\r
171 setMaximum(READ_NODE_AS_LONG(it->second));
\r
172 else if (key == Keys::Minimum)
\r
173 setMinimum(READ_NODE_AS_LONG(it->second));
\r
174 else if (key == Keys::MaxLength)
\r
175 setMaxLength(READ_NODE_AS_INT(it->second));
\r
176 else if (key == Keys::MinLength)
\r
177 setMinLength(READ_NODE_AS_INT(it->second));
\r
179 else if (key == Keys::Pattern)
\r
180 setPattern(READ_NODE_AS_STRING(it->second));
\r
181 else if (key == Keys::Repeat)
\r
182 setRepeat(READ_NODE_AS_BOOL(it->second));
\r
183 else if (key == Keys::Required)
\r
184 setRequired(READ_NODE_AS_BOOL(it->second));
\r
185 else if (key == Keys::Type)
\r
186 setType(READ_NODE_AS_STRING(it->second));
\r
187 else if (key == Keys::Enum)
\r
189 YAML::Node enumNode = it->second;
\r
190 for ( YAML::const_iterator tt = enumNode.begin(); tt != enumNode.end(); ++tt )
\r
191 setEnumeration(READ_NODE_AS_STRING(*tt));
\r