26 #ifndef ADF_ConfigurationFrame
39 fHeaderDef(
'#',false,
"ADF::DotConf",
""),
40 fHeader(-1,-1,
"Init"),
46 if (fComment.size() > 0)
47 if ( fComment.at(fComment.length()-1) ==
'\n' )
48 fComment.erase(fComment.size()-1);
55 fHeaderDef(
'#',is_record,rid,srid),
56 fHeader(-1,-1,
"Init"),
62 if (fComment.size() > 0)
63 if ( fComment.at(fComment.length()-1) ==
'\n' )
64 fComment.erase(fComment.size()-1);
95 std::string bor(&fHeaderDef.fSkipLine,1); bor +=
"////"; bor += fHeaderDef.fRID; bor +=
"_beg////";
101 std::string eor(&fHeaderDef.fSkipLine,1); eor +=
"////"; eor += fHeaderDef.fRID; eor +=
"_end////";
107 time_t thetime; ::time(&thetime); fLastModif = ::ctime(&thetime);
110 if (fLastModif.size() > 0)
111 if ( fLastModif.at(fLastModif.length()-1) ==
'\n' )
112 fLastModif.erase(fLastModif.size()-1);
122 std::string bor =
BeginOfRecord(),
tmp, tmp_srid, tmp_option; Short_t version;
125 if ( st.find(bor) == 0 ) {
127 tmp = st.substr(bor.length()+1);
132 if (
tmp.find(fHeaderDef.fSRID) == string::npos ) {
138 istringstream in(
tmp );
144 for (
size_t i = 0; i <
tmp.size(); i++) {
145 if (
tmp[i] ==
' ' && aval )
147 if (
tmp[i] !=
' ' && aval ==
false ) {
159 if ( fHeaderDef.fSRID ==
"" ) {
160 in >> version >> tmp_option;
163 in >> tmp_srid >> tmp_option;
167 in >> tmp_srid >> version >> tmp_option;
174 if ( tmp_option.find(
"Init") != string::npos ) {
181 fHeader.fPreviousVersion = fHeader.fVersion; fHeader.fVersion = version; fHeader.fStreamOption = tmp_option;
192 if ( st.find(eor) == 0 )
201 if ( !fHeaderDef.fWithRecord )
213 out <<
"# Last modified by : " <<
GetLastModif() <<
" \n";
214 out <<
"# Modified by : " <<
GetComment() <<
" \n";
224 fListOfDotConf.push_back(aconf);
230 string tmp; Bool_t is_a_record =
false, do_process =
false, ok_decode =
true;
236 if ( !fHeaderDef.fWithRecord )
237 is_a_record = do_process =
true;
242 while ( in.good() && !in.eof() ) {
243 if ( tmp[0] == fHeaderDef.fSkipLine ) {
245 if ( fHeaderDef.fWithRecord ) {
248 do_process = is_a_record =
true;
270 std::list< DotConf * >::iterator
272 for ( listed_item = fListOfDotConf.begin() ; listed_item != fListOfDotConf.end() ; listed_item++ ) {
274 in.seekg (0, ios::beg);
275 ok_decode = ok_decode && (*listed_item)->DoConfigure(in, allow_init);
287 Bool_t ok_decode =
true;
302 std::list< DotConf * >::iterator
304 for ( listed_item = fListOfDotConf.begin() ; listed_item != fListOfDotConf.end() ; listed_item++ ) {
305 ok_decode = ok_decode && (*listed_item)->DoConfigure(out);
316 Bool_t ok; std::string opt = option;
318 std::ifstream filein(name);
319 if ( filein.is_open() == true ) {
323 fLog <<
error <<
"Cannot open file (read mode) " << name <<
nline;
329 std::ofstream fileout(name);
330 if ( fileout.is_open() == true ) {
334 fLog <<
error <<
" Cannot open file (writting mode) " << name <<
nline;
348 Bool_t ok; std::string opt = option;
354 std::istringstream in;
356 in.str((frame->
String()));
363 std::ostringstream out;
366 frame->
String() = out.str();
DotConf : Utility for class configuration from ascii file or Configuration frames.
const Char_t * GetComment() const
std::string BeginOfRecord()
string that gives a start of record for this object
virtual Short_t GetVersion() const
to get the curent version of this object
virtual const Char_t * GetSRID() const
to get the record id
void SetLastModif()
set in last modif string the current date.
A configuration frame is just an encapsulation of a string.
Bool_t IsEndOfRecord(const std::string &)
Return true if this string is an end of record.
LogMessage & error(LogMessage &)
virtual void Reset(const Char_t *opt="")
Reset : all values are set to default.
std::string EndOfRecord()
string that gives an end of record for this object
virtual UInt_t Read()
It reads the content of the string from the Frame.
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 ...
virtual UInt_t Write()
It writes to the Frame the content of the string.
const Char_t * GetLastModif() const
virtual void SetProcessMethod(const char *)
To set the current method.
LogMessage & nline(LogMessage &)
LogMessage fLog
the log messenger ... to know the object hae been properly intitialised/modified
virtual Bool_t DoConfigure(std::istream &, Bool_t allow_init)
configure this from an input stream
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.
header file for DotConf.cpp
virtual Bool_t ProcessLine(const std::string &)
a helper template to do clones : it requires a default constructor. then it uses the Configure facili...
virtual const Char_t * GetStreamOption() const
get/set option
virtual void AddConf(DotConf *)
add a conf object to this. The added objects are not owned by this so not deleted.
LogMessage & dolog(LogMessage &)
Bool_t AddRecord(std::ostream &, char t= 'b')
Add a begin or end of record, return true if done.