ConfigAdmin class. More...
#include <ConfigAdmin.h>
Classes | |
struct | find_conf |
Public Member Functions | |
ConfigAdmin (coil::Properties &prop) | |
Constructor. | |
~ConfigAdmin (void) | |
Virtual Destructor. | |
template<typename VarType > | |
bool | bindParameter (const char *param_name, VarType &var, const char *def_val, bool(*trans)(VarType &, const char *)=coil::stringTo) |
Setup for configuration parameters. | |
void | update (void) |
Update the values of configuration parameters (Active configuration set). | |
void | update (const char *config_set) |
Update configuration parameter (By ID). | |
void | update (const char *config_set, const char *config_param) |
Update the values of configuration parameters (By name). | |
bool | isExist (const char *name) |
Check the existence of configuration parameters. | |
bool | isChanged (void) |
Confirm to change configuration parameters. | |
const char * | getActiveId (void) |
Get ID of active configuration set. | |
bool | haveConfig (const char *config_id) |
Check the existence of configuration set. | |
bool | isActive (void) |
Confirm to activate configuration set. | |
const std::vector < coil::Properties * > & | getConfigurationSets (void) |
Get all configuration sets. | |
const coil::Properties & | getConfigurationSet (const char *config_id) |
Get a configuration set by specified ID. | |
bool | setConfigurationSetValues (const coil::Properties &configuration_set) |
Add to configuration set from specified property. | |
const coil::Properties & | getActiveConfigurationSet (void) |
Get the active configuration set. | |
bool | addConfigurationSet (const coil::Properties &configuration_set) |
Add the configuration value to configuration set. | |
bool | removeConfigurationSet (const char *config_id) |
Remove the configuration set. | |
bool | activateConfigurationSet (const char *config_id) |
Activate the configuration set. | |
void | setOnUpdate (OnUpdateCallback *cb) |
void | setOnUpdateParam (OnUpdateParamCallback *cb) |
void | setOnSetConfigurationSet (OnSetConfigurationSetCallback *cb) |
void | setOnAddConfigurationSet (OnAddConfigurationAddCallback *cb) |
void | setOnRemoveConfigurationSet (OnRemoveConfigurationSetCallback *cb) |
void | setOnActivateSet (OnActivateSetCallback *cb) |
void | addConfigurationParamListener (ConfigurationParamListenerType type, ConfigurationParamListener *listener, bool autoclean=true) |
Adding ConfigurationParamListener. | |
void | removeConfigurationParamListener (ConfigurationParamListenerType type, ConfigurationParamListener *listener) |
Removing ConfigurationParamListener. | |
void | addConfigurationSetListener (ConfigurationSetListenerType type, ConfigurationSetListener *listener, bool autoclean=true) |
Adding ConfigurationSetListener. | |
void | removeConfigurationSetListener (ConfigurationSetListenerType type, ConfigurationSetListener *listener) |
Removing ConfigurationSetListener. | |
void | addConfigurationSetNameListener (ConfigurationSetNameListenerType type, ConfigurationSetNameListener *listener, bool autoclean=true) |
Adding ConfigurationSetNameListener. | |
void | removeConfigurationSetNameListener (ConfigurationSetNameListenerType type, ConfigurationSetNameListener *listener) |
Removing ConfigurationSetNameListener. | |
Protected Member Functions | |
void | onUpdate (const char *config_set) |
When the configuration parameter is updated, it is called. | |
void | onUpdateParam (const char *config_set, const char *config_param) |
When the configuration parameter is updated, it is called. | |
void | onSetConfigurationSet (const coil::Properties &config_set) |
Called when the property is added to the configuration set. | |
void | onAddConfigurationSet (const coil::Properties &config_set) |
Called when a set value is added to the configuration set. | |
void | onRemoveConfigurationSet (const char *config_id) |
Called when the configuration set has been deleted. | |
void | onActivateSet (const char *config_id) |
Called when the configuration set is made active. |
ConfigAdmin class.
Class to manage various configuration information. Now terms for this class are defined as follows.
The following two configuration informations are stored in this class.
Basically, the purpose of this class is to set one of the configuration-set in the list of (1) into parameter variables of (2). Usually, configuration parameter variables manipulation is performed with two-phases of configuration-set setting and parameter variables setting.
The configuration-set manipulations are performed by the following functions.
Modification, addition, deletion, acquisition and activation of configuration-set are performed by these functions. In order to reflect configuration-set, which is manipulated by these functions, on parameter variables that are used from RTC activities, the following update() functions are used .
Callback functors can be given to hook configuration operation. Operations to be hooked are as follows.
RTC::ConfigAdmin::ConfigAdmin | ( | coil::Properties & | prop | ) |
Constructor.
Constructor
prop | The target property name for setup |
RTC::ConfigAdmin::~ConfigAdmin | ( | void | ) |
Virtual Destructor.
Virtual Destructor
bool RTC::ConfigAdmin::activateConfigurationSet | ( | const char * | config_id | ) |
Activate the configuration set.
Activate the configuration set of specified ID Return empty configuration set, if a configuration set of specified ID doesn't exist.
config_id | ID of the target configuration set for remove |
void RTC::ConfigAdmin::addConfigurationParamListener | ( | ConfigurationParamListenerType | type, | |
ConfigurationParamListener * | listener, | |||
bool | autoclean = true | |||
) |
Adding ConfigurationParamListener.
This function adds a listener object which is called when update(const char* config_set, const char* config_param) is called. In the type argument, currently only ON_UPDATE_CONFIG_PARAM is allowed.
type | ConfigurationParamListenerType value ON_UPDATE_CONFIG_PARAM is only allowed. | |
listener | ConfigurationParamListener listener object. | |
autoclean | a flag whether if the listener object autocleaned. |
bool RTC::ConfigAdmin::addConfigurationSet | ( | const coil::Properties & | configuration_set | ) |
Add the configuration value to configuration set.
Add the configuration value to configuration set
configuration_set | Property to add |
void RTC::ConfigAdmin::addConfigurationSetListener | ( | ConfigurationSetListenerType | type, | |
ConfigurationSetListener * | listener, | |||
bool | autoclean = true | |||
) |
Adding ConfigurationSetListener.
This function add a listener object which is called when ConfigurationSet is updated. Available events are the followings.
type | ConfigurationSetListenerType value | |
listener | ConfigurationSetListener listener object. | |
autoclean | a flag whether if the listener object autocleaned. |
void RTC::ConfigAdmin::addConfigurationSetNameListener | ( | ConfigurationSetNameListenerType | type, | |
ConfigurationSetNameListener * | listener, | |||
bool | autoclean = true | |||
) |
Adding ConfigurationSetNameListener.
This function add a listener object which is called when ConfigurationSetName is updated. Available events are the followings.
type | ConfigurationSetNameListenerType value | |
listener | ConfigurationSetNameListener listener object. | |
autoclean | a flag whether if the listener object autocleaned. |
bool RTC::ConfigAdmin::bindParameter | ( | const char * | param_name, | |
VarType & | var, | |||
const char * | def_val, | |||
bool(*)(VarType &, const char *) | trans = coil::stringTo | |||
) | [inline] |
Setup for configuration parameters.
Bind configuration parameter to its variable. Return false, if configuration parameter of specified name has already existed. Specify the data type of the configuration as <VarType>.
param_name | Configuration parameter name | |
var | Configuration parameter variable | |
def_val | Default value of configuration parameter | |
trans | Function to transform configuration parameter type into string format |
Referenced by RTC::RTObject_impl::bindParameter().
const coil::Properties& RTC::ConfigAdmin::getActiveConfigurationSet | ( | void | ) |
Get the active configuration set.
Get the current active configuration set. Return empty configuration set, if an active configuration set doesn't exist.
const char* RTC::ConfigAdmin::getActiveId | ( | void | ) | [inline] |
Get ID of active configuration set.
Get ID of the current active configuration set.
const coil::Properties& RTC::ConfigAdmin::getConfigurationSet | ( | const char * | config_id | ) |
Get a configuration set by specified ID.
Get a configuration set that was specified by ID Return empty configuration set, if a configuration set of specified ID doesn't exist.
config_id | ID of the target configuration set for getting |
const std::vector<coil::Properties*>& RTC::ConfigAdmin::getConfigurationSets | ( | void | ) |
Get all configuration sets.
Get all specified configuration sets
bool RTC::ConfigAdmin::haveConfig | ( | const char * | config_id | ) | [inline] |
Check the existence of configuration set.
Check the existence of specified configuration set.
config_id | ID of target configuration set for confirmation |
bool RTC::ConfigAdmin::isActive | ( | void | ) | [inline] |
Confirm to activate configuration set.
Confirm that configuration set has been activated.
bool RTC::ConfigAdmin::isChanged | ( | void | ) | [inline] |
Confirm to change configuration parameters.
Confirm that configuration parameters have changed.
bool RTC::ConfigAdmin::isExist | ( | const char * | name | ) |
Check the existence of configuration parameters.
Check the existence of configuration parameters of specified name.
name | Configuration parameter name |
void RTC::ConfigAdmin::onActivateSet | ( | const char * | config_id | ) | [protected] |
Called when the configuration set is made active.
Call the set callback object.
config_id | property |
void RTC::ConfigAdmin::onAddConfigurationSet | ( | const coil::Properties & | config_set | ) | [protected] |
Called when a set value is added to the configuration set.
Call the set callback object.
configuration_set | property |
void RTC::ConfigAdmin::onRemoveConfigurationSet | ( | const char * | config_id | ) | [protected] |
Called when the configuration set has been deleted.
Call the set callback object.
config_id | property |
void RTC::ConfigAdmin::onSetConfigurationSet | ( | const coil::Properties & | config_set | ) | [protected] |
Called when the property is added to the configuration set.
Call the set callback object.
configuration_set | property |
void RTC::ConfigAdmin::onUpdate | ( | const char * | config_set | ) | [protected] |
When the configuration parameter is updated, it is called.
Call the set callback object.
config_set | The target configuration set's ID to setup |
void RTC::ConfigAdmin::onUpdateParam | ( | const char * | config_set, | |
const char * | config_param | |||
) | [protected] |
When the configuration parameter is updated, it is called.
Call the set callback object.
config_set | configuration-set ID. | |
config_param | configuration parameter name. |
void RTC::ConfigAdmin::removeConfigurationParamListener | ( | ConfigurationParamListenerType | type, | |
ConfigurationParamListener * | listener | |||
) |
Removing ConfigurationParamListener.
This function removes a listener object which is added by addConfigurationParamListener() function.
type | ConfigurationParamListenerType value ON_UPDATE_CONFIG_PARAM is only allowed. | |
listener | a pointer to ConfigurationParamListener listener object. |
bool RTC::ConfigAdmin::removeConfigurationSet | ( | const char * | config_id | ) |
Remove the configuration set.
Remove the configuration set of specified ID Return empty configuration set, if a configuration set of specified ID doesn't exist.
The configuration-sets that can be removed by this function are only configuration-sets newly added by the addConfigurationSet() function. The configuration that can be removed by this function is only newly added configuration-set by addConfigurationSet() function. The "default" configuration-set and configurationi-sets that is loaded from configuration file cannot be removed.
If the specified configuration is active currently, any configurations are not deleted.
Callback functions that are set by addOnRemovedConfigurationSet() will be called if a configuration-set is deleted actually by this function.
config_id | ID of the target configuration set for remove |
void RTC::ConfigAdmin::removeConfigurationSetListener | ( | ConfigurationSetListenerType | type, | |
ConfigurationSetListener * | listener | |||
) |
Removing ConfigurationSetListener.
This function removes a listener object which is added by addConfigurationSetListener() function.
type | ConfigurationSetListenerType value | |
listener | a pointer to ConfigurationSetListener listener object. |
void RTC::ConfigAdmin::removeConfigurationSetNameListener | ( | ConfigurationSetNameListenerType | type, | |
ConfigurationSetNameListener * | listener | |||
) |
Removing ConfigurationSetNameListener.
This function removes a listener object which is added by addConfigurationSetNameListener() function.
type | ConfigurationSetNameListenerType value ON_UPDATE_CONFIG_PARAM is only allowed. | |
listener | a pointer to ConfigurationSetNameListener listener object. |
bool RTC::ConfigAdmin::setConfigurationSetValues | ( | const coil::Properties & | configuration_set | ) |
Add to configuration set from specified property.
Add specified property to configuration set that was specified by ID. Return false if configuration set, that matches specified ID, doesn't exist.
config_id | ID of the target configuration set for add | |
configuration_set | Property to add |
void RTC::ConfigAdmin::setOnActivateSet | ( | OnActivateSetCallback * | cb | ) |
void RTC::ConfigAdmin::setOnAddConfigurationSet | ( | OnAddConfigurationAddCallback * | cb | ) |
void RTC::ConfigAdmin::setOnRemoveConfigurationSet | ( | OnRemoveConfigurationSetCallback * | cb | ) |
void RTC::ConfigAdmin::setOnSetConfigurationSet | ( | OnSetConfigurationSetCallback * | cb | ) |
void RTC::ConfigAdmin::setOnUpdate | ( | OnUpdateCallback * | cb | ) |
void RTC::ConfigAdmin::setOnUpdateParam | ( | OnUpdateParamCallback * | cb | ) |
void RTC::ConfigAdmin::update | ( | const char * | config_set, | |
const char * | config_param | |||
) |
Update the values of configuration parameters (By name).
This operation updates a configuration variable by the specified configuration parameter in the configuration-set. This operation does not change current active configuration-set. Since this operation causes inconsistency between current active configuration set and actual values of configuration variables, user should carefully use it.
This operation ends without doing anything, if the configuration-set or the configuration parameter do not exist.
config_set | configuration-set ID. | |
config_param | configuration parameter name. |
void RTC::ConfigAdmin::update | ( | const char * | config_set | ) |
Update configuration parameter (By ID).
This operation updates configuration variables by the configuration-set with specified ID. This operation does not change current active configuration-set. Since this operation causes inconsistency between current active configuration set and actual values of configuration variables, user should carefully use it.
This operation ends without doing anything, if the configuration-set does not exist.
config_set | The target configuration set's ID to setup |
void RTC::ConfigAdmin::update | ( | void | ) |
Update the values of configuration parameters (Active configuration set).
When configuration set is updated, update the configuration parameter value to the value that is set to the current active configuration. This update will be executed, only when an active configuration set exists and the content of the configuration set has been updated from the last update.