Fawkes API  Fawkes Development Version
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
fawkes::Configuration Class Referenceabstract

Interface for configuration handling. More...

#include <>>

Inheritance diagram for fawkes::Configuration:

Classes

class  ValueIterator
 Iterator interface to iterate over config values. More...
 

Public Member Functions

virtual ~Configuration ()
 Virtual empty destructor. More...
 
virtual void copy (Configuration *copyconf)=0
 Copy all values from the given configuration. More...
 
virtual void add_change_handler (ConfigurationChangeHandler *h)
 Add a configuration change handler. More...
 
virtual void rem_change_handler (ConfigurationChangeHandler *h)
 Remove a configuration change handler. More...
 
virtual void load (const char *name, const char *defaults_name, const char *tag=NULL)=0
 Load configuration. More...
 
virtual void tag (const char *tag)=0
 Tag this configuration version. More...
 
virtual std::list< std::string > tags ()=0
 List of tags. More...
 
virtual bool exists (const char *path)=0
 Check if a given value exists. More...
 
virtual bool is_float (const char *path)=0
 Check if a value is of type float. More...
 
virtual bool is_uint (const char *path)=0
 Check if a value is of type unsigned int. More...
 
virtual bool is_int (const char *path)=0
 Check if a value is of type int. More...
 
virtual bool is_bool (const char *path)=0
 Check if a value is of type bool. More...
 
virtual bool is_string (const char *path)=0
 Check if a value is of type string. More...
 
virtual bool is_default (const char *path)=0
 Check if a value was read from the default config. More...
 
virtual float get_float (const char *path)=0
 Get value from configuration which is of type float. More...
 
virtual unsigned int get_uint (const char *path)=0
 Get value from configuration which is of type unsigned int. More...
 
virtual int get_int (const char *path)=0
 Get value from configuration which is of type int. More...
 
virtual bool get_bool (const char *path)=0
 Get value from configuration which is of type bool. More...
 
virtual std::string get_string (const char *path)=0
 Get value from configuration which is of type string. More...
 
virtual ValueIteratorget_value (const char *path)=0
 Get value from configuration. More...
 
virtual std::string get_type (const char *path)=0
 Get type of value at given path. More...
 
virtual std::string get_comment (const char *path)=0
 Get comment of value at given path. More...
 
virtual std::string get_default_comment (const char *path)=0
 Get comment of value at given path. More...
 
virtual void set_float (const char *path, float f)=0
 Set new value in configuration of type float. More...
 
virtual void set_uint (const char *path, unsigned int uint)=0
 Set new value in configuration of type unsigned int. More...
 
virtual void set_int (const char *path, int i)=0
 Set new value in configuration of type int. More...
 
virtual void set_bool (const char *path, bool b)=0
 Set new value in configuration of type bool. More...
 
virtual void set_string (const char *path, std::string &s)=0
 Set new value in configuration of type string. More...
 
virtual void set_string (const char *path, const char *s)=0
 Set new value in configuration of type string. More...
 
virtual void set_comment (const char *path, const char *comment)=0
 Set new comment for existing value. More...
 
virtual void set_comment (const char *path, std::string &comment)=0
 Set new comment for existing value. More...
 
virtual void erase (const char *path)=0
 Erase the given value from the configuration. More...
 
virtual void set_default_float (const char *path, float f)=0
 Set new default value in configuration of type float. More...
 
virtual void set_default_uint (const char *path, unsigned int uint)=0
 Set new default value in configuration of type unsigned int. More...
 
virtual void set_default_int (const char *path, int i)=0
 Set new default value in configuration of type int. More...
 
virtual void set_default_bool (const char *path, bool b)=0
 Set new default value in configuration of type bool. More...
 
virtual void set_default_string (const char *path, std::string &s)=0
 Set new default value in configuration of type string. More...
 
virtual void set_default_string (const char *path, const char *s)=0
 Set new default value in configuration of type string. More...
 
virtual void set_default_comment (const char *path, const char *comment)=0
 Set new default comment for existing default configuration value. More...
 
virtual void set_default_comment (const char *path, std::string &comment)=0
 Set new default comment for existing default configuration value. More...
 
virtual void erase_default (const char *path)=0
 Erase the given default value from the configuration. More...
 
virtual ValueIteratoriterator ()=0
 Iterator for all values. More...
 
virtual ValueIteratoriterator_default ()=0
 Iterator for all default values. More...
 
virtual ValueIteratoriterator_hostspecific ()=0
 Iterator for all host-specific values. More...
 
