12 #include "LibCyberRadio/Driver/Configurable.h" 37 std::ostringstream oss;
38 oss <<
"Configuration(";
39 ConfigurationDict::const_iterator it;
40 for ( it = this->begin(); it != this->end(); it++)
42 if ( it != this->begin() )
44 oss << it->first.c_str()
46 << it->second.c_str();
54 return ( this->find(key) != this->end() );
69 _config(other._config)
78 _config = other._config;
101 ConfigurationDict::const_iterator it = _config.find(key);
102 if ( it != _config.end() )
116 catch(std::exception& ex)
129 catch(std::exception& ex)
137 unsigned int ret = 0;
142 catch(std::exception& ex)
155 catch(std::exception& ex)
167 ConfigurationDict::iterator nit;
168 for (ConfigurationDict::iterator it = _config.begin(); it != _config.end(); it++)
170 nit = normCfg.find(it->first);
171 if ( nit != normCfg.end() )
172 it->second = nit->second;
178 const std::string& value)
181 ConfigurationDict::iterator it = _config.find(key);
182 if ( it != _config.end() )
206 const unsigned int value)
236 for (ConfigurationDict::iterator it = adjCfg.begin(); it != adjCfg.end(); it++)
243 std::string ret =
"";
244 std::string adjVal = val;
245 std::transform(val.begin(), val.end(), adjVal.begin(), tolower);
246 if ( (adjVal ==
"1") || (adjVal ==
"yes") || (adjVal ==
"on") || (adjVal ==
"true") )
248 else if ( (adjVal ==
"0") || (adjVal ==
"no") || (adjVal ==
"off") || (adjVal ==
"false") )
257 this->
debug(
"Configuration:\n");
258 ConfigurationDict::const_iterator it;
259 for ( it = _config.begin(); it != _config.end(); it++)
261 this->
debug(
"-- %s = %s\n", it->first.c_str(), it->second.c_str());
263 this->
debug(
"[end configuration]\n");
virtual bool getConfigurationValueAsBool(const std::string &key) const
Gets a named configuration value as a Boolean.
virtual void updateConfigurationDict()
Updates the configuration dictionary from object settings.
Configuration value string class.
virtual bool setConfigurationValueToDbl(const std::string &key, const double value)
Sets a named configuration value to a double value.
virtual ConfigString getConfigurationValue(const std::string &key) const
Gets a named configuration value as a string.
virtual ConfigurationDict normalizedConfigurationDict(const ConfigurationDict &cfg)
Normalizes an incoming configuration dictionary.
virtual bool hasKey(const std::string &key) const
Determines if the dictionary has the given key.
virtual ~ConfigurationDict()
Destroys a ConfigurationDict object.
bool asBool() const
Retrieves a value from this object.
virtual void setName(const std::string &name)
Sets the name of the configurable object.
virtual bool setConfigurationValueToBool(const std::string &key, const bool value)
Sets a named configuration value to a Boolean.
virtual void queryConfiguration()
Tells the object to create its configuration dictionary.
virtual int getConfigurationValueAsInt(const std::string &key) const
Gets a named configuration value as an integer value.
Class that supports debug output.
int asInt() const
Retrieves a value from this object.
double asDouble() const
Retrieves a value from this object.
virtual ConfigurationDict getConfiguration() const
Gets the configuration dictionary for this object.
ConfigurationDict()
Constructs a ConfigurationDict object.
virtual void dumpConfiguration()
Dumps this object's configuration dictionary to debug output.
virtual std::string normalizedBool(const std::string &val)
Normalizes a Boolean string value.
virtual bool setConfigurationValueToUInt(const std::string &key, const unsigned int value)
Sets a named configuration value to an unsigned integer value.
virtual std::string toString() const
Construct a string representation of this object.
virtual int debug(const char *format,...)
Outputs debug information.
virtual ~Configurable()
Destroys a Configurable object.
Defines functionality for LibCyberRadio applications.
A configuration dictionary.
virtual Configurable & operator=(const Configurable &other)
Assignment operator for Configurable objects.
virtual void initConfigurationDict()
Initializes the configuration dictionary, defining the allowed keys.
virtual bool setConfiguration(ConfigurationDict &cfg)
Sets the configuration dictionary for this object.
Base configurable object class.
virtual std::string getName() const
Gets the name of the configurable object.
unsigned int asUInt() const
Retrieves a value from this object.
virtual double getConfigurationValueAsDbl(const std::string &key) const
Gets a named configuration value as a double value.
virtual unsigned int getConfigurationValueAsUInt(const std::string &key) const
Gets a named configuration value as an unsigned integer value.
virtual bool setConfigurationValue(const std::string &key, const std::string &value)
Sets a named configuration value to a string.
Configurable(const std::string &name="<unknown>", bool debug=false)
Constructs a Configurable object.
virtual bool setConfigurationValueToInt(const std::string &key, const int value)
Sets a named configuration value to an integer value.