Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

CConfigurationManager Class Reference

#include <CConfigurationManager.h>

List of all members.

Public Member Functions

 CConfigurationManager ()
 Default construtor.
 CConfigurationManager (STD(list)< CTypeFreeBinding * > &rBindings)
 Prestocked configuration.
 ~CConfigurationManager ()
 Destruction requires nothing special.
 CConfigurationManager (const CConfigurationManager &rhs)
 Copy constructor.
CConfigurationManageroperator= (const CConfigurationManager &rhs)
 Assignment operator.
int operator== (const CConfigurationManager &rhs)
int operator!= (const CConfigurationManager &rhs)
 STD (list)< CTypeFreeBinding * > getBindings() const
void setBindings (STD(list)< CTypeFreeBinding * > newBindings)
 Replace all bindings.
void AddBinding (CTypeFreeBinding &rBinding)
void AddBinding (STD(list)< CTypeFreeBinding * > addlist)
void ReadConfigFile (const char *pName)
void ReadConfigFile (const STD(string)&rName)
void ReadConfigFile (int fd)
void Read1stConfigFile (const STD(vector)< STD(string)> &Names)
void Read1stConfigFile (const STD(vector)< STD(string)> &Paths, const char *pName)
void Read1stConfigFile (const STD(vector)< STD(string)> &Paths, const STD(string)&rName)
void ReadAllConfigFiles (const STD(vector)< STD(string)> &Name)
void ReadAllConfigFiles (const STD(vector)< STD(string)> &Paths, const char *pName)
void ReadAllConfigFiles (const STD(vector)< STD(string)> &Paths, const STD(string)&rName)
void WriteConfigFile (const char *pName)
void WriteConfigFile (const STD(string)&rName)
void WriteConfigFile (int fd)

Protected Member Functions

void InternalReadConfigFile (CTCLInterpreter &rInterp, int fd)

Private Member Functions

 STD (list)< CTypeFreeBinding * > m_lBindings
 List of configuration bindings.


Detailed Description

ConfigurationManager provides a flexible scheme for configuring various application parameters. The idea is that a script or set of scripts will hold configuration information (variable sets e.g.). These configuration scripts are linked to application variables via instances of subclasses of CBinding. The configuration manager is asked to read a set of configuration files, it instantiates a TCLInterpreter with which to interpret the files. Folowing this, the application has its configuration variable set as a result of this script exeuction and the set of defined bindings between TCL variables and application variables.

The following bindings are supported:

All of the bindings types are templated types. However due to TCL restrictions, only some type parameterizations are allowed:

All of these type parameterizations are straightforward with the exception of char* char* variables are filled in with pointers to malloc'd copies of the contents of the variable after configuration is done. In practice this is only an issue if multiple configurations reads members are performed (e.g. reconfiguration after complete configuration).

The major member functions supported by this class are:

Definition at line 357 of file CConfigurationManager.h.


Constructor & Destructor Documentation

CConfigurationManager::CConfigurationManager  )  [inline]
 

Default construtor.

Definition at line 365 of file CConfigurationManager.h.

CConfigurationManager::CConfigurationManager STD(list)< CTypeFreeBinding * > &  rBindings  )  [inline]
 

Prestocked configuration.

Definition at line 366 of file CConfigurationManager.h.

CConfigurationManager::~CConfigurationManager  )  [inline]
 

Destruction requires nothing special.

Definition at line 368 of file CConfigurationManager.h.

CConfigurationManager::CConfigurationManager const CConfigurationManager rhs  )  [inline]
 

Copy constructor.

Definition at line 374 of file CConfigurationManager.h.


Member Function Documentation

void CConfigurationManager::AddBinding STD(list)< CTypeFreeBinding * >  addlist  )  [inline]
 

Parameters:
addlist  Append list of bindings

Definition at line 401 of file CConfigurationManager.h.

void CConfigurationManager::AddBinding CTypeFreeBinding rBinding  )  [inline]
 

< Append to list of bindings

Definition at line 398 of file CConfigurationManager.h.

void CConfigurationManager::InternalReadConfigFile CTCLInterpreter &  rInterp,
int  fd
[protected]
 

Internal function to read a configuration file and execute it. since the lowest common denominator is a file descriptor and Tcl/Tk doesn't have a function to process a script given an fd, we'll read the entire file into a buffer and process the file from that string. In practice, configuration files will not be too large so this will not be a serious problem.

