27 #ifndef ICL_CORE_CONFIG_CONFIG_H_INCLUDED 28 #define ICL_CORE_CONFIG_CONFIG_H_INCLUDED 30 #include <boost/foreach.hpp> 47 #ifdef _IC_BUILDER_OPENSPLICEDDS_ 48 # include "dds_dcps.h" 51 #ifdef _IC_BUILDER_DEPRECATED_STYLE_ 127 str_value =
toLower(str_value);
128 if (str_value ==
"0" || str_value ==
"no" || str_value ==
"false")
133 else if (str_value ==
"1" || str_value ==
"yes" || str_value ==
"true")
149 #ifdef _IC_BUILDER_OPENSPLICEDDS_ 158 value = DDS::string_dup(str_value.c_str());
168 template <
typename T>
170 const char *descriptions[],
const char *end_marker = NULL)
178 value = T(raw_value);
192 template <
typename T>
194 const char *descriptions[],
const char *end_marker = NULL)
199 template <
typename T>
202 T value = default_value;
207 template <
typename T>
218 get<icl_core::String>(key, value);
222 #ifdef _IC_BUILDER_OPENSPLICEDDS_ 229 get<DDS::String>(key, value);
242 bool cleanup =
true,
bool report_error =
true)
247 while (*config != NULL)
249 if ((*config)->get())
252 << (*config)->key() <<
"\" = \"" << (*config)->stringValue()
259 SLOGGING_ERROR(log_stream,
"Error reading configuration parameter \"" 264 SLOGGING_TRACE(log_stream,
"Could not read configuration parameter \"" 275 config = config_values;
276 while (*config != NULL)
293 bool get(std::string config_prefix,
295 bool cleanup =
true,
bool report_error =
true)
302 if (config_prefix !=
"" && config_prefix[config_prefix.length() - 1] !=
'/')
304 config_prefix = config_prefix +
"/";
312 if (config->
get(config_prefix, log_stream))
315 << config_prefix << config->
key() <<
"\" = \"" << config->
stringValue()
322 SLOGGING_ERROR(log_stream,
"Error reading configuration parameter \"" 327 SLOGGING_TRACE(log_stream,
"Could not read configuration parameter \"" 354 bool cleanup =
true,
bool report_error =
true)
356 return get(
"", config_values, log_stream, cleanup, report_error);
359 template <
typename T>
365 template <
typename T>
374 setValue<icl_core::String>(key, value);
383 template <
typename T>
404 template <
typename T>
410 template <
typename T>
412 const char *descriptions[],
const char *end_marker = NULL)
421 value = T(raw_value);
435 template <
typename T>
437 const char *descriptions[],
const char *end_marker = NULL)
439 return paramOpt<T>(
icl_core::String(name), value, descriptions, end_marker);
442 template <
typename T>
454 return default_value;
459 return default_value;
463 template <
typename T>
469 template <
typename T>
491 template <
typename T>
493 const char *descriptions[],
const char *end_marker = NULL)
502 value = T(raw_value);
622 {
return find(query); }
627 template <
typename T>
634 template <
typename T>
636 template <
typename T>
638 {
return get<T>(key, value); }
643 template <
typename T>
647 template <
typename T>
inline 650 {
return get<T>(key, value); }
658 ICL_CORE_GCC_DEPRECATE_STYLE;
662 {
return get<icl_core::String>(key, value); }
669 ICL_CORE_GCC_DEPRECATE_STYLE;
674 template <
typename T>
677 const char *descriptions[],
678 const char *end_marker = NULL)
680 template <
typename T>
683 const char *descriptions[],
684 const char *end_marker)
685 {
return get<T>(key, value, descriptions, end_marker); }
687 template <
typename T>
688 bool Get(
const char *key,
690 const char *descriptions[],
691 const char *end_marker = NULL)
693 template <
typename T>
696 const char *descriptions[],
697 const char *end_marker)
698 {
return get<T>(key, value, descriptions, end_marker); }
700 template <
typename T>
704 template <
typename T>
707 {
return getDefault<T>(key, default_value); }
709 template <
typename T>
713 template <
typename T>
716 {
return getDefault<T>(key, default_value); }
721 ICL_CORE_GCC_DEPRECATE_STYLE;
726 {
return getDefault<icl_core::String>(key, default_value); }
737 {
return get(config_values, log_stream, cleanup); }
739 template <
typename T>
743 template <
typename T>
746 { setValue<T>(key, value); }
748 template <
typename T>
752 template <
typename T>
755 { setValue<T>(key, value); }
769 template <
typename T>
773 template <
typename T>
776 {
return paramOpt<T>(name, value); }
778 template <
typename T>
781 template <
typename T>
783 {
return paramOpt<T>(name, value); }
785 template <
typename T>
787 const char *descriptions[],
const char *end_marker = NULL)
789 template <
typename T>
792 const char *descriptions[],
const char *end_marker)
793 {
return paramOpt<T>(name, value, descriptions, end_marker); }
795 template <
typename T>
797 const char *descriptions[],
const char *end_marker = NULL)
799 template <
typename T>
802 const char *descriptions[],
const char *end_marker)
803 {
return paramOpt<T>(name, value, descriptions, end_marker); }
805 template <
typename T>
808 template <
typename T>
811 {
return paramOptDefault<T>(name, default_value); }
813 template <
typename T>
816 template <
typename T>
819 {
return paramOptDefault<T>(name, default_value); }
821 template <
typename T>
824 template <
typename T>
827 {
return paramNonOpt<T>(index, value); }
829 template <
typename T>
831 const char *descriptions[],
const char *end_marker = NULL)
833 template <
typename T>
836 const char *descriptions[],
const char *end_marker)
837 {
return paramNonOpt<T>(index, value, descriptions, end_marker); }
900 bool Initialize(
int& argc,
char *argv[],
bool remove_read_arguments)
902 inline bool Initialize(
int& argc,
char *argv[],
bool remove_read_arguments)
903 {
return initialize(argc, argv, remove_read_arguments); }
913 {
return initialize(argc, argv, cleanup, registration_check); }
all options have to be registered
Helper definitions for template programming.
Contains helper functions for dealing with String.
static ConfigManager & instance()
bool initialize(int &argc, char *argv[], bool remove_read_arguments)
void setProgramDescription(icl_core::String const &description)
#define ICL_CORE_VC_DEPRECATE_STYLE
Contains ConfigParameter.
Handles commandline parameters.
#define SLOGGING_ERROR(stream, arg)
ICL_CORE_VC_DEPRECATE_STYLE icl_core::String ExtraCmdParam(size_t index) ICL_CORE_GCC_DEPRECATE_STYLE
String toLower(icl_core::String str)
Contains GetoptParameter.
void setProgramDescription(icl_core::String const &description)
#define ICL_CORE_CONFIG_IMPORT_EXPORT
Contains macros to deprecate classes, types, functions and variables.
bool string2Enum(const String &str, int32_t &value, const char *const *descriptions, const char *end_marker)
ICL_CORE_VC_DEPRECATE_STYLE void AddParameter(const ConfigParameter ¶meter) ICL_CORE_GCC_DEPRECATE_STYLE
icl_core::String paramOpt(const icl_core::String &name) const
ICL_CORE_VC_DEPRECATE_STYLE void DebugOutCommandLine(int argc, char *argv[]) ICL_CORE_GCC_DEPRECATE_STYLE
bool paramOptPresent(const icl_core::String &name) const
T getDefault(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToConstRef default_value)
void SetValue(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToConstRef value) ICL_CORE_GCC_DEPRECATE_STYLE
void debugOutCommandLine(int argc, char *argv[])
T paramOptDefault(const icl_core::String &name, typename icl_core::ConvertToRef< T >::ToConstRef default_value)
bool Get< bool >(const icl_core::String &key, bool &value) ICL_CORE_GCC_DEPRECATE_STYLE
ICL_CORE_VC_DEPRECATE_STYLE size_t ExtraCmdParamCount() ICL_CORE_GCC_DEPRECATE_STYLE
size_t paramNonOptCount() const
ICL_CORE_VC_DEPRECATE_STYLE bool Initialize(int &argc, char *argv[], bool remove_read_arguments) ICL_CORE_GCC_DEPRECATE_STYLE
size_t extraCmdParamCount()
ParameterRegistrationCheck
void addParameter(const ConfigParameter ¶meter)
ICL_CORE_VC_DEPRECATE_STYLE void Dump() ICL_CORE_GCC_DEPRECATE_STYLE
size_t extraCmdParamCount() const
void setValue(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToConstRef value)
void activateExtraCmdParams(const icl_core::String &delimiter="--")
bool get< bool >(const icl_core::String &key, bool &value)
Template specialization for boolean values.
bool paramOpt(const icl_core::String &name, typename icl_core::ConvertToRef< T >::ToRef value)
Implements a thread-safe logging framework.
std::list< impl::ConfigValueIface * > ConfigValueList
void setProgramVersion(icl_core::String const &version)
Contains import/export definitions for the Win32 plattform.
ThreadStream & endl(ThreadStream &stream)
bool ParamOpt(const icl_core::String &name, typename icl_core::ConvertToRef< T >::ToRef value) ICL_CORE_GCC_DEPRECATE_STYLE
const char * CONFIGFILE_CONFIG_KEY
icl_core::String extraCmdParam(size_t index) const
ConfigIterator find(const ::icl_core::String &query)
bool get(const String &key, typename ConvertToRef< T >::ToRef value) const
void addParameter(const ConfigParameter ¶meter)
command line options are left untouched
T ParamOptDefault(const icl_core::String &name, typename icl_core::ConvertToRef< T >::ToConstRef default_value) ICL_CORE_GCC_DEPRECATE_STYLE
icl_core::String extraCmdParam(size_t index)
Utility functions for the configuration framework.
void activateExtraCmdParams(const icl_core::String &delimiter="--")
virtual icl_core::String key() const =0
T GetDefault(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToConstRef default_value) ICL_CORE_GCC_DEPRECATE_STYLE
bool ParamNonOpt(size_t index, typename icl_core::ConvertToRef< T >::ToRef value) ICL_CORE_GCC_DEPRECATE_STYLE
Contains Interface base classes and base types.
ICL_CORE_VC_DEPRECATE_STYLE size_t ParamNonOptCount() ICL_CORE_GCC_DEPRECATE_STYLE
static Getopt & instance()
size_t paramNonOptCount()
void addParameter(const GetoptParameter ¶meter)
bool paramOptPresent(const icl_core::String &name)
Contains helper functions to handle enums with textual descriptions.
bool setValue(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToConstRef value)
Add a key/value pair or change a value. In contrast to Insert, this method notifies observers...
void setProgramVersion(icl_core::String const &version)
ICL_CORE_VC_DEPRECATE_STYLE ConfigIterator Find(const icl_core::String &query) ICL_CORE_GCC_DEPRECATE_STYLE
bool Get(const icl_core::String &key, typename icl_core::ConvertToRef< T >::ToRef value) ICL_CORE_GCC_DEPRECATE_STYLE
#define SLOGGING_TRACE(stream, arg)
ICL_CORE_VC_DEPRECATE_STYLE void ActivateExtraCmdParams(const icl_core::String &delimiter="--") ICL_CORE_GCC_DEPRECATE_STYLE
bool paramNonOpt(size_t index, typename icl_core::ConvertToRef< T >::ToRef value)
virtual bool get(std::string const &prefix="", icl_core::logging::LogStream &log_stream=icl_core::logging::Nirwana::instance()) const =0
ICL_CORE_VC_DEPRECATE_STYLE bool ParamOptPresent(const icl_core::String &name) ICL_CORE_GCC_DEPRECATE_STYLE
ICL_CORE_VC_DEPRECATE_STYLE void PrintHelp() ICL_CORE_GCC_DEPRECATE_STYLE
#define ICL_CORE_GCC_DEPRECATE_STYLE
icl_core::String paramNonOpt(size_t index) const
impl::ConfigValueIface * ConfigValues[]
virtual icl_core::String stringValue() const =0
icl_core::KeyValueDirectoryIterator< icl_core::String > ConfigIterator