virtual ValueIteratorsearch (const char *path)=0
 Iterator with search results. More...
 
virtual void lock ()=0
 Lock the config. More...
 
virtual bool try_lock ()=0
 Try to lock the config. More...
 
virtual void unlock ()=0
 Unlock the config. More...
 

Protected Types

typedef std::list
< ConfigurationChangeHandler * > 
ChangeHandlerList
 List that contains pointers to ConfigurationChangeHandler. More...
 
typedef std::multimap< const
char
*, ConfigurationChangeHandler
*, StringLess
ChangeHandlerMultimap
 Multimap string to config change handlers. More...
 
typedef std::pair
< ChangeHandlerMultimap::iterator,
ChangeHandlerMultimap::iterator > 
ChangeHandlerMultimapRange
 Config change handler multimap range. More...
 

Protected Member Functions

ChangeHandlerListfind_handlers (const char *path)
 Find handlers for given path. More...
 
void notify_handlers (const char *path, bool comment_changed=false)
 Notify handlers for given path. More...
 

Protected Attributes

ChangeHandlerMultimap _change_handlers
 Registered change handlers. More...
 
ChangeHandlerMultimapRange _ch_range
 Change handler range. More...
 

Detailed Description

Interface for configuration handling.

We know that half of robotics is about parameter tuning. The Configuration interface defines a unified way of storing parameters and other configuration options no matter of how the database is implemented. This is mainly done to allow for testing different solutions for ticket #10.

Definition at line 63 of file config.h.

Member Typedef Documentation

List that contains pointers to ConfigurationChangeHandler.

Definition at line 168 of file config.h.

typedef std::multimap<const char *, ConfigurationChangeHandler *, StringLess > fawkes::Configuration::ChangeHandlerMultimap
protected

Multimap string to config change handlers.

Definition at line 172 of file config.h.

typedef std::pair<ChangeHandlerMultimap::iterator, ChangeHandlerMultimap::iterator> fawkes::Configuration::ChangeHandlerMultimapRange
protected

Config change handler multimap range.

Definition at line 177 of file config.h.

Constructor & Destructor Documentation

fawkes::Configuration::~Configuration ( )
inlinevirtual

Virtual empty destructor.

Definition at line 66 of file config.h.

Member Function Documentation

void fawkes::Configuration::add_change_handler ( ConfigurationChangeHandler h)
virtual

Add a configuration change handler.

The added handler is called whenever a value changes and the handler desires to get notified for the given component.

Parameters
hconfiguration change handler

Reimplemented in fawkes::NetworkConfiguration.

Definition at line 479 of file config.cpp.

References _change_handlers, and fawkes::ConfigurationChangeHandler::config_monitor_prefix().

Referenced by fawkes::NetworkConfiguration::add_change_handler(), ConfigChangeWatcherTool::ConfigChangeWatcherTool(), fawkes::ConfigNetworkHandler::ConfigNetworkHandler(), and fawkes::PluginManager::PluginManager().

void fawkes::Configuration::copy ( Configuration copyconf)
pure virtual

Copy all values from the given configuration.

All values from the given configuration are copied. Old values are not erased so that the copied values will overwrite existing values, new values are created, but values existent in current config but not in the copie config will remain unchanged.

Parameters
copyconfconfiguration to copy

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::erase ( const char *  path)
pure virtual

Erase the given value from the configuration.

It is not an error if the value does not exists before deletion.

Parameters
pathpath to value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::erase_default ( const char *  path)
pure virtual

Erase the given default value from the configuration.

It is not an error if the value does not exists before deletion.

Parameters
pathpath to value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

bool fawkes::Configuration::exists ( const char *  path)
pure virtual

Check if a given value exists.

Parameters
pathpath to value
Returns
true if the value exists, false otherwise

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by StaticTransformsThread::init().

Configuration::ChangeHandlerList * fawkes::Configuration::find_handlers ( const char *  path)
protected

Find handlers for given path.

Parameters
pathpath to get handlers for
Returns
list with config change handlers.

Definition at line 525 of file config.cpp.

References _ch_range, and _change_handlers.

Referenced by notify_handlers().

std::string fawkes::Configuration::get_comment ( const char *  path)
pure virtual

Get comment of value at given path.

The value at the given path must exist in the host-specific configuration.

Parameters
pathpath to value
Returns
comment
Exceptions
ConfigEntryNotFoundExceptionshall be thrown if value does not exist
ConfigurationExceptionshall be thrown on any other error

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

std::string fawkes::Configuration::get_default_comment ( const char *  path)
pure virtual

