eVaf
eVaf::Common::Internal::Config Class Reference

Default implementation of the iConfig interface. More...

#include <Common/config.h>

Public Member Functions

iConfig_interface () const
 Returns the current implementation of the iConfig interface. More...
 
 Config ()
 
void done ()
 Finalizes the iConfig interface implementation. More...
 
virtual QVariant getValue (QString const &paramName, QVariant const &defaultValue) const
 Reads a configuration parameter value. More...
 
bool init ()
 Initializes the iConfig interface implementation. More...
 
virtual bool setValue (QString const &paramName, QVariant const &value, bool commit)
 Writes a configuration parameter value. More...
 
virtual ~Config ()
 
- Public Member Functions inherited from eVaf::Common::iConfig
 iConfig ()
 Interface constructor. More...
 
virtual ~iConfig ()
 Empty virtual destructor. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from eVaf::Common::iConfig
static iConfiginstance ()
 Returns the current iConfig interface instance. More...
 

Detailed Description

Default implementation of the iConfig interface.

This class implements the iConfig interface using INI files in the eVaf::Common::iApp::instance()->etcDir() directory.

Definition at line 55 of file config.h.

Constructor & Destructor Documentation

eVaf::Common::Internal::Config::Config ( )
virtual eVaf::Common::Internal::Config::~Config ( )
virtual

Member Function Documentation

iConfig* eVaf::Common::Internal::Config::_interface ( ) const

Returns the current implementation of the iConfig interface.

void eVaf::Common::Internal::Config::done ( )

Finalizes the iConfig interface implementation.

virtual QVariant eVaf::Common::Internal::Config::getValue ( QString const &  paramName,
QVariant const &  defaultValue 
) const
virtual

Reads a configuration parameter value.

Parameters
paramNameName of the parameter
defaultValueDefault value
Returns
The parameter value or the default value if the parameter cannot be found

The getValue() method returns a configuration parameter value identified by the parameter name. If the parameter cannot be read or is not found, returns the default value.

The default value is used to determine the type of the value. For example, if the default value is an integer, then the returned value is also an integer. The default iConfig interface implementation validates parameter values and makes sure that the parameter value is of the proper type. If the value cannot be converted to the proper type, returns the default value. Other implementations of the iConfig interface are encouraged to do the same.

Implements eVaf::Common::iConfig.

bool eVaf::Common::Internal::Config::init ( )

Initializes the iConfig interface implementation.

Returns
True if succeeded; false if not
virtual bool eVaf::Common::Internal::Config::setValue ( QString const &  paramName,
QVariant const &  value,
bool  commit 
)
virtual

Writes a configuration parameter value.

Parameters
paramNameName of the parameter
valueThe parameter value
commitIf true, then commits new parameter values
Returns
True if succeeded; false if not

The setValue() method writes new configuration parameter values identified by the parameter name.

The commit argument can be used to improve the performance of writing several parameter values at once. Use commit = false for all except the last parameter's write operation.

conf->setValue("/main/param1", 1, false);
conf->setValue("/main/param2", 2, false);
conf->setValue("/main/param3", 3); // Last parameter in the block

Implements eVaf::Common::iConfig.


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