BrisaCore::BrisaConfigurationManager Class Reference

Class that provides an easy way of managing configurations. More...

#include <brisaconfig.h>

List of all members.

Public Member Functions

 BrisaConfigurationManager (const QString &configPath, const QHash< QString, QString > &state)
void setDirectAccess (bool access)
bool getDirectAccess ()
void update ()
void save ()
QString getParameter (const QString &section, const QString &parameter)
void setParameter (const QString &section, const QString &parameter, const QString &parValue)
QList< QString > getSectionNames ()
QHash< QString, QString > items (const QString &section)
bool removeSection (const QString &section)

Detailed Description

Class that provides an easy way of managing configurations.

Configuration is organized in sections, which may contain parameters. Each section has a name and a parameter has a name and a value.

Concerning storage, the configuration can be saved on a sqlite database. Also, there's a feature called "direct access" that enables direct operations on the database. For example,a getParameter() call would retrieve the value of a parameter directly from the database, if the feature is enabled.

When disabled, all methods apply to (what we call) the "state". The state initially contains the same information that is on the database, but if the "direct access" feature is disabled, all get()'s and set()'s apply to the state. This means you can have a "runtime configuration" and a "static configuration".

By default, the "direct access" feature is disabled. To enable it, just call setDirectAccess(True).

The state can be saved on the persistence by explicitly calling save() It can also update its values by explicitly calling update().

Definition at line 63 of file brisaconfig.h.


Constructor & Destructor Documentation

BrisaConfigurationManager::BrisaConfigurationManager ( const QString &  configPath,
const QHash< QString, QString > &  state 
)

Constructor for the BrisaConfigurationManager class.

Parameters:
config_path a QString that represents the path of the database to work on. If not supplied will work on a memory database.
state,: hash as a dictionaryr with sections and parameters.\ Keys are section.parameters format and values are the their respective values.

Definition at line 37 of file brisaconfig.cpp.


Member Function Documentation

bool BrisaConfigurationManager::getDirectAccess (  ) 

Returns False if the ConfigurationManager is currently working on the runtime state. Otherwise, it will return True, which means it's working directly on the persistence.

Returns:
The current status of the ConfigurationManager

Definition at line 50 of file brisaconfig.cpp.

QString BrisaConfigurationManager::getParameter ( const QString &  section,
const QString &  parameter 
)

Retrieves the value associated with the parameter in the section given.

Parameters:
section a section to find the parameter
parameter a parameter to return the value
Returns:
the value for the given parameter

Definition at line 70 of file brisaconfig.cpp.

QList< QString > BrisaConfigurationManager::getSectionNames (  ) 

Returns the names of all sections.

Returns:
a QList with its parameters and values

Definition at line 101 of file brisaconfig.cpp.

QHash< QString, QString > BrisaConfigurationManager::items ( const QString &  section  ) 

Returns all the items of the given section.

Parameters:
section name
Returns:
a dictionary with all the items of the given section

Definition at line 119 of file brisaconfig.cpp.

bool BrisaConfigurationManager::removeSection ( const QString &  section  ) 

Removes a section given the name.

Parameters:
section,: section name to be removed
Returns:
a boolean. true whether is possible remove it

Definition at line 135 of file brisaconfig.cpp.

void BrisaConfigurationManager::save (  ) 

Stores the state of the manager on the persistence.

Definition at line 62 of file brisaconfig.cpp.

void BrisaConfigurationManager::setDirectAccess ( bool  access  ) 

Sets the direct access option of the ConfigurationManager. When True, direct access makes all get and set methods work directly on the database, not on the current state.

Parameters:
access a boolean argument to set direct access option of the BrisaConfigurationManager

Definition at line 46 of file brisaconfig.cpp.

void BrisaConfigurationManager::setParameter ( const QString &  section,
const QString &  parameter,
const QString &  parValue 
)

Sets a parameter's value in the given section. If the parameter does not exist, it gets created.

Parameters:
section a section to set the parameter
parameter a parameter to set the value
parameter a value to be set

Definition at line 84 of file brisaconfig.cpp.

void BrisaConfigurationManager::update (  ) 

Updates the current state of the manager according to persistence data.

Definition at line 54 of file brisaconfig.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Sep 30 14:04:30 2010 for Brisa by  doxygen 1.6.3