/*
* A class which handles persistance of configuration information
*
* Copyright (C) Michael Still 2002
* Copyright (C) Blake Swadling 2002
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
/******************************************************************************
DOCBOOK START
FUNCTION
cepConfiguration
PURPOSE
provides a persistance mechanism for configuration data
SYNOPSIS START
Since it is sensible to have cnfiguration stored centrally,
this config mechanism is implemented as a singleton. To use it
you need to to 2 things.
1) initialise the configuration database for a specific config file (optional)
2) get a reference to the configuration. If the configuration ahs not been initialised
then the default configuration file is used (currently ~/.cep)
for example this will initialise the config database to "testcfg" in the current working
directory and will get a reference to the central config object ...
cepConfiguration::initialise("testcfg");
cepConfiguration cfg = cepConfiguration::getInstance();
SYNOPSIS END
DESCRIPTION START
A configuration class (using the singleton pattern) which allows
access to a single configuration store.
static void initialise( const string &path )
initialises the configuration database usng the specifed file. if the file
cannot be accessed then an attempt is made to initialise the default path.
this is static and must be called like so ..
cepConfiguration::initialise( mypath );
static cepConfiguration::getInstance()
Gets a reference to the current configuration object.
this is a static an must be called like so ...
cepConfiguration cfg = cepConfiguration::getInstance();
void getVal( const string &key, const string &default, const string &value )
gets a string value by key. if the value does not exist then the default is returned
void getVal( const string &key, int default, int value )
gets an int value by key. if the value does not exist then the default is returned
void getVal( const string &key, bool default, bool value )
gets a boolean value by key. if the value does not exist then the default is returned
void getVal( const string &key, const string &value )
places a string value into configuration using the key for id. If the value exists it
is overwritten
void getVal( const string &key, int value )
places an int value into configuration using the key for id. If the value exists it
is overwritten
void getVal( const string &key, bool value )
places a boolean value into configuration using the key for id. If the value exists it
is overwritten
DESCRIPTION END
DOCBOOK END
******************************************************************************/
#ifndef CEP_CONFIGURATION_H
#define CEP_CONFIGURATION_H
#include