30 #ifndef INCLUDE_OLA_EXPORTMAP_H_
31 #define INCLUDE_OLA_EXPORTMAP_H_
68 const std::string
Name()
const {
return m_name; }
74 virtual const std::string
Value()
const = 0;
81 BaseVariable*, bool> {
107 void Set(
bool value) { m_value = value; }
113 bool Get()
const {
return m_value; }
121 const std::string
Value()
const {
return m_value ?
"1" :
"0"; }
138 void Set(
const std::string &value) { m_value = value; }
139 const std::string Get()
const {
return m_value; }
140 const std::string
Value()
const {
return m_value; }
157 void Set(
int value) { m_value = value; }
158 void operator++(
int) { m_value++; }
159 void operator--(
int) { m_value--; }
160 void Reset() { m_value = 0; }
161 int Get()
const {
return m_value; }
163 std::ostringstream out;
183 void operator++(
int) { m_value++; }
184 void operator+=(
unsigned int value) { m_value += value; }
185 void Reset() { m_value = 0; }
186 unsigned int Get()
const {
return m_value; }
188 std::ostringstream out;
194 unsigned int m_value;
201 template<
typename Type>
204 MapVariable(
const std::string &name,
const std::string &label)
209 void Remove(
const std::string &key);
210 void Set(
const std::string &key, Type value);
211 Type &operator[](
const std::string &key);
212 const std::string
Value()
const;
213 const std::string Label()
const {
return m_label; }
216 std::map<std::string, Type> m_variables;
230 IntMap(
const std::string &name,
const std::string &label)
233 void Increment(
const std::string &key) {
244 UIntMap(
const std::string &name,
const std::string &label)
247 void Increment(
const std::string &key) {
257 template<
typename Type>
259 return m_variables[key];
266 template<
typename Type>
267 void MapVariable<Type>::Set(
const std::string &key, Type value) {
268 m_variables[key] = value;
276 template<
typename Type>
278 typename std::map<std::string, Type>::iterator iter = m_variables.find(key);
280 if (iter != m_variables.end())
281 m_variables.erase(iter);
290 template<
typename Type>
292 std::ostringstream value;
293 value <<
"map:" << m_label;
294 typename std::map<std::string, Type>::const_iterator iter;
295 for (iter = m_variables.begin(); iter != m_variables.end(); ++iter)
296 value <<
" " << iter->first <<
":" << iter->second;
306 std::ostringstream value;
307 value <<
"map:" << m_label;
308 std::map<std::string, std::string>::const_iterator iter;
309 for (iter = m_variables.begin(); iter != m_variables.end(); ++iter) {
310 std::string var = iter->second;
312 value <<
" " << iter->first <<
":\"" << var <<
"\"";
369 StringMap *GetStringMapVar(
const std::string &name,
370 const std::string &label=
"");
371 IntMap *GetIntMapVar(
const std::string &name,
const std::string &label=
"");
372 UIntMap *GetUIntMapVar(
const std::string &name,
373 const std::string &label=
"");
382 template<
typename Type>
383 Type *GetVar(std::map<std::string, Type*> *var_map,
384 const std::string &name);
386 template<
typename Type>
387 Type *GetMapVar(std::map<std::string, Type*> *var_map,
388 const std::string &name,
389 const std::string &label);
391 std::map<std::string, BoolVariable*> m_bool_variables;
392 std::map<std::string, CounterVariable*> m_counter_variables;
393 std::map<std::string, IntegerVariable*> m_int_variables;
394 std::map<std::string, StringVariable*> m_string_variables;
396 std::map<std::string, StringMap*> m_str_map_variables;
397 std::map<std::string, IntMap*> m_int_map_variables;
398 std::map<std::string, UIntMap*> m_uint_map_variables;
403 #endif // INCLUDE_OLA_EXPORTMAP_H_