ConfigEnumDefault.h
Go to the documentation of this file.
1 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
2 
3 // -- BEGIN LICENSE BLOCK ----------------------------------------------
4 // This file is part of FZIs ic_workspace.
5 //
6 // This program is free software licensed under the LGPL
7 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3).
8 // You can find a copy of this license in LICENSE folder in the top
9 // directory of the source code.
10 //
11 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany
12 //
13 // -- END LICENSE BLOCK ------------------------------------------------
14 
15 //----------------------------------------------------------------------
22 //----------------------------------------------------------------------
23 #ifndef ICL_CORE_CONFIG_CONFIG_ENUM_DEFAULT_H_INCLUDED
24 #define ICL_CORE_CONFIG_CONFIG_ENUM_DEFAULT_H_INCLUDED
25 
26 #include <icl_core/BaseTypes.h>
28 
31 #include "icl_core_config/Util.h"
32 
33 #define CONFIG_ENUM_DEFAULT(key, value, default_value, descriptions) \
34  (new icl_core::config::ConfigEnumDefault<ICL_CORE_CONFIG_TYPEOF(value)>(key, value, default_value, descriptions))
35 
36 namespace icl_core {
37 namespace config {
38 
42 template <typename T>
43 class ConfigEnumDefault : public ConfigEnum<T>
44 {
45 public:
50  typename icl_core::ConvertToRef<T>::ToRef value,
51  typename icl_core::ConvertToRef<T>::ToConstRef default_value,
52  const char * const * descriptions,
53  const char * end_marker = NULL)
54  : ConfigEnum<T>(key, value, descriptions, end_marker),
55  m_default_value(default_value)
56  { }
57 
60  virtual ~ConfigEnumDefault() {}
61 
64  virtual bool get(std::string const & prefix, icl_core::logging::LogStream& log_stream) const
65  {
66  if (!ConfigEnum<T>::get(prefix, log_stream))
67  {
68  this->m_value = m_default_value;
70  }
71  return true;
72  }
73 
74 private:
76 };
77 
78 }}
79 
80 #endif
Helper definitions for template programming.
ConfigEnumDefault(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToRef value, typename icl_core::ConvertToRef< T >::ToConstRef default_value, const char *const *descriptions, const char *end_marker=NULL)
icl_core::ConvertToRef< T >::ToConstRef m_default_value
icl_core::ConvertToRef< T >::ToRef m_value
Definition: ConfigEnum.h:102
T hexical_cast(U input)
Definition: Util.h:43
Implements a thread-safe logging framework.
Definition: LogStream.h:54
virtual icl_core::String key() const
Definition: ConfigEnum.h:87
Utility functions for the configuration framework.
std::string String
Definition: BaseTypes.h:43
Contains Interface base classes and base types.
icl_core::String m_str_value
Definition: ConfigEnum.h:101


fzi_icl_core
Author(s):
autogenerated on Mon Jun 10 2019 13:17:58