29 #ifndef ROOT_TMVA_Option 30 #define ROOT_TMVA_Option 75 virtual void Print( std::ostream&,
Int_t levelofdetail=0 )
const = 0;
115 virtual void AddPreDefVal(
const T&);
117 virtual void Print ( std::ostream&,
Int_t levelofdetail=0 )
const;
118 virtual void PrintPreDefs( std::ostream&,
Int_t levelofdetail=0 )
const;
125 virtual Bool_t IsPreDefinedValLocal(
const T& )
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" 263 this->PrintPreDefs(os,levelofdetail);
270 for (
Int_t i=0; i<fSize; i++) {
274 os <<
" " << this->
TheName() <<
"[" << i <<
"]: " <<
"\"" << this->
GetValue(i) <<
"\"";
275 if (i!=fSize-1) os << std::endl;
277 this->PrintPreDefs(os,levelofdetail);
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;
virtual Int_t GetArraySize() const
const T & Value(Int_t i) const
MsgLogger & Endl(MsgLogger &ml)
virtual const T & Value(Int_t i=-1) const
virtual void Print(std::ostream &, Int_t levelofdetail=0) const
virtual Bool_t IsPreDefinedValLocal(const T &) const
virtual void Print(std::ostream &, Int_t levelofdetail=0) const =0
const TString & Description() const
Option(T *&ref, Int_t size, const TString &name, const TString &desc)
virtual Bool_t IsArrayOpt() const =0
void ToLower()
Change string to lower-case.
virtual Int_t GetArraySize() const
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
virtual TString GetValue(Int_t i=-1) const =0
virtual void AddPreDefVal(const T &)
#define ClassDef(name, id)
virtual Bool_t IsPreDefinedVal(const TString &) const
OptionBase(const TString &name, const TString &desc)
constructor
virtual void PrintPreDefs(std::ostream &, Int_t levelofdetail=0) const
virtual TString GetValue(Int_t i=-1) const
virtual void SetValueLocal(const TString &val, Int_t i=-1)
virtual Bool_t SetValue(const TString &vs, Int_t i=-1)
set value for option
TString GetValue(Int_t i) const
virtual Bool_t IsArrayOpt() const
Class for TMVA-option handling.
virtual Bool_t HasPreDefinedVal() const =0
virtual Int_t GetArraySize() const =0
Option(T &ref, const TString &name, const TString &desc)
virtual Bool_t IsArrayOpt() const
const TString fDescription
virtual const char * GetName() const
Returns name of object.
static constexpr double s
virtual const char * TheName() const
virtual Bool_t HasPreDefinedVal() const
virtual Bool_t IsPreDefinedVal(const TString &) const =0
ostringstream derivative to redirect and format output
Mother of all ROOT objects.
Abstract ClassifierFactory template that handles arbitrary types.
virtual void SetValueLocal(const TString &vs, Int_t i=-1)=0
std::vector< T > fPreDefs
const char * Data() const