Parameters:
rInterp - Tcl Interpreter which will interpret the file.
fd - File descriptor already open on the file.
Exceptions:
CTCLException - if the script does not parse properly etc.
CErrnoException - if unable to determine file size.
Note:
It is the caller's responsibility to close the file.

Definition at line 682 of file CConfigurationManager.cpp.

Referenced by ReadConfigFile().

int CConfigurationManager::operator!= const CConfigurationManager rhs  )  [inline]
 

< Inequality compare

Definition at line 382 of file CConfigurationManager.h.

CConfigurationManager& CConfigurationManager::operator= const CConfigurationManager rhs  )  [inline]
 

Assignment operator.

Definition at line 376 of file CConfigurationManager.h.

int CConfigurationManager::operator== const CConfigurationManager rhs  )  [inline]
 

< Equality compare

Definition at line 379 of file CConfigurationManager.h.

void CConfigurationManager::Read1stConfigFile const STD(vector)< STD(string)> &  Paths,
const STD(string)&  rName
 

void CConfigurationManager::Read1stConfigFile const STD(vector)< STD(string)> &  Paths,
const char *  pName
 

void CConfigurationManager::Read1stConfigFile const STD(vector)< STD(string)> &  Names  ) 
 

void CConfigurationManager::ReadAllConfigFiles const STD(vector)< STD(string)> &  Paths,
const STD(string)&  rName
 

void CConfigurationManager::ReadAllConfigFiles const STD(vector)< STD(string)> &  Paths,
const char *  pName
 

void CConfigurationManager::ReadAllConfigFiles const STD(vector)< STD(string)> &  Name  ) 
 

void CConfigurationManager::ReadConfigFile int  fd  ) 
 

Reads a configuration file given that it is open on a file descriptor. The file is interpreted from its current location until end of file.

Parameters:
fd - File descriptor open on the file.
Exceptions:
CTCLException - if there was a problem interpreting the script e.g.

Definition at line 403 of file CConfigurationManager.cpp.

References InternalReadConfigFile().

void CConfigurationManager::ReadConfigFile const STD(string)&  rName  ) 
 

void CConfigurationManager::ReadConfigFile const char *  pName  ) 
 

Reads a single configuration file. This involves:

  1. Ensuring the file exists.
  2. Creating a CTCLInterpreter on which to interpret the config file.
  3. Initializing all bindings on the interpreter.
  4. Interpreting the script file.
  5. Committing all bindings on the interpreter.
  6. Shutting down all bindings on the interpreter.
  7. Destroying the CTCLIntpereter.

Parameters:
pName - Pointer to the name of the file to read. This must be fully specified (absolute or relative path).
Exceptions:
CErrnoException - if e.g. file cannot be opened for read.
CTCLException - if there was a problem (e.g. syntax error) interpreting the configuration script.

Definition at line 368 of file CConfigurationManager.cpp.

void CConfigurationManager::setBindings STD(list)< CTypeFreeBinding * >  newBindings  )  [inline]
 

Replace all bindings.

Definition at line 395 of file CConfigurationManager.h.

CConfigurationManager::STD list   )  const [inline]
 

< Get a copy of bindings.

Definition at line 388 of file CConfigurationManager.h.

CConfigurationManager::STD list   )  [private]
 

List of configuration bindings.

void CConfigurationManager::WriteConfigFile int  fd  ) 
 

Writes a configuration file which can be re-read to duplicate the current state of the configuration variables. The configuration file will contain a comment which will give the following information:

  • Identifying information to indicate that this is a configuration file written by the configuration subsystem. - When written
  • Name of user executing this program.

Parameters:
fd - File descriptor of file open on the output configuration file.
Exceptions:
CErrnoException - If there are problems writing to the file.
Note:
It is the caller's responsibilility to close the file.

Definition at line 605 of file CConfigurationManager.cpp.

void CConfigurationManager::WriteConfigFile const STD(string)&  rName  ) 
 

void CConfigurationManager::WriteConfigFile const char *  pName  ) 
 

Writes a configuraiton file which can be re-read to duplicate the current configuration. The file is specified by a null terminated array of characters (C-string). This function attempts to open the specified file for write and on success delegates the actual write operation to the previous overload of this function.

Parameters:
pName - Pointer to the filename as a C-string.

Definition at line 645 of file CConfigurationManager.cpp.


The documentation for this class was generated from the following files:
Generated on Thu Jan 6 16:58:43 2005 for Spectrodaq External Event Framework by  doxygen 1.3.9.1