29#ifndef ROOT_TMVA_Option
30#define ROOT_TMVA_Option
75 virtual void Print( std::ostream&,
Int_t levelofdetail=0 )
const = 0;
117 virtual void Print ( std::ostream&,
Int_t levelofdetail=0 )
const;
137 Option<
T>(*ref,
name, desc), fVRefPtr(&ref), fSize(size) {}
141 std::stringstream str;
142 str << std::scientific <<
Value(i);
150 virtual void Print( std::ostream&,
Int_t levelofdetail=0 )
const;
177 std::stringstream str;
178 str << std::scientific << this->
Value();
184 return Value() ?
"True" :
"False";
189 return Value(i) ?
"True" :
"False";
197 std::stringstream str(val.
Data());
199 return IsPreDefinedValLocal(tmpVal);
206 if (fPreDefs.size()==0)
return kTRUE;
208 typename std::vector<T>::const_iterator predefIt;
209 predefIt = fPreDefs.begin();
210 for (;predefIt!=fPreDefs.end(); predefIt++)
211 if ( (*predefIt)==val )
return kTRUE;
222 if (fPreDefs.size()==0)
return kFALSE;
224 std::vector<TString>::const_iterator predefIt;
225 predefIt = fPreDefs.begin();
226 for (;predefIt!=fPreDefs.end(); predefIt++) {
229 if (
s==tVal) { foundPreDef =
kTRUE;
break; }
239 fPreDefs.push_back(val);
246 Log() << kFATAL <<
"<AddPreDefVal> predefined values for Option<Bool_t> don't make sense"
254 Log() << kFATAL <<
"<AddPreDefVal> predefined values for Option<Float_t> don't make sense"
262 os << TheName() <<
": " <<
"\"" << GetValue() <<
"\"" <<
" [" << Description() <<
"]";
263 this->PrintPreDefs(os,levelofdetail);
270 for (
Int_t i=0; i<fSize; i++) {
272 os << this->TheName() <<
"[" << i <<
"]: " <<
"\"" << this->GetValue(i) <<
"\"" <<
" [" << this->Description() <<
"]";
274 os <<
" " << this->TheName() <<
"[" << i <<
"]: " <<
"\"" << this->GetValue(i) <<
"\"";
275 if (i!=fSize-1) os << std::endl;
277 this->PrintPreDefs(os,levelofdetail);
285 if (HasPreDefinedVal() && levelofdetail>0) {
286 os << std::endl <<
"PreDefined - possible values are:" << std::endl;
287 typename std::vector<T>::const_iterator predefIt;
288 predefIt = fPreDefs.begin();
289 for (;predefIt!=fPreDefs.end(); predefIt++) {
291 os <<
" - " << (*predefIt) << std::endl;
301 if (ind >= fSize)
return kFALSE;
302 std::stringstream str(val.
Data());
317 std::stringstream str(val.
Data());
326 if (fPreDefs.size()!=0) {
329 std::vector<TString>::const_iterator predefIt;
330 predefIt = fPreDefs.begin();
331 for (;predefIt!=fPreDefs.end(); predefIt++) {
334 if (
s==tVal) { valToSet = *predefIt;
break; }
338 std::stringstream str(valToSet.
Data());
348 if (valToSet==
"1" || valToSet==
"true" || valToSet==
"ktrue" || valToSet==
"t") {
349 this->
Value() =
true;
351 else if (valToSet==
"0" || valToSet==
"false" || valToSet==
"kfalse" || valToSet==
"f") {
352 this->
Value() =
false;
355 Log() << kFATAL <<
"<SetValueLocal> value \'" << val
356 <<
"\' can not be interpreted as boolean" <<
Endl;
#define ClassDef(name, id)
ostringstream derivative to redirect and format output
Class for TMVA-option handling.
virtual const char * TheName() const
OptionBase(const TString &name, const TString &desc)
constructor
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
const TString fDescription
virtual void SetValueLocal(const TString &vs, Int_t i=-1)=0
virtual Bool_t HasPreDefinedVal() const =0
const TString & Description() const
virtual const char * GetName() const
Returns name of object.
virtual Int_t GetArraySize() const =0
virtual void Print(std::ostream &, Int_t levelofdetail=0) const =0
virtual TString GetValue(Int_t i=-1) const =0
Option(T *&ref, Int_t size, const TString &name, const TString &desc)
TString GetValue(Int_t i) const
virtual Int_t GetArraySize() const
const T & Value(Int_t i) const
virtual Bool_t IsArrayOpt() const
virtual void PrintPreDefs(std::ostream &, Int_t levelofdetail=0) const
virtual Bool_t HasPreDefinedVal() const
virtual void SetValueLocal(const TString &val, Int_t i=-1)
virtual Bool_t IsPreDefinedVal(const TString &) const
virtual TString GetValue(Int_t i=-1) const
std::vector< T > fPreDefs
virtual void AddPreDefVal(const T &)
virtual void Print(std::ostream &, Int_t levelofdetail=0) const
Option(T &ref, const TString &name, const TString &desc)
virtual Int_t GetArraySize() const
virtual Bool_t IsArrayOpt() const
virtual const T & Value(Int_t i=-1) const
virtual Bool_t IsPreDefinedValLocal(const T &) const
Mother of all ROOT objects.
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
void ToLower()
Change string to lower-case.
const char * Data() const
void Print(std::ostream &os, const OptionType &opt)
static constexpr double s
create variable transformations
MsgLogger & Endl(MsgLogger &ml)