59#pragma warning ( disable : 4355 )
66:
TNamed(
"Configurable",
"Configurable"),
68 fLooseOptionCheckingEnabled (
kTRUE ),
69 fLastDeclaredOption ( 0 ),
70 fConfigDescription (
"No description" ),
71 fReferenceFile (
"None" ),
125 Log() << kVERBOSE <<
"Parsing option string: " <<
Endl;
135 SplitOptions(fOptions,
loo);
139 std::map<TString, std::vector<std::pair<Int_t, TString> > >
arrayTypeOptions;
172 st.Remove(
st.First(
']'));
173 std::stringstream str(
st.Data());
182 Log() << kWARNING <<
"Value for option " <<
decOpt->GetName()
183 <<
" was previously set to " <<
decOpt->GetValue() <<
Endl;
186 if (
decOpt->IsArrayOpt()) {
194 Log() << kFATAL <<
"Index " << idx <<
" too large for option " <<
decOpt->TheName()
195 <<
", allowed range is [0," <<
decOpt->GetArraySize()-1 <<
"]" <<
Endl;
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;
236 Log() << kFATAL <<
"Negating a non-boolean variable " <<
optname
237 <<
", please check the options for method: " << GetName() <<
Endl;
243 if (!
paramParsed && LooseOptionCheckingEnabled()) {
248 if (
decOpt->HasPreDefinedVal() &&
decOpt->IsPreDefinedVal(s) ) {
255 if (fOptions!=
"") fOptions +=
":";
263 if (
gConfig().WriteOptionsReference()) WriteOptionsReferenceToFile();
290 <<
"The following options were specified, but could not be interpreted: \'"
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()) {
383 if (fOptions.Length()!=0) fOptions +=
":";
386 std::stringstream s(
"");
388 if (
gTools().HasAttr(opt,
"size")) {
394 s << std::scientific <<
optName <<
"[" << i <<
"]=" << values[i];
400 fOptions += s.str().c_str();
412 fReferenceFile = dir +
"/" + GetConfigName() +
"_optionsRef.txt";
413 std::ofstream o( fReferenceFile );
415 Log() << kFATAL <<
"<WriteOptionsToInfoFile> Unable to open output file: " << fReferenceFile <<
Endl;
419 o <<
"# List of options:" << std::endl;
420 o <<
"# Configurable: " << GetConfigName() << std::endl;
421 o <<
"# Description: " << GetConfigDescription() << std::endl;
424 o << std::endl <<
"# ------------------------------------------------" << std::endl;
428 Log() << kVERBOSE <<
"Wrote options reference file: \"" << fReferenceFile <<
"\"" <<
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);
453 stropt.ReplaceAll(
':',
'=');
454 strval.ReplaceAll(
"\"",
"");
455 if (fOptions.Length()!=0) fOptions +=
":";
458 istr.getline(buf,512);
size_t size(const MatrixT &matrix)
retrieve the size of a square matrix
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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.
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.
The TNamed class is the base class for all named ROOT classes.
Collectable string class.
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.
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)