OBT::AbstractConfigurationFileParser Class Reference

Abstract class for configuration file parsers. More...

#include <OBTAbstractConfigurationFileParser.h>

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

List of all members.

Public Member Functions

virtual ~AbstractConfigurationFileParser ()
 destructor

Protected Member Functions

 AbstractConfigurationFileParser (const char *fileName, ConfigurationItem &configurationItem=touchRoot())
 constructor
const char * getBuffer () const
 Get accessor to the file buffer.
unsigned long getBufferSize () const
 Get accessor to the file buffer size.

Static Protected Member Functions

static ConfigurationItemtouchChild (ConfigurationItem &configurationItem, unsigned int childNumber)
 allows the descendants of AbstractConfigurationFileParser to access the protected getChild method of ConfigurationItem
static ConfigurationItemtouchRoot ()
 allows the descendants of AbstractConfigurationFileParser to access the protected touchRoot method of ConfigurationParameters

Private Member Functions

 AbstractConfigurationFileParser (const AbstractConfigurationFileParser &fileParser)
 copy constructor
const
AbstractConfigurationFileParser
operator= (const AbstractConfigurationFileParser &fileParser)
 assignment operator

Private Attributes

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

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         }

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

assignment operator

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 }


Member Data Documentation

file buffer

Definition at line 81 of file OBTAbstractConfigurationFileParser.h.

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

subroot of the configurationParameters tree to populate

Definition at line 78 of file OBTAbstractConfigurationFileParser.h.


Generated on 1 Jan 2010 for OBT by  doxygen 1.6.1