scim::ConfigBase Class Reference
[Config]

The interface class to access the configuration data. More...

#include <scim_config_base.h>

List of all members.

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

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.


Detailed Description

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.


Constructor & Destructor Documentation

scim::ConfigBase::ConfigBase (  ) 

Contrustor.

virtual scim::ConfigBase::~ConfigBase (  )  [virtual]

Virtual destructor empty but ensures that dtor of all derived classes is virtual.


Member Function Documentation

virtual bool scim::ConfigBase::valid (  )  const [pure virtual]

Check if this Config object is valid.

Returns:
true if its valid and ready to work.

Implemented in scim::DummyConfig.

virtual String scim::ConfigBase::get_name (  )  const [pure virtual]

Return the name of this configuration module.

This name must be same as the config module's name.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::read ( const String key,
String ret 
) const [pure virtual]

Read a string from the given key.

Parameters:
key - the key to be read.
ret - the result will be stored into *ret.
Returns:
true if the string is read successfully, otherwise return false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::read ( const String key,
int *  ret 
) const [pure virtual]

Read an int value from the given key.

Parameters:
key - the key to be read.
ret - the result will be stored into *ret.
Returns:
true if the value is read successfully, otherwise return false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::read ( const String key,
double *  ret 
) const [pure virtual]

Read a double value from the given key.

Parameters:
key - the key to be read.
ret - the result will be stored into *ret.
Returns:
true if the value is read successfully, otherwise return false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::read ( const String key,
bool *  ret 
) const [pure virtual]

Read a bool value from the given key.

Parameters:
key - the key to be read.
ret - the result will be stored into *ret.
Returns:
true if the value is read successfully, otherwise return false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::read ( const String key,
std::vector< String > *  ret 
) const [pure virtual]

Read a string list from the given key.

Parameters:
key - the key to be read.
ret - the result will be stored into *ret.
Returns:
true if the string list is read successfully, otherwise return false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::read ( const String key,
std::vector< int > *  ret 
) const [pure virtual]

Read an int list from the given key.

Parameters:
key - the key to be read.
ret - the result will be stored into *ret.
Returns:
true if the int list is read successfully, otherwise return false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::write ( const String key,
const String value 
) [pure virtual]

Write a string to the given key.

Parameters:
key - the key to be written.
value - the string to be written to the key.
Returns:
true if success, otherwise false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::write ( const String key,
int  value 
) [pure virtual]

Write an int value to the given key.

Parameters:
key - the key to be written.
value - the int value to be written to the key.
Returns:
true if success, otherwise false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::write ( const String key,
double  value 
) [pure virtual]

Write a double value to the given key.

Parameters:
key - the key to be written.
value - the double value to be written to the key.
Returns:
true if success, otherwise false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::write ( const String key,
bool  value 
) [pure virtual]

Write a bool value to the given key.

Parameters:
key - the key to be written.
value - the bool value to be written to the key.
Returns:
true if success, otherwise false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::write ( const String key,
const std::vector< String > &  value 
) [pure virtual]

Write a string list to the given key.

Parameters:
key - the key to be written.
value - the string list to be written to the key.
Returns:
true if success, otherwise false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::write ( const String key,
const std::vector< int > &  value 
) [pure virtual]

Write an int list to the given key.

Parameters:
key - the key to be written.
value - the int list to be written to the key.
Returns:
true if success, otherwise false.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::flush (  )  [pure virtual]

Permanently writes all changes.

Returns:
true if success.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::erase ( const String key  )  [pure virtual]

Erase a key and its value.

Parameters:
key - the key to be erased.
Returns:
true if success.

Implemented in scim::DummyConfig.

virtual bool scim::ConfigBase::reload (  )  [pure virtual]

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.

Returns:
true if success.

Implemented in scim::DummyConfig.

String scim::ConfigBase::read ( const String key,
const String defVal = String() 
) const

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.

Parameters:
key - the key to be read.
defVal - the default value to be return if failed to read.
Returns:
The result string.

int scim::ConfigBase::read ( const String key,
int  defVal 
) const

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.

Parameters:
key - the key to be read.
defVal - the default value to be return if failed to read.
Returns:
The result int value.

double scim::ConfigBase::read ( const String key,
double  defVal 
) const

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.

Parameters:
key - the key to be read.
defVal - the default value to be return if failed to read.
Returns:
The result double value.

bool scim::ConfigBase::read ( const String key,
bool  defVal 
) const

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.

Parameters:
key - the key to be read.
defVal - the default value to be return if failed to read.
Returns:
The result bool value.

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.

Parameters:
key - the key to be read.
defVal - the default value to be return if failed to read.
Returns:
The result string list.

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.

Parameters:
key - the key to be read.
defVal - the default value to be return if failed to read.
Returns:
The result int list.

Connection scim::ConfigBase::signal_connect_reload ( ConfigSlotVoid slot  ) 

connect the given slot to the reload signal.

Parameters:
slot - the given slot to be connected.
Returns:
the Connection object, can be used to disconnect this slot.

static ConfigPointer scim::ConfigBase::set ( const ConfigPointer p_config  )  [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.

Parameters:
p_config - a smart pointer to the Config object.
Returns:
a smart pointer to the old default Config object.

static ConfigPointer scim::ConfigBase::get ( bool  create_on_demand = true,
const String default_module = String("") 
) [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.

Parameters:
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.
Returns:
a smart pointer to the default global Config object.


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

Generated on Sat Jan 24 23:45:06 2009 for scim by  doxygen 1.5.7.1