63 #pragma warning ( disable : 4355 )
70 : fOptions ( theOption ),
71 fLooseOptionCheckingEnabled (
kTRUE ),
72 fLastDeclaredOption ( 0 ),
73 fConfigName (
"Configurable" ),
74 fConfigDescription (
"No description" ),
75 fReferenceFile (
"None" ),
76 fLogger ( new MsgLogger(this) )
78 fListOfOptions.SetOwner();
99 while (splitOpt.
Length()>0) {
107 splitOpt = splitOpt(splitOpt.
First(
':')+1,splitOpt.
Length());
130 TString optionsWithoutTilde(fOptions);
139 SplitOptions(fOptions, loo);
143 std::map<TString, std::vector<std::pair<Int_t, TString> > > arrayTypeOptions;
172 if (decOpt==0 && optname.
Contains(
'[')) {
177 std::stringstream str(st.
Data());
187 <<
" was previously set to " << decOpt->
GetValue() <<
Endl;
198 Log() <<
kFATAL <<
"Index " << idx <<
" too large for option " << decOpt->
TheName()
205 <<
" is not an array, but you specified an index" <<
Endl;
211 <<
" does not have predefined value: \"" << optval <<
"\"" <<
Endl;
228 if (predOptName == optname) optionExists =
kTRUE;
230 if (predOptName == optname)
break;
235 decOpt->
SetValue( hasNotSign ?
"0" :
"1" );
239 if (optionExists && hasNotSign) {
240 Log() <<
kFATAL <<
"Negating a non-boolean variable " << optname
241 <<
", please check the opions for method: " << GetName() <<
Endl;
247 if (!paramParsed && LooseOptionCheckingEnabled()) {
252 if (decOpt->HasPreDefinedVal() && decOpt->IsPreDefinedVal(s) ) {
253 paramParsed = decOpt->SetValue(s);
259 if (fOptions!=
"") fOptions +=
":";
260 if (paramParsed || preserveTilde) fOptions +=
'~';
261 if (preserveNotSign) fOptions +=
'!';
267 if (
gConfig().WriteOptionsReference()) WriteOptionsReferenceToFile();
280 SplitOptions(theOpt, loo);
288 if (unusedOptions !=
"") unusedOptions +=
':';
292 if (unusedOptions !=
"") {
294 <<
"The following options were specified, but could not be interpreted: \'"
295 << unusedOptions <<
"\', please check!" <<
Endl;
329 o << prefix <<
"# Set by User:" << std::endl;
331 if (opt->IsSet()) { o << prefix; opt->Print(o); o << std::endl; }
333 o << prefix <<
"# Default:" << std::endl;
335 if (!opt->IsSet()) { o << prefix; opt->Print(o); o << std::endl; }
336 o << prefix <<
"##" << std::endl;
349 if (opt->IsArrayOpt()) {
350 std::stringstream s(
"");
352 for(
Int_t i=0; i<opt->GetArraySize(); i++) {
354 s << std::scientific << opt->GetValue(i);
362 if (opt->IsArrayOpt()) {
365 gTools().
AddAttr(optnode,
"modified", (opt->IsSet()?
"Yes":
"No") );
377 if (fOptions.Length()!=0) fOptions +=
":";
380 std::stringstream s(
"");
382 if (
gTools().HasAttr(opt,
"size")) {
386 for(
UInt_t i=0; i<size; i++) {
388 s << std::scientific << optName <<
"[" << i <<
"]=" << values[i];
392 s << std::scientific << optName <<
"=" << optValue;
394 fOptions += s.str().c_str();
406 fReferenceFile = dir +
"/" + GetConfigName() +
"_optionsRef.txt";
407 std::ofstream o( fReferenceFile );
409 Log() <<
kFATAL <<
"<WriteOptionsToInfoFile> Unable to open output file: " << fReferenceFile <<
Endl;
413 o <<
"# List of options:" << std::endl;
414 o <<
"# Configurable: " << GetConfigName() << std::endl;
415 o <<
"# Description: " << GetConfigDescription() << std::endl;
418 o << std::endl <<
"# ------------------------------------------------" << std::endl;
422 Log() <<
kVERBOSE <<
"Wrote options reference file: \"" << fReferenceFile <<
"\"" <<
Endl;
436 istr.getline(buf,512);
438 while (istr.good() && !istr.eof() && !(buf[0]==
'#' && buf[1]==
'#')) {
440 while (*p==
' ' || *p==
'\t') p++;
441 if (*p==
'#' || *p==
'\0') {
442 istr.getline(buf,512);
445 std::stringstream sstr(buf);
446 sstr >> stropt >> strval;
449 if (fOptions.Length()!=0) fOptions +=
":";
452 istr.getline(buf,512);
TString fOptionsReferenceFileDir
void AddOptionsXMLTo(void *parent) const
write options to XML file
MsgLogger & Endl(MsgLogger &ml)
void ReadOptionsFromXML(void *node)
Collectable string class.
void ReadOptionsFromStream(std::istream &istr)
read option back from the weight file
TString & ReplaceAll(const TString &s1, const TString &s2)
void CheckForUnusedOptions() const
checks for unused options in option string
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
virtual ~Configurable()
default destructur
virtual int MakeDirectory(const char *name)
Make a directory.
virtual Bool_t IsArrayOpt() const =0
void ToLower()
Change string to lower-case.
void SplitOptions(const TString &theOpt, TList &loo) const
splits the option string at ':' and fills the list 'loo' with the primitive strings ...
virtual TString GetValue(Int_t i=-1) const =0
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
void WriteOptionsToStream(std::ostream &o, const TString &prefix) const
write options to output stream (e.g. in writing the MVA weight files
const char * Data() const
virtual void ParseOptions()
options parser
virtual Bool_t SetValue(const TString &vs, Int_t i=-1)
set value for option
void PrintOptions() const
prints out the options set in the options string and the defaults
R__EXTERN TSystem * gSystem
virtual const char * TheName() const
void WriteOptionsReferenceToFile()
write complete options to output stream
TSubString Strip(EStripType s=kTrailing, char c= ' ') const
Return a substring of self stripped at beginning and/or end.
Configurable(const TString &theOption="")
virtual Bool_t HasPreDefinedVal() const =0
virtual Int_t GetArraySize() const =0
TString & Remove(Ssiz_t pos)
void ResetSetFlag()
resets the IsSet falg for all declare options to be called before options are read from stream ...
virtual Bool_t IsPreDefinedVal(const TString &) const =0
virtual void Add(TObject *obj)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
void Reset()
Reset list iterator.
ClassImp(TMVA::Configurable) TMVA
constructor
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
virtual const char * GetName() const
Returns name of object.
Ssiz_t First(char c) const
Find first occurrence of a character c.