OBT::AbstractConfigurationFileParser Class Reference

#include <OBTAbstractConfigurationFileParser.h>

Inheritance diagram for OBT::AbstractConfigurationFileParser:

Inheritance graph
[legend]
Collaboration diagram for OBT::AbstractConfigurationFileParser:

Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual ~AbstractConfigurationFileParser ()

Protected Member Functions

 AbstractConfigurationFileParser (const char *fileName, ConfigurationItem &configurationItem=touchRoot())
const char * getBuffer () const
unsigned long getBufferSize () const

Static Protected Member Functions

static
ConfigurationItem
touchChild (ConfigurationItem &configurationItem, unsigned int childNumber)
static
ConfigurationItem
touchRoot ()

Private Member Functions

 AbstractConfigurationFileParser (const AbstractConfigurationFileParser &fileParser)
const
AbstractConfigurationFileParser
operator= (const AbstractConfigurationFileParser &fileParser)

Private Attributes

std::string _buffer
 file buffer
ConfigurationItem_configurationItem
 subroot of the configurationParameters tree to populate


Detailed Description

Abstract class for configuration file parsers.

Author:
Michaël Rouillé <michael.rouille@gmail.com>
This class groups together common functionnalities for configuration file parsers, i.e. being able to use a file in order to fill a ConfigurationItems tree. This reduces the dependencies between an application and the configuration file format; currently, the only supported file format by OBT is XML, as handled by the XMLConfigurationFileParser. However, if another file format was to be chosen, we would only have to define a new class for this format.

Definition at line 23 of file OBTAbstractConfigurationFileParser.h.


Constructor & Destructor Documentation

AbstractConfigurationFileParser::~AbstractConfigurationFileParser (  )  [virtual]

destructor

Definition at line 39 of file OBTAbstractConfigurationFileParser.cpp.

00040 {
00041 }

AbstractConfigurationFileParser::AbstractConfigurationFileParser ( const char *  fileName,
ConfigurationItem configurationItem = touchRoot() 
) [protected]

constructor

Definition at line 12 of file OBTAbstractConfigurationFileParser.cpp.

References _buffer, and TRACE_ERROR.

00013 :
00014 _configurationItem( configurationItem ),
00015 _buffer()
00016 {
00017         if ( ( fileName == NULL ) || ( strlen( fileName ) == 0 ) )
00018         {
00019                 TRACE_ERROR( "filename missing" ) ;
00020         }
00021         else
00022         {
00023                 std::ifstream file( fileName ) ;
00024                 if ( file.is_open() )
00025                 {
00026                         getline( file, _buffer, static_cast<char>( file.eof() ) ) ;
00027                         file.close() ;
00028                 }
00029                 else
00030                 {
00031                         TRACE_ERROR( "Could not open file " << fileName ) ;
00032                 }
00033         }
00034 }

OBT::AbstractConfigurationFileParser::AbstractConfigurationFileParser ( const AbstractConfigurationFileParser fileParser  )  [private]

copy constructor


Member Function Documentation

const char * OBT::AbstractConfigurationFileParser::getBuffer (  )  const [inline, protected]

Get accessor to the file buffer

Returns:
a characters array containing the file buffer

Definition at line 88 of file OBTAbstractConfigurationFileParser.h.

References _buffer.

00089         {
00090                 return _buffer.c_str() ;
00091         }

unsigned long OBT::AbstractConfigurationFileParser::getBufferSize (  )  const [inline, protected]

Get accessor to the file buffer size

Returns:
the size of the characters array containing the file buffer

Definition at line 97 of file OBTAbstractConfigurationFileParser.h.

References _buffer.

00098         {
00099                 return static_cast<unsigned long>( _buffer.length() ) ;
00100         }

ConfigurationItem & AbstractConfigurationFileParser::touchChild ( ConfigurationItem configurationItem,
unsigned int  childNumber 
) [static, protected]

allows the descendants of AbstractConfigurationFileParser to access the protected getChild method of ConfigurationItem

Parameters:
configurationItem parent
childNumber number of the child to return
Returns:
a reference to the child childNumber

Definition at line 47 of file OBTAbstractConfigurationFileParser.cpp.

References OBT::ConfigurationItem::touchChild().

00048 {
00049         return configurationItem.touchChild( childNumber ) ;
00050 }

ConfigurationItem & AbstractConfigurationFileParser::touchRoot (  )  [static, protected]

allows the descendants of AbstractConfigurationFileParser to access the protected touchRoot method of ConfigurationParameters

Returns:
a reference to the ConfigurationParameters singleton root

Definition at line 56 of file OBTAbstractConfigurationFileParser.cpp.

00057 {
00058         return Singleton< ConfigurationTree >::getInstance().touchRoot() ;
00059 }

const AbstractConfigurationFileParser& OBT::AbstractConfigurationFileParser::operator= ( const AbstractConfigurationFileParser fileParser  )  [private]

assignment operator


Member Data Documentation

std::string OBT::AbstractConfigurationFileParser::_buffer [private]

file buffer

Definition at line 78 of file OBTAbstractConfigurationFileParser.h.

Referenced by AbstractConfigurationFileParser(), getBuffer(), and getBufferSize().

ConfigurationItem& OBT::AbstractConfigurationFileParser::_configurationItem [private]

subroot of the configurationParameters tree to populate

Definition at line 81 of file OBTAbstractConfigurationFileParser.h.


Generated on Wed Oct 1 11:34:18 2008 for OBT by  doxygen 1.5.3