DotConf : Utility for class configuration from ascii file or Configuration frames. More...
#include <DotConf.h>
Public Member Functions | |
virtual void | AddConf (DotConf *) |
add a conf object to this. The added objects are not owned by this so not deleted. More... | |
virtual Bool_t | Configure (ConfigurationFrame *, const char *option="in", Bool_t allow_init=false) |
configuration from/to a configuration frame : extact string from the frame and call DoConfigure More... | |
virtual Bool_t | Configure (const char *name, const char *option="in", Bool_t allow_init=true) |
configuration from/to a file : open the file and call DoConfigure More... | |
virtual Bool_t | DoConfigure (std::istream &, Bool_t allow_init) |
configure this from an input stream More... | |
virtual Bool_t | DoConfigure (std::ostream &) |
write the configuration in an output stream More... | |
DotConf () | |
DotConf (const Char_t *rid, const Char_t *srid="", Bool_t is_record=true) | |
const Char_t * | GetComment () const |
const Char_t * | GetLastModif () const |
Short_t | GetMaxVersion () const |
this class could managed moddification of the versionned part up to MaxVersion : should be set in the constructor part of the inheriting class More... | |
virtual const Char_t * | GetRID () const |
to get the record id More... | |
virtual const Char_t * | GetSRID () const |
to get the record id More... | |
virtual const Char_t * | GetStreamOption () const |
get/set option More... | |
virtual Short_t | GetVersion () const |
to get the curent version of this object More... | |
Bool_t | IsWithRecord () const |
to know if this is intialisased with a stream composed of records. More... | |
virtual void | RemoveConf (DotConf *aconf=0x0) |
virtual void | Reset (const Char_t *opt="") |
Reset : all values are set to default. More... | |
void | SetComment (const Char_t *comment) |
virtual void | SetRID (const Char_t *rid, const Char_t *srid="") |
to set the record id More... | |
virtual void | SetStreamOption (const Char_t *opt) |
void | SetWithRecord (Bool_t is_record=true) |
to change the behavior More... | |
virtual | ~DotConf () |
Protected Member Functions | |
Bool_t | AddRecord (std::ostream &, char t= 'b') |
Add a begin or end of record, return true if done. More... | |
std::string | BeginOfRecord () |
string that gives a start of record for this object More... | |
std::string | EndOfRecord () |
string that gives an end of record for this object More... | |
Bool_t | IsBeginOfRecord (const std::string &, Bool_t allow_init) |
Return true if this string is a begin of record and call Reset if Init is found. More... | |
Bool_t | IsEndOfRecord (const std::string &) |
Return true if this string is an end of record. More... | |
virtual Bool_t | ProcessLine (const std::string &) |
a helper template to do clones : it requires a default constructor. then it uses the Configure facilities to configure the new object More... | |
void | SetLastModif () |
set in last modif string the current date. More... | |
void | SetMaxVersion (Short_t v) |
void | SetVersion (Short_t v) |
Protected Attributes | |
LogMessage | fLog |
the log messenger ... to know the object hae been properly intitialised/modified More... | |
DotConf : Utility for class configuration from ascii file or Configuration frames.
An object that inherits from this class could be intialised/modified using a simple ascii file. This file could be embedded inside a configuration Frame.
The file/frame may be composed of records that start/end with a particular string. In this case IsWithRecord is true and the BeginOfRecord and EndOfRecord look like this :
#////ADF::ConfAgent_beg//// Agata 0 Init ... #////ADF::ConfAgent_end////
with :
In principle a configuration frame should not Init completely the data members of the class that inherits from DotConf. So if you design your class using this base class, think of the data members as belonging to two categories. The first one are changeable (or 'permanent') data members i.e., @ any time, a conf frame (or a conf file) could come with only a modification of one data member or to add some more info : Make sure this action is well managed by your reading (see for instance ProcessLine)
The second one groups data members that cannot be changed : this could be a path to some directory. In such case such informations in the conf frame would cause errors since the path written is related to the system on which the data has been produced and is most likely not adapted to yours !
By default Configure(ConfigurationFrame *, const char *option = "in", Bool_t allow_init = false); is protected so that it is impossible to read a configuration frame in Init mode. It may not suit your wishes. In such case, you should set the last argument of the method, allow_init, to true.
The methods :
do the work to read/write the stream used to initialise/change the data member of this object.
could be use as it is ... it just reads the stream line by line and calls the ProcessLine method which could be overwritten. the methods:
just call after some processing
In reading mode, false means an attempt to read something expected has rised an error. Otherwise if the record is not there or reading is ok, it returns true.