Fawkes API
Fawkes Development Version
|
Configuration store using YAML documents. More...
#include <>>
Classes | |
class | YamlValueIterator |
Iterator for YAML config trees. More... | |
Public Member Functions | |
YamlConfiguration () | |
Constructor. More... | |
YamlConfiguration (const char *sysconfdir, const char *userconfdir=NULL) | |
Constructor. More... | |
virtual | ~YamlConfiguration () |
Destructor. More... | |
virtual void | copy (Configuration *copyconf) |
Copies all values from the given configuration. More... | |
virtual void | load (const char *file_path) |
Load configuration. More... | |
virtual bool | exists (const char *path) |
Check if a given value exists. More... | |
virtual bool | is_float (const char *path) |
Check if a value is of type float. More... | |
virtual bool | is_uint (const char *path) |
Check if a value is of type unsigned int. More... | |
virtual bool | is_int (const char *path) |
Check if a value is of type int. More... | |
virtual bool | is_bool (const char *path) |
Check if a value is of type bool. More... | |
virtual bool | is_string (const char *path) |
Check if a value is of type string. More... | |
virtual bool | is_list (const char *path) |
Check if a value is a list. More... | |
virtual bool | is_default (const char *path) |
Check if a value was read from the default config. More... | |
virtual std::string | get_type (const char *path) |
Get type of value at given path. More... | |
virtual float | get_float (const char *path) |
Get value from configuration which is of type float. More... | |
virtual unsigned int | get_uint (const char *path) |
Get value from configuration which is of type unsigned int. More... | |
virtual int | get_int (const char *path) |
Get value from configuration which is of type int. More... | |
virtual bool | get_bool (const char *path) |
Get value from configuration which is of type bool. More... | |
virtual std::string | get_string (const char *path) |
Get value from configuration which is of type string. More... | |
virtual std::vector< float > | get_floats (const char *path) |
Get list of values from configuration which is of type float. More... | |
virtual std::vector< unsigned int > | get_uints (const char *path) |
Get list of values from configuration which is of type unsigned int. More... | |
virtual std::vector< int > | get_ints (const char *path) |
Get list of values from configuration which is of type int. More... | |
virtual std::vector< bool > | get_bools (const char *path) |
Get list of values from configuration which is of type bool. More... | |
virtual std::vector< std::string > | get_strings (const char *path) |
Get list of values from configuration which is of type string. More... | |
virtual ValueIterator * | get_value (const char *path) |
Get value from configuration. More... | |
virtual std::string | get_comment (const char *path) |
Get comment of value at given path. More... | |
virtual std::string | get_default_comment (const char *path) |
Get comment of value at given path. More... | |
virtual void | set_float (const char *path, float f) |
Set new value in configuration of type float. More... | |
virtual void | set_uint (const char *path, unsigned int uint) |
Set new value in configuration of type unsigned int. More... | |
virtual void | set_int (const char *path, int i) |
Set new value in configuration of type int. More... | |
virtual void | set_bool (const char *path, bool b) |
Set new value in configuration of type bool. More... | |
virtual void | set_string (const char *path, std::string &s) |
Set new value in configuration of type string. More... | |
virtual void | set_string (const char *path, const char *s) |
Set new value in configuration of type string. More... | |
virtual void | set_floats (const char *path, std::vector< float > &f) |
Set new value in configuration of type float. More... | |
virtual void | set_uints (const char *path, std::vector< unsigned int > &uint) |
Set new value in configuration of type unsigned int. More... | |
virtual void | set_ints (const char *path, std::vector< int > &i) |
Set new value in configuration of type int. More... | |
virtual void | set_bools (const char *path, std::vector< bool > &b) |
Set new value in configuration of type bool. More... | |
virtual void | set_strings (const char *path, std::vector< std::string > &s) |
Set new value in configuration of type string. More... | |
virtual void | set_strings (const char *path, std::vector< const char *> &s) |
Set new value in configuration of type string. More... | |
virtual void | set_comment (const char *path, std::string &comment) |
Set new comment for existing value. More... | |
virtual void | set_comment (const char *path, const char *comment) |
Set new comment for existing value. More... | |
virtual void | erase (const char *path) |
Erase the given value from the configuration. More... | |
virtual void | set_default_float (const char *path, float f) |
Set new default value in configuration of type float. More... | |
virtual void | set_default_uint (const char *path, unsigned int uint) |
Set new default value in configuration of type unsigned int. More... | |
virtual void | set_default_int (const char *path, int i) |
Set new default value in configuration of type int. More... | |
virtual void | set_default_bool (const char *path, bool b) |
Set new default value in configuration of type bool. More... | |
virtual void | set_default_string (const char *path, std::string &s) |
Set new default value in configuration of type string. More... | |
virtual void | set_default_string (const char *path, const char *s) |
Set new default value in configuration of type string. More... | |
virtual void | set_default_comment (const char *path, const char *comment) |
Set new default comment for existing default configuration value. More... | |
virtual void | set_default_comment (const char *path, std::string &comment) |
Set new default comment for existing default configuration value. More... | |
virtual void | erase_default (const char *path) |
Erase the given default value from the configuration. More... | |
ValueIterator * | iterator () |
Iterator for all values. More... | |
ValueIterator * | search (const char *path) |
Iterator with search results. More... | |
void | lock () |
Lock the config. More... | |
bool | try_lock () |
Try to lock the config. More... | |
void | unlock () |
Unlock the config. More... | |
virtual void | try_dump () |
Try to dump configuration. More... | |
virtual void | fam_event (const char *filename, unsigned int mask) |
Event has been raised. More... | |
![]() | |
virtual | ~Configuration () |
Virtual empty destructor. 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 | ~FamListener () |
Virtual empty destructor. More... | |
Additional Inherited Members | |
![]() | |
static const unsigned int | FAM_ACCESS = 0x00000001 |
File was accessed. More... | |
static const unsigned int | FAM_MODIFY = 0x00000002 |
File was modified. More... | |
static const unsigned int | FAM_ATTRIB = 0x00000004 |
Metadata changed. More... | |
static const unsigned int | FAM_CLOSE_WRITE = 0x00000008 |
Writtable file was closed. More... | |
static const unsigned int | FAM_CLOSE_NOWRITE = 0x00000010 |
Unwrittable file closed. More... | |
static const unsigned int | FAM_CLOSE = (FAM_CLOSE_WRITE | FAM_CLOSE_NOWRITE) |
Close. More... | |
static const unsigned int | FAM_OPEN = 0x00000020 |
File was opened. More... | |
static const unsigned int | FAM_MOVED_FROM = 0x00000040 |
File was moved from X. More... | |
static const unsigned int | FAM_MOVED_TO = 0x00000080 |
File was moved to Y. More... | |
static const unsigned int | FAM_MOVE = (FAM_MOVED_FROM | FAM_MOVED_TO) |
Moves. More... | |
static const unsigned int | FAM_CREATE = 0x00000100 |
Subfile was created. More... | |
static const unsigned int | FAM_DELETE = 0x00000200 |
Subfile was deleted. More... | |
static const unsigned int | FAM_DELETE_SELF = 0x00000400 |
Self was deleted. More... | |
static const unsigned int | FAM_MOVE_SELF = 0x00000800 |
Self was moved. More... | |
static const unsigned int | FAM_UNMOUNT = 0x00002000 |
Backing fs was unmounted. More... | |
static const unsigned int | FAM_Q_OVERFLOW = 0x00004000 |
Event queued overflowed. More... | |
static const unsigned int | FAM_IGNORED = 0x00008000 |
File was ignored. More... | |
static const unsigned int | FAM_ONLYDIR = 0x01000000 |
Only watch the path if it is a directory. More... | |
static const unsigned int | FAM_DONT_FOLLOW = 0x02000000 |
Do not follow a sym link. More... | |
static const unsigned int | FAM_MASK_ADD = 0x20000000 |
Add to the mask of an already existing watch. More... | |
static const unsigned int | FAM_ISDIR = 0x40000000 |
Event occurred against dir. More... | |
static const unsigned int | FAM_ONESHOT = 0x80000000 |
Only send event once. More... | |
static const unsigned int | FAM_ALL_EVENTS |
All events which a program can wait on. More... | |
![]() | |
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... | |
![]() | |
ChangeHandlerList * | find_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... | |
![]() | |
ChangeHandlerMultimap | _change_handlers |
Registered change handlers. More... | |
ChangeHandlerMultimapRange | _ch_range |
Change handler range. More... | |
Configuration store using YAML documents.
fawkes::YamlConfiguration::YamlConfiguration | ( | ) |
fawkes::YamlConfiguration::YamlConfiguration | ( | const char * | sysconfdir, |
const char * | userconfdir = NULL |
||
) |
Constructor.
sysconfdir | system configuration directory, will be searched for default configuration file, and system will try to create host-specific database if writable |
userconfdir | user configuration directory, will be searched preferably for default configuration file, and will be used to create host-specific database if sysconfdir is not writable. This directory will be created if it does not exist during load(). |
|
virtual |
|
virtual |
Copies 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 copied config will remain unchanged.
copyconf | configuration to copy |
Implements fawkes::Configuration.
|
virtual |
Erase the given value from the configuration.
It is not an error if the value does not exists before deletion.
path | path to value |
Implements fawkes::Configuration.
|
virtual |
Erase the given default value from the configuration.
It is not an error if the value does not exists before deletion.
path | path to value |
Implements fawkes::Configuration.
|
virtual |
Check if a given value exists.
path | path to value |
Implements fawkes::Configuration.
|
virtual |
Event has been raised.
filename | name of the file that triggered the event |
mask | mask indicating the event. Currently inotify event flags are used, see inotify.h. |
Implements fawkes::FamListener.
Definition at line 603 of file yaml.cpp.
References lock(), fawkes::LibLogger::log_warn(), fawkes::Configuration::notify_handlers(), and fawkes::RefPtr< T_CppObject >::reset().
|
virtual |
Get value from configuration which is of type bool.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1021 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get list of values from configuration which is of type bool.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1054 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get comment of value at given path.
The value at the given path must exist in the host-specific configuration.
path | path to value |
ConfigEntryNotFoundException | shall be thrown if value does not exist |
ConfigurationException | shall be thrown on any other error |
Implements fawkes::Configuration.
|
virtual |
Get comment of value at given path.
The value at the given path must exist in the default configuration.
path | path to value |
ConfigEntryNotFoundException | shall be thrown if value does not exist |
ConfigurationException | shall be thrown on any other error |
Implements fawkes::Configuration.
|
virtual |
Get value from configuration which is of type float.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1003 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get list of values from configuration which is of type float.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1034 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get value from configuration which is of type int.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1015 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get list of values from configuration which is of type int.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1048 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get value from configuration which is of type string.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1027 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get list of values from configuration which is of type string.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1060 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get type of value at given path.
path | path to value |
ConfigurationException | shall be thrown if value does not exist or on any other error. |
Implements fawkes::Configuration.
|
virtual |
Get value from configuration which is of type unsigned int.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1009 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get list of values from configuration which is of type unsigned int.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1041 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Get value from configuration.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1147 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path(), and fawkes::YamlConfiguration::YamlValueIterator::YamlValueIterator().
|
virtual |
Check if a value is of type bool.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1110 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Check if a value was read from the default config.
path | path to value |
Implements fawkes::Configuration.
|
virtual |
Check if a value is of type float.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1084 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Check if a value is of type int.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1104 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Check if a value is a list.
path | path to value |
Implements fawkes::Configuration.
|
virtual |
Check if a value is of type string.
path | path to value |
Implements fawkes::Configuration.
Definition at line 1116 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Check if a value is of type unsigned int.
path | path to value |
Implements fawkes::Configuration.
|
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.
Implements fawkes::Configuration.
Definition at line 1376 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::YamlValueIterator().
|
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.
file_path | path of the configuration file. |
Implements fawkes::Configuration.
Definition at line 427 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path().
|
virtual |
Lock the config.
No further changes or queries can be executed on the configuration and will block until the config is unlocked.
Implements fawkes::Configuration.
Definition at line 1337 of file yaml.cpp.
Referenced by fam_event().
|
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
is effectively the same as a call to iterator().
path | start of path |
Implements fawkes::Configuration.
Definition at line 1384 of file yaml.cpp.
References fawkes::YamlConfiguration::YamlValueIterator::path(), fawkes::str_split_to_queue(), and fawkes::YamlConfiguration::YamlValueIterator::YamlValueIterator().
|
virtual |
Set new value in configuration of type bool.
path | path to value |
b | new bool value |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type bool.
path | path to value |
b | new bool values |
Implements fawkes::Configuration.
|
virtual |
Set new comment for existing value.
path | path to value |
comment | new comment string |
Implements fawkes::Configuration.
|
virtual |
Set new comment for existing value.
Works like the aforementioned method. Just takes an good ol' char array instead of a std::string.
path | path to value |
comment | new comment string |
Implements fawkes::Configuration.
|
virtual |
Set new default value in configuration of type bool.
path | path to value |
b | new bool value |
Implements fawkes::Configuration.
|
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.
path | path to value |
comment | new comment string |
Implements fawkes::Configuration.
Definition at line 1314 of file yaml.cpp.
Referenced by set_default_comment().
|
virtual |
Set new default comment for existing default configuration value.
path | path to value |
comment | new comment string |
Implements fawkes::Configuration.
Definition at line 1320 of file yaml.cpp.
References set_default_comment().
|
virtual |
Set new default value in configuration of type float.
path | path to value |
f | new float value |
Implements fawkes::Configuration.
|
virtual |
Set new default value in configuration of type int.
path | path to value |
i | new int value |
Implements fawkes::Configuration.
|
virtual |
Set new default value in configuration of type string.
path | path to value |
s | new string value |
Implements fawkes::Configuration.
|
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.
path | path to value |
s | new string value |
Implements fawkes::Configuration.
|
virtual |
Set new default value in configuration of type unsigned int.
path | path to value |
uint | new unsigned int value |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type float.
path | path to value |
f | new float value |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type float.
path | path to value |
f | new float values |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type int.
path | path to value |
i | new int value |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type int.
path | path to value |
i | new int values |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type string.
path | path to value |
s | new string value |
Implements fawkes::Configuration.
|
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.
path | path to value |
s | new string value |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type string.
path | path to value |
s | new string values |
Implements fawkes::Configuration.
|
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.
path | path to value |
s | new string values |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type unsigned int.
path | path to value |
uint | new unsigned int value |
Implements fawkes::Configuration.
|
virtual |
Set new value in configuration of type unsigned int.
path | path to value |
uint | new unsigned int values |
Implements fawkes::Configuration.
|
virtual |
Try to dump configuration.
For configuration methods that transform configuration files in a binary format this can be used to write out the text representation on shutdown of Fawkes.
Exception | thrown if dumping fails |
Implements fawkes::Configuration.
|
virtual |
Try to lock the config.
Implements fawkes::Configuration.
|
virtual |