Get comment of value at given path.

The value at the given path must exist in the default configuration.

Parameters
pathpath to value
Returns
comment
Exceptions
ConfigEntryNotFoundExceptionshall be thrown if value does not exist
ConfigurationExceptionshall be thrown on any other error

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

int fawkes::Configuration::get_int ( const char *  path)
pure virtual

Get value from configuration which is of type int.

Parameters
pathpath to value
Returns
value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

std::string fawkes::Configuration::get_type ( const char *  path)
pure virtual

Get type of value at given path.

Parameters
pathpath to value
Returns
string representation of type, one of float, unsigned int, int, bool, or string
Exceptions
ConfigurationExceptionshall be thrown if value does not exist or on any other error.

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Configuration::ValueIterator * fawkes::Configuration::get_value ( const char *  path)
pure virtual

Get value from configuration.

Parameters
pathpath to value
Returns
value iterator for just this one value, maybe invalid if value does not exists.

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop(), and notify_handlers().

bool fawkes::Configuration::is_bool ( const char *  path)
pure virtual

Check if a value is of type bool.

Parameters
pathpath to value
Returns
true if the value exists and is of type bool

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

bool fawkes::Configuration::is_default ( const char *  path)
pure virtual

Check if a value was read from the default config.

Parameters
pathpath to value
Returns
true if the value exists and is only stored in the default config

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

bool fawkes::Configuration::is_float ( const char *  path)
pure virtual

Check if a value is of type float.

Parameters
pathpath to value
Returns
true if the value exists and is of type float

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

bool fawkes::Configuration::is_int ( const char *  path)
pure virtual

Check if a value is of type int.

Parameters
pathpath to value
Returns
true if the value exists and is of type int

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

bool fawkes::Configuration::is_string ( const char *  path)
pure virtual

Check if a value is of type string.

Parameters
pathpath to value
Returns
true if the value exists and is of type string

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

bool fawkes::Configuration::is_uint ( const char *  path)
pure virtual

Check if a value is of type unsigned int.

Parameters
pathpath to value
Returns
true if the value exists and is of type unsigned int

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Configuration::ValueIterator * fawkes::Configuration::iterator ( )
pure virtual

Iterator for all values.

Returns an iterator that can be used to iterate over all values in the current configuration, it will value the overlay. If a default and a host-specific value exists you will only see the host-specific value.

Returns
iterator over all values

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::SQLiteConfiguration::copy(), and fawkes::NetworkConfiguration::copy().

Configuration::ValueIterator * fawkes::Configuration::iterator_default ( )
pure virtual

Iterator for all default values.

Returns an iterator that can be used to iterate over all default values in the current default configuration. Note that this might return less paths than available, because the values for which no default entry exists are not returned.

Returns
iterator over all default values

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

Configuration::ValueIterator * fawkes::Configuration::iterator_hostspecific ( )
pure virtual

Iterator for all host-specific values.

Returns an iterator that can be used to iterate over all host-specific values in the current configuration. Note that this might return less paths than available, because the default values for which no host-specific entry exists are not returned.

Returns
iterator over all host-specific values

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::load ( const char *  name,
const char *  defaults_name,
const char *  tag = NULL 
)
pure virtual

Load configuration.

Loads configuration data, or opens a file, depending on the implementation. After this call access to all other methods shall be possible.

Parameters
namename of the host-based configuration. If this does not exist it shall be created from the default configuration. The name depends on the implementation and could be a filename.
defaults_namename of the default database. As for the name this depends on the actual implementation.
tagthis optional parameter can denote a specific config version to load. This will cause the host-specific database to be flushed and filled with the values for the given tag. All values that did not exist for the tag are copied over from the default database.

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::lock ( )
pure virtual

Lock the config.

No further changes or queries can be executed on the configuration and will block until the config is unlocked.

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::SQLiteConfiguration::copy(), fawkes::NetworkConfiguration::copy(), fawkes::ConfigNetworkHandler::loop(), and RetrieverConfigPlugin::pre_run().

void fawkes::Configuration::rem_change_handler ( ConfigurationChangeHandler h)
virtual

Remove a configuration change handler.

The handler is removed from the change handler list and no longer called on config changes.

Parameters
hconfiguration change handler

Reimplemented in fawkes::NetworkConfiguration.

Definition at line 496 of file config.cpp.

References _ch_range, _change_handlers, and fawkes::ConfigurationChangeHandler::config_monitor_prefix().

Referenced by ConfigChangeWatcherTool::handle_signal(), fawkes::NetworkConfiguration::rem_change_handler(), fawkes::ConfigNetworkHandler::~ConfigNetworkHandler(), and fawkes::PluginManager::~PluginManager().

Configuration::ValueIterator * fawkes::Configuration::search ( const char *  path)
pure virtual
void fawkes::Configuration::set_bool ( const char *  path,
bool  b 
)
pure virtual

Set new value in configuration of type bool.

Parameters
pathpath to value
bnew bool value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_comment ( const char *  path,
const char *  comment 
)
pure virtual

Set new comment for existing value.

Works like the aforementioned method. Just takes an good ol' char array instead of a std::string.

Parameters
pathpath to value
commentnew comment string

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_comment ( const char *  path,
std::string &  comment 
)
pure virtual

Set new comment for existing value.

Parameters
pathpath to value
commentnew comment string

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::set_default_bool ( const char *  path,
bool  b 
)
pure virtual

Set new default value in configuration of type bool.

Parameters
pathpath to value
bnew bool value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_default_comment ( const char *  path,
const char *  comment 
)
pure virtual

Set new default comment for existing default configuration value.

Works like the aforementioned method. Just takes an good ol' char array instead of a std::string.

Parameters
pathpath to value
commentnew comment string

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_default_comment ( const char *  path,
std::string &  comment 
)
pure virtual

Set new default comment for existing default configuration value.

Parameters
pathpath to value
commentnew comment string

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::set_default_float ( const char *  path,
float  f 
)
pure virtual

Set new default value in configuration of type float.

Parameters
pathpath to value
fnew float value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_default_int ( const char *  path,
int  i 
)
pure virtual

Set new default value in configuration of type int.

Parameters
pathpath to value
inew int value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_default_string ( const char *  path,
std::string &  s 
)
pure virtual

Set new default value in configuration of type string.

Parameters
pathpath to value
snew string value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_default_string ( const char *  path,
const char *  s 
)
pure virtual

Set new default value in configuration of type string.

Works like the aforementioned method. Just takes an good ol' char array instead of a std::string.

Parameters
pathpath to value
snew string value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::set_default_uint ( const char *  path,
unsigned int  uint 
)
pure virtual

Set new default value in configuration of type unsigned int.

Parameters
pathpath to value
uintnew unsigned int value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_float ( const char *  path,
float  f 
)
pure virtual

Set new value in configuration of type float.

Parameters
pathpath to value
fnew float value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_int ( const char *  path,
int  i 
)
pure virtual

Set new value in configuration of type int.

Parameters
pathpath to value
inew int value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::set_string ( const char *  path,
std::string &  s 
)
pure virtual

Set new value in configuration of type string.

Parameters
pathpath to value
snew string value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by BlackBoardLoggerPlugin::BlackBoardLoggerPlugin(), Roomba500Thread::init(), fawkes::ConfigNetworkHandler::loop(), and RetrieverConfigPlugin::post_run().

void fawkes::Configuration::set_string ( const char *  path,
const char *  s 
)
pure virtual

Set new value in configuration of type string.

Works like the aforementioned method. Just takes an good ol' char array instead of a std::string.

Parameters
pathpath to value
snew string value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::set_uint ( const char *  path,
unsigned int  uint 
)
pure virtual

Set new value in configuration of type unsigned int.

Parameters
pathpath to value
uintnew unsigned int value

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

Referenced by fawkes::ConfigNetworkHandler::loop().

void fawkes::Configuration::tag ( const char *  tag)
pure virtual

Tag this configuration version.

This creates a new tagged version of the current config. The tagged config can be accessed via load().

Parameters
tagtag for this version

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

std::list< std::string > fawkes::Configuration::tags ( )
pure virtual

List of tags.

Returns
list of tags

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

bool fawkes::Configuration::try_lock ( )
pure virtual

Try to lock the config.

See Also
Configuration::lock()
Returns
true, if the lock has been aquired, false otherwise

Implemented in fawkes::NetworkConfiguration, and fawkes::SQLiteConfiguration.

void fawkes::Configuration::unlock ( )
pure virtual

Member Data Documentation

ChangeHandlerMultimapRange fawkes::Configuration::_ch_range
protected

Change handler range.

Definition at line 182 of file config.h.

Referenced by find_handlers(), and rem_change_handler().

ChangeHandlerMultimap fawkes::Configuration::_change_handlers
protected

Registered change handlers.

Definition at line 180 of file config.h.

Referenced by add_change_handler(), find_handlers(), and rem_change_handler().


The documentation for this class was generated from the following files: