60#pragma warning ( disable : 4355 )
67:
TNamed(
"Configurable",
"Configurable"),
68 fOptions ( theOption ),
69 fLooseOptionCheckingEnabled (
kTRUE ),
70 fLastDeclaredOption ( 0 ),
71 fConfigDescription (
"No description" ),
72 fReferenceFile (
"None" ),
96 while (splitOpt.
Length()>0) {
104 splitOpt = splitOpt(splitOpt.
First(
':')+1,splitOpt.
Length());
126 Log() << kVERBOSE <<
"Parsing option string: " <<
Endl;
127 TString optionsWithoutTilde(fOptions);
129 Log() << kVERBOSE <<
"... \"" << optionsWithoutTilde <<
"\"" <<
Endl;
136 SplitOptions(fOptions, loo);
140 std::map<TString, std::vector<std::pair<Int_t, TString> > > arrayTypeOptions;
169 if (decOpt==0 && optname.
Contains(
'[')) {
174 std::stringstream str(st.
Data());
183 Log() << kWARNING <<
"Value for option " << decOpt->
GetName()
184 <<
" was previously set to " << decOpt->
GetValue() <<
Endl;
195 Log() << kFATAL <<
"Index " << idx <<
" too large for option " << decOpt->
TheName()
201 Log() << kFATAL <<
"Option " << decOpt->
TheName()
202 <<
" is not an array, but you specified an index" <<
Endl;
207 else Log() << kFATAL <<
"Option " << decOpt->
TheName()
208 <<
" does not have predefined value: \"" << optval <<
"\"" <<
Endl;
225 if (predOptName == optname) optionExists =
kTRUE;
227 if (predOptName == optname)
break;
232 decOpt->
SetValue( hasNotSign ?
"0" :
"1" );
236 if (optionExists && hasNotSign) {
237 Log() << kFATAL <<
"Negating a non-boolean variable " << optname
238 <<
", please check the options for method: " << GetName() <<
Endl;
244 if (!paramParsed && LooseOptionCheckingEnabled()) {
249 if (decOpt->HasPreDefinedVal() && decOpt->IsPreDefinedVal(s) ) {
250 paramParsed = decOpt->SetValue(s);
256 if (fOptions!=
"") fOptions +=
":";
257 if (paramParsed || preserveTilde) fOptions +=
'~';
258 if (preserveNotSign) fOptions +=
'!';
264 if (
gConfig().WriteOptionsReference()) WriteOptionsReferenceToFile();
277 SplitOptions(theOpt, loo);
285 if (unusedOptions !=
"") unusedOptions +=
':';
289 if (unusedOptions !=
"") {
291 <<
"The following options were specified, but could not be interpreted: \'"
292 << unusedOptions <<
"\', please check!" <<
Endl;
301 Log() << kVERBOSE <<
"The following options are set:" <<
Endl;
304 Log() << kVERBOSE <<
"- By User:" <<
Endl;
308 Log() << kVERBOSE <<
" ";
309 std::ostringstream oss;
314 if (!found) Log() << kVERBOSE <<
" <none>" <<
Endl;
317 Log() << kVERBOSE <<
"- Default:" <<
Endl;
321 Log() << kVERBOSE <<
" ";
322 std::ostringstream oss;
327 if (!found) Log() << kVERBOSE <<
" <none>" <<
Endl;
336 o << prefix <<
"# Set by User:" << std::endl;
338 if (opt->IsSet()) { o << prefix; opt->Print(o); o << std::endl; }
340 o << prefix <<
"# Default:" << std::endl;
342 if (!opt->IsSet()) { o << prefix; opt->Print(o); o << std::endl; }
343 o << prefix <<
"##" << std::endl;
356 if (opt->IsArrayOpt()) {
357 std::stringstream s(
"");
359 for(
Int_t i=0; i<opt->GetArraySize(); i++) {
361 s << std::scientific << opt->GetValue(i);
369 if (opt->IsArrayOpt()) {
372 gTools().
AddAttr(optnode,
"modified", (opt->IsSet()?
"Yes":
"No") );
384 if (fOptions.Length()!=0) fOptions +=
":";
387 std::stringstream s(
"");
389 if (
gTools().HasAttr(opt,
"size")) {
395 s << std::scientific << optName <<
"[" << i <<
"]=" << values[i];
399 s << std::scientific << optName <<
"=" << optValue;
401 fOptions += s.str().c_str();
413 fReferenceFile = dir +
"/" + GetConfigName() +
"_optionsRef.txt";
414 std::ofstream o( fReferenceFile );
416 Log() << kFATAL <<
"<WriteOptionsToInfoFile> Unable to open output file: " << fReferenceFile <<
Endl;
420 o <<
"# List of options:" << std::endl;
421 o <<
"# Configurable: " << GetConfigName() << std::endl;
422 o <<
"# Description: " << GetConfigDescription() << std::endl;
425 o << std::endl <<
"# ------------------------------------------------" << std::endl;
429 Log() << kVERBOSE <<
"Wrote options reference file: \"" << fReferenceFile <<
"\"" <<
Endl;
443 istr.getline(buf,512);
445 while (istr.good() && !istr.eof() && !(buf[0]==
'#' && buf[1]==
'#')) {
447 while (*
p==
' ' || *
p==
'\t')
p++;
448 if (*
p==
'#' || *
p==
'\0') {
449 istr.getline(buf,512);
452 std::stringstream sstr(buf);
453 sstr >> stropt >> strval;
456 if (fOptions.Length()!=0) fOptions +=
":";
459 istr.getline(buf,512);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
winID h TVirtualViewer3D TVirtualGLPainter p
R__EXTERN TSystem * gSystem
virtual void SetOwner(Bool_t enable=kTRUE)
Set whether this collection is the owner (enable==true) of its content.
void Reset() override
Reset list iterator.
void Add(TObject *obj) override
TString fOptionsReferenceFileDir
void ReadOptionsFromXML(void *node)
void ResetSetFlag()
resets the IsSet flag for all declare options to be called before options are read from stream
virtual ~Configurable()
default destructor
void WriteOptionsReferenceToFile()
write complete options to output stream
void WriteOptionsToStream(std::ostream &o, const TString &prefix) const
write options to output stream (e.g. in writing the MVA weight files
Configurable(const TString &theOption="")
constructor
TList fListOfOptions
option list
virtual void ParseOptions()
options parser
void PrintOptions() const
prints out the options set in the options string and the defaults
void CheckForUnusedOptions() const
checks for unused options in option string
void SplitOptions(const TString &theOpt, TList &loo) const
splits the option string at ':' and fills the list 'loo' with the primitive strings
void ReadOptionsFromStream(std::istream &istr)
read option back from the weight file
void AddOptionsXMLTo(void *parent) const
write options to XML file
ostringstream derivative to redirect and format output
void SetMinType(EMsgType minType)
Class for TMVA-option handling.
virtual const char * TheName() const
virtual Bool_t SetValue(const TString &vs, Int_t i=-1)
set value for option
virtual Bool_t IsPreDefinedVal(const TString &) const =0
virtual Bool_t IsArrayOpt() const =0
virtual Bool_t HasPreDefinedVal() const =0
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetArraySize() const =0
virtual TString GetValue(Int_t i=-1) const =0
The TNamed class is the base class for all named ROOT classes.
Collectable string class.
virtual TObject * FindObject(const char *name) const
Must be redefined in derived classes.
void ToLower()
Change string to lower-case.
TSubString Strip(EStripType s=kTrailing, char c=' ') const
Return a substring of self stripped at beginning and/or end.
Ssiz_t First(char c) const
Find first occurrence of a character c.
const char * Data() const
TString & ReplaceAll(const TString &s1, const TString &s2)
Bool_t BeginsWith(const char *s, ECaseCompare cmp=kExact) const
TString & Remove(Ssiz_t pos)
Bool_t Contains(const char *pat, ECaseCompare cmp=kExact) const
virtual int MakeDirectory(const char *name)
Make a directory.
MsgLogger & Endl(MsgLogger &ml)