Fawkes API  Fawkes Development Version
fawkes::Configuration Class Reference

Interface for configuration handling. More...

#include <>>

Inheritance diagram for fawkes::Configuration:

List of all members.

Classes

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

Public Member Functions

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

Protected Types

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

Protected Member Functions

ChangeHandlerListfind_handlers (const char *path)
 Find handlers for given path.

Protected Attributes

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

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.


Member Typedef Documentation

List that contains pointers to ConfigurationChangeHandler.

Definition at line 166 of file config.h.

Multimap string to config change handlers.

Definition at line 170 of file config.h.

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

Config change handler multimap range.

Definition at line 175 of file config.h.


Constructor & Destructor Documentation

fawkes::Configuration::~Configuration ( ) [inline, virtual]

Virtual empty destructor.

Definition at line 65 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 474 of file config.cpp.

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

Referenced by ConfigChangeWatcherTool::ConfigChangeWatcherTool(), fawkes::ConfigNetworkHandler::ConfigNetworkHandler(), fawkes::NetworkConfiguration::add_change_handler(), 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.

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(), and PanTiltRX28Thread::init().

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().

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::NetworkConfiguration::copy(), and fawkes::SQLiteConfiguration::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.

Referenced by FawkesMainThread::FawkesMainThread().

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::ConfigNetworkHandler::loop(), fawkes::NetworkConfiguration::copy(), fawkes::SQLiteConfiguration::copy(), 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 491 of file config.cpp.

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

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

Configuration::ValueIterator * fawkes::Configuration::search ( const char *  path) [pure virtual]

Iterator with search results.

Returns an iterator that can be used to iterate over the search results. All values whose path start with the given strings are returned. A call like

   config->search("");

is effectively the same as a call to iterator().

Parameters:
pathstart of path
Returns:
iterator to search results

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

Referenced by FvRetrieverPlugin::FvRetrieverPlugin(), BlackBoardLoggerPlugin::BlackBoardLoggerPlugin(), BlackBoardLogReplayPlugin::BlackBoardLogReplayPlugin(), BlackBoardSynchronizationPlugin::BlackBoardSynchronizationPlugin(), LaserDeadSpotsDataFilter::LaserDeadSpotsDataFilter(), LaserPlugin::LaserPlugin(), PanTiltPlugin::PanTiltPlugin(), EclipseAgentThread::init(), WorldModelThread::init(), and RetrieverConfigPlugin::pre_run().

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(), and FawkesMainThread::FawkesMainThread().

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 fawkes::ConfigNetworkHandler::loop(), BlackBoardLoggerPlugin::BlackBoardLoggerPlugin(), 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

Change handler range.

Definition at line 180 of file config.h.

Referenced by rem_change_handler(), and find_handlers().

Registered change handlers.

Definition at line 178 of file config.h.

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


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