59#pragma warning ( disable : 4355 )
66:
TNamed(
"Configurable",
"Configurable"),
77 if (
gTools().CheckForVerboseOption( theOption ))
Log().SetMinType( kVERBOSE );
95 while (splitOpt.
Length()>0) {
103 splitOpt = splitOpt(splitOpt.
First(
':')+1,splitOpt.
Length());
125 Log() << kVERBOSE <<
"Parsing option string: " <<
Endl;
128 Log() << kVERBOSE <<
"... \"" << optionsWithoutTilde <<
"\"" <<
Endl;
139 std::map<TString, std::vector<std::pair<Int_t, TString> > > arrayTypeOptions;
168 if (decOpt==0 && optname.
Contains(
'[')) {
173 std::stringstream str(st.
Data());
182 Log() << kWARNING <<
"Value for option " << decOpt->
GetName()
183 <<
" was previously set to " << decOpt->
GetValue() <<
Endl;
194 Log() << kFATAL <<
"Index " << idx <<
" too large for option " << decOpt->
TheName()
200 Log() << kFATAL <<
"Option " << decOpt->
TheName()
201 <<
" is not an array, but you specified an index" <<
Endl;
206 else Log() << kFATAL <<
"Option " << decOpt->
TheName()
207 <<
" does not have predefined value: \"" << optval <<
"\"" <<
Endl;
224 if (predOptName == optname) optionExists =
kTRUE;
226 if (predOptName == optname)
break;
231 decOpt->
SetValue( hasNotSign ?
"0" :
"1" );
235 if (optionExists && hasNotSign) {
236 Log() << kFATAL <<
"Negating a non-boolean variable " << optname
237 <<
", please check the options for method: " <<
GetName() <<
Endl;
248 if (decOpt->HasPreDefinedVal() && decOpt->IsPreDefinedVal(s) ) {
249 paramParsed = decOpt->SetValue(s);
256 if (paramParsed || preserveTilde)
fOptions +=
'~';
257 if (preserveNotSign)
fOptions +=
'!';
284 if (unusedOptions !=
"") unusedOptions +=
':';
288 if (unusedOptions !=
"") {
290 <<
"The following options were specified, but could not be interpreted: \'"
291 << unusedOptions <<
"\', please check!" <<
Endl;
300 Log() << kVERBOSE <<
"The following options are set:" <<
Endl;
303 Log() << kVERBOSE <<
"- By User:" <<
Endl;
307 Log() << kVERBOSE <<
" ";
308 std::ostringstream oss;
313 if (!found)
Log() << kVERBOSE <<
" <none>" <<
Endl;
316 Log() << kVERBOSE <<
"- Default:" <<
Endl;
320 Log() << kVERBOSE <<
" ";
321 std::ostringstream oss;
326 if (!found)
Log() << kVERBOSE <<
" <none>" <<
Endl;
335 o << prefix <<
"# Set by User:" << std::endl;
337 if (opt->IsSet()) { o << prefix; opt->Print(o); o << std::endl; }
339 o << prefix <<
"# Default:" << std::endl;
341 if (!opt->IsSet()) { o << prefix; opt->Print(o); o << std::endl; }
342 o << prefix <<
"##" << std::endl;
355 if (opt->IsArrayOpt()) {
356 std::stringstream s(
"");
358 for(
Int_t i=0; i<opt->GetArraySize(); i++) {
360 s << std::scientific << opt->GetValue(i);
368 if (opt->IsArrayOpt()) {
371 gTools().
AddAttr(optnode,
"modified", (opt->IsSet()?
"Yes":
"No") );
386 std::stringstream s(
"");
388 if (
gTools().HasAttr(opt,
"size")) {
394 s << std::scientific << optName <<
"[" << i <<
"]=" << values[i];
398 s << std::scientific << optName <<
"=" << optValue;
415 Log() << kFATAL <<
"<WriteOptionsToInfoFile> Unable to open output file: " <<
fReferenceFile <<
Endl;
419 o <<
"# List of options:" << std::endl;
424 o << std::endl <<
"# ------------------------------------------------" << std::endl;
442 istr.getline(buf,512);
444 while (istr.good() && !istr.eof() && !(buf[0]==
'#' && buf[1]==
'#')) {
446 while (*p==
' ' || *p==
'\t') p++;
447 if (*p==
'#' || *p==
'\0') {
448 istr.getline(buf,512);
451 std::stringstream sstr(buf);
452 sstr >> stropt >> strval;
458 istr.getline(buf,512);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
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)
Bool_t LooseOptionCheckingEnabled() const
TString fReferenceFile
reference file for options writing
OptionBase * fLastDeclaredOption
! last declared option
void ResetSetFlag()
resets the IsSet flag for all declare options to be called before options are read from stream
const char * GetConfigName() const
const char * GetConfigDescription() const
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
TString fConfigDescription
description of this configurable
TList fListOfOptions
option list
virtual void ParseOptions()
options parser
MsgLogger * fLogger
! message logger
TString fOptions
options string
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
Bool_t fLooseOptionCheckingEnabled
checker for option string
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
Class for TMVA-option handling.
virtual const char * TheName() const
const char * GetName() const override
Returns name of object.
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 Int_t GetArraySize() const =0
virtual TString GetValue(Int_t i=-1) const =0
const char * GetName() const override
Returns name of object.
Collectable string class.
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
MsgLogger & Endl(MsgLogger &ml)