30 #ifndef INCLUDE_OLA_EXPORTMAP_H_
31 #define INCLUDE_OLA_EXPORTMAP_H_
43 using std::stringstream;
70 const string Name()
const {
return m_name; }
76 virtual const string Value()
const = 0;
83 BaseVariable*, bool> {
109 void Set(
bool value) { m_value = value; }
115 bool Get()
const {
return m_value; }
123 const string Value()
const {
return m_value ?
"1" :
"0"; }
140 void Set(
const string &value) { m_value = value; }
141 const string Get()
const {
return m_value; }
142 const string Value()
const {
return m_value; }
159 void Set(
int value) { m_value = value; }
160 void operator++(
int) { m_value++; }
161 void operator--(
int) { m_value--; }
162 void Reset() { m_value = 0; }
163 int Get()
const {
return m_value; }
185 void operator++(
int) { m_value++; }
186 void operator+=(
unsigned int value) { m_value += value; }
187 void Reset() { m_value = 0; }
188 unsigned int Get()
const {
return m_value; }
196 unsigned int m_value;
203 template<
typename Type>
206 MapVariable(
const string &name,
const string &label):
211 void Remove(
const string &key);
212 void Set(
const string &key, Type value);
213 Type &operator[](
const string &key);
214 const string Value()
const;
215 const string Label()
const {
return m_label; }
218 map<string, Type> m_variables;
232 IntMap(
const string &name,
const string &label)
236 void Increment(
const string &key) {
247 UIntMap(
const string &name,
const string &label)
251 void Increment(
const string &key) {
261 template<
typename Type>
263 return m_variables[key];
270 template<
typename Type>
271 void MapVariable<Type>::Set(
const string &key, Type value) {
272 m_variables[key] = value;
280 template<
typename Type>
282 typename map<string, Type>::iterator iter = m_variables.find(key);
284 if (iter != m_variables.end())
285 m_variables.erase(iter);
338 StringMap *GetStringMapVar(
const string &name,
const string &label=
"");
339 IntMap *GetIntMapVar(
const string &name,
const string &label=
"");
340 UIntMap *GetUIntMapVar(
const string &name,
const string &label=
"");
352 template<
typename Type>
353 Type *GetVar(map<string, Type*> *var_map,
const string &name);
355 template<
typename Type>
356 Type *GetMapVar(map<string, Type*> *var_map,
358 const string &label);
360 map<string, BoolVariable*> m_bool_variables;
361 map<string, CounterVariable*> m_counter_variables;
362 map<string, IntegerVariable*> m_int_variables;
363 map<string, StringVariable*> m_string_variables;
365 map<string, StringMap*> m_str_map_variables;
366 map<string, IntMap*> m_int_map_variables;
367 map<string, UIntMap*> m_uint_map_variables;
370 #endif // INCLUDE_OLA_EXPORTMAP_H_