ConfigValueDefault.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_VALUE_DEFAULT_H_INCLUDED
24 #define ICL_CORE_CONFIG_CONFIG_VALUE_DEFAULT_H_INCLUDED
25 
26 #include <icl_core/BaseTypes.h>
28 
31 #include "icl_core_config/Util.h"
32 
33 #define CONFIG_VALUE_DEFAULT(key, value, default_value) \
34  (new icl_core::config::ConfigValueDefault<ICL_CORE_CONFIG_TYPEOF(value)>(key, value, default_value))
35 
36 namespace icl_core {
37 namespace config {
38 
42 template <typename T>
44 {
45 public:
50  typename icl_core::ConvertToRef<T>::ToRef value,
51  typename icl_core::ConvertToRef<T>::ToConstRef default_value)
52  : ConfigValue<T>(key, value),
53  m_default_value(default_value)
54  { }
55 
58  virtual ~ConfigValueDefault() {}
59 
62  virtual bool get(std::string const & prefix, icl_core::logging::LogStream& log_stream) const
63  {
64  if (!ConfigValue<T>::get(prefix, log_stream))
65  {
66  this->m_value = m_default_value;
68  }
69  return true;
70  }
71 
72 private:
74 };
75 
76 }}
77 
78 #endif
Helper definitions for template programming.
icl_core::String m_str_value
Definition: ConfigValue.h:104
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: ConfigValue.h:90
ConfigValueDefault(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToRef value, typename icl_core::ConvertToRef< T >::ToConstRef default_value)
Utility functions for the configuration framework.
std::string String
Definition: BaseTypes.h:43
Contains Interface base classes and base types.
icl_core::ConvertToRef< T >::ToRef m_value
Definition: ConfigValue.h:105
icl_core::ConvertToRef< T >::ToConstRef m_default_value


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