scim 1.4.18
|
The interface class to access the configuration data. More...
#include <scim_config_base.h>
Public Member Functions | |
Constructor and Destructor. | |
ConfigBase () | |
Contrustor. | |
virtual | ~ConfigBase () |
Virtual destructor empty but ensures that dtor of all derived classes is virtual. | |
Pure virtual methods which should be implemented in derived classes. | |
virtual bool | valid () const =0 |
Check if this Config object is valid. | |
virtual String | get_name () const =0 |
Return the name of this configuration module. | |
virtual bool | read (const String &key, String *ret) const =0 |
Read a string from the given key. | |
virtual bool | read (const String &key, int *ret) const =0 |
Read an int value from the given key. | |
virtual bool | read (const String &key, double *ret) const =0 |
Read a double value from the given key. | |
virtual bool | read (const String &key, bool *ret) const =0 |
Read a bool value from the given key. | |
virtual bool | read (const String &key, std::vector< String > *ret) const =0 |
Read a string list from the given key. | |
virtual bool | read (const String &key, std::vector< int > *ret) const =0 |
Read an int list from the given key. | |
virtual bool | write (const String &key, const String &value)=0 |
Write a string to the given key. | |
virtual bool | write (const String &key, int value)=0 |
Write an int value to the given key. | |
virtual bool | write (const String &key, double value)=0 |
Write a double value to the given key. | |
virtual bool | write (const String &key, bool value)=0 |
Write a bool value to the given key. | |
virtual bool | write (const String &key, const std::vector< String > &value)=0 |
Write a string list to the given key. | |
virtual bool | write (const String &key, const std::vector< int > &value)=0 |
Write an int list to the given key. | |
virtual bool | flush ()=0 |
Permanently writes all changes. | |
virtual bool | erase (const String &key)=0 |
Erase a key and its value. | |
virtual bool | reload ()=0 |
Reload the configurations from storage. | |
Other helper methods. | |
String | read (const String &key, const String &defVal=String()) const |
Read a string from the given key with a default fallback value. | |
int | read (const String &key, int defVal) const |
Read an int value from the given key with a default fallback value. | |
double | read (const String &key, double defVal) const |
Read a double value from the given key with a default fallback value. | |
bool | read (const String &key, bool defVal) const |
Read a bool value from the given key with a default fallback value. | |
std::vector< String > | read (const String &key, const std::vector< String > &defVal) const |
Read a string list from the given key with a default fallback value. | |
std::vector< int > | read (const String &key, const std::vector< int > &defVal) const |
Read an int list from the given key with a default fallback value. | |
Connection | signal_connect_reload (ConfigSlotVoid *slot) |
connect the given slot to the reload signal. | |
![]() | |
bool | is_referenced () const |
void | ref () |
Increase an object's reference count by one. | |
void | unref () |
Static Public Member Functions | |
static ConfigPointer | set (const ConfigPointer &p_config) |
Set the default global Config object. | |
static ConfigPointer | get (bool create_on_demand=true, const String &default_module=String("")) |
Get the default global Config object. | |
Additional Inherited Members | |
![]() | |
ReferencedObject () | |
Constructor. | |
virtual | ~ReferencedObject ()=0 |
Destructor. | |
void | set_referenced (bool reference) |
The interface class to access the configuration data.
This is an interface class to access the configuration data. All of the SCIM objects which have configuration data should use this interface to store and load them.
scim::ConfigBase::ConfigBase | ( | ) |
Contrustor.
|
virtual |
Virtual destructor empty but ensures that dtor of all derived classes is virtual.
Check if this Config object is valid.
Implemented in scim::DummyConfig.
Return the name of this configuration module.
This name must be same as the config module's name.
Implemented in scim::DummyConfig.
Read a string from the given key.
key | - the key to be read. |
ret | - the result will be stored into *ret. |
Implemented in scim::DummyConfig.
Read an int value from the given key.
key | - the key to be read. |
ret | - the result will be stored into *ret. |
Implemented in scim::DummyConfig.
Read a double value from the given key.
key | - the key to be read. |
ret | - the result will be stored into *ret. |
Implemented in scim::DummyConfig.
Read a bool value from the given key.
key | - the key to be read. |
ret | - the result will be stored into *ret. |
Implemented in scim::DummyConfig.
|
pure virtual |
Read a string list from the given key.
key | - the key to be read. |
ret | - the result will be stored into *ret. |
Implemented in scim::DummyConfig.
|
pure virtual |
Read an int list from the given key.
key | - the key to be read. |
ret | - the result will be stored into *ret. |
Implemented in scim::DummyConfig.
Write a string to the given key.
key | - the key to be written. |
value | - the string to be written to the key. |
Implemented in scim::DummyConfig.
Write an int value to the given key.
key | - the key to be written. |
value | - the int value to be written to the key. |
Implemented in scim::DummyConfig.
Write a double value to the given key.
key | - the key to be written. |
value | - the double value to be written to the key. |
Implemented in scim::DummyConfig.
Write a bool value to the given key.
key | - the key to be written. |
value | - the bool value to be written to the key. |
Implemented in scim::DummyConfig.
|
pure virtual |
Write a string list to the given key.
key | - the key to be written. |
value | - the string list to be written to the key. |
Implemented in scim::DummyConfig.
|
pure virtual |
Write an int list to the given key.
key | - the key to be written. |
value | - the int list to be written to the key. |
Implemented in scim::DummyConfig.
Erase a key and its value.
key | - the key to be erased. |
Implemented in scim::DummyConfig.
Reload the configurations from storage.
All modified keys after the last flush maybe lost.
The derived method should call this base method after reload the configurations successfully, in order to emit the reload signal.
The derived method should have some machanism to avoid reload again if there is no update after the previous reload.
Implemented in scim::DummyConfig.
Read a string from the given key with a default fallback value.
If failed to read from the given key, then return the given default value.
key | - the key to be read. |
defVal | - the default value to be return if failed to read. |
Read an int value from the given key with a default fallback value.
If failed to read from the given key, then return the given default value.
key | - the key to be read. |
defVal | - the default value to be return if failed to read. |
Read a double value from the given key with a default fallback value.
If failed to read from the given key, then return the given default value.
key | - the key to be read. |
defVal | - the default value to be return if failed to read. |
Read a bool value from the given key with a default fallback value.
If failed to read from the given key, then return the given default value.
key | - the key to be read. |
defVal | - the default value to be return if failed to read. |
std::vector< String > scim::ConfigBase::read | ( | const String & | key, |
const std::vector< String > & | defVal ) const |
Read a string list from the given key with a default fallback value.
If failed to read from the given key, then return the given default value.
key | - the key to be read. |
defVal | - the default value to be return if failed to read. |
std::vector< int > scim::ConfigBase::read | ( | const String & | key, |
const std::vector< int > & | defVal ) const |
Read an int list from the given key with a default fallback value.
If failed to read from the given key, then return the given default value.
key | - the key to be read. |
defVal | - the default value to be return if failed to read. |
Connection scim::ConfigBase::signal_connect_reload | ( | ConfigSlotVoid * | slot | ) |
connect the given slot to the reload signal.
slot | - the given slot to be connected. |
|
static |
Set the default global Config object.
There is only one global Config object in an application. All other objects should use it by default.
p_config | - a smart pointer to the Config object. |
|
static |
Get the default global Config object.
The default global Config object can be set with function ConfigBase::set. If there is no default object set, a new object can be created if needed.
create_on_demand | - if it's true then a new object will be created, if there is no one available. |
default_module | - the Config module should be used to create the default Config object. If omitted, then use the default module defined in global config file. |