1 /******************************************************************
3 * Copyright 2016 Samsung Electronics All Rights Reserved.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
19 ******************************************************************/
21 #ifndef SIMULATOR_ATTRIBUTE_VALUE_GENERATOR_H_
22 #define SIMULATOR_ATTRIBUTE_VALUE_GENERATOR_H_
24 #include "simulator_resource_model_schema.h"
26 class AttributeValueGen
29 virtual bool hasNext() = 0;
30 virtual AttributeValueVariant next() = 0;
31 virtual AttributeValueVariant value() = 0;
32 virtual void reset() = 0;
35 template <typename TYPE>
36 class RangeValueGen : public AttributeValueGen
44 RangeValueGen(TYPE min, TYPE max) : m_min(min), m_max(max), m_cur(min) {}
48 return (m_cur <= m_max);
51 AttributeValueVariant next()
58 AttributeValueVariant value()
69 template <typename TYPE>
70 class ValuesSetGen : public AttributeValueGen
73 std::vector<TYPE> m_values;
77 ValuesSetGen(const std::vector<TYPE> &values) : m_values(values), m_index(0) {}
81 return (m_index < m_values.size());
84 AttributeValueVariant next()
86 return m_values[m_index++];
89 AttributeValueVariant value()
91 return m_values[m_index - 1];
100 class AttributeValueGenFactory
103 static std::unique_ptr<AttributeValueGen> create(
104 const std::shared_ptr<AttributeProperty> &property);