29 #ifndef ROOT_TMVA_Option
30 #define ROOT_TMVA_Option
53 #ifndef ROOT_TMVA_MsgLogger
83 virtual void Print( std::ostream&,
Int_t levelofdetail=0 )
const = 0;
122 virtual void Print ( std::ostream&,
Int_t levelofdetail=0 )
const;
142 Option<
T>(*ref,name, desc), fVRefPtr(&ref), fSize(size) {}
146 std::stringstream str;
147 str << std::scientific <<
Value(i);
155 virtual void Print( std::ostream&,
Int_t levelofdetail=0 )
const;
182 std::stringstream str;
183 str << std::scientific << this->
Value();
189 return Value() ?
"True" :
"False";
194 return Value(i) ?
"True" :
"False";
202 std::stringstream str(val.
Data());
204 return IsPreDefinedValLocal(tmpVal);
211 if (fPreDefs.size()==0)
return kTRUE;
213 typename std::vector<T>::const_iterator predefIt;
214 predefIt = fPreDefs.begin();
215 for (;predefIt!=fPreDefs.end(); predefIt++)
216 if ( (*predefIt)==val )
return kTRUE;
227 if (fPreDefs.size()==0)
return kFALSE;
229 std::vector<TString>::const_iterator predefIt;
230 predefIt = fPreDefs.begin();
231 for (;predefIt!=fPreDefs.end(); predefIt++) {
234 if (s==tVal) { foundPreDef =
kTRUE;
break; }
244 fPreDefs.push_back(val);
251 Log() <<
kFATAL <<
"<AddPreDefVal> predefined values for Option<Bool_t> don't make sense"
259 Log() <<
kFATAL <<
"<AddPreDefVal> predefined values for Option<Float_t> don't make sense"
267 os << TheName() <<
": " <<
"\"" << GetValue() <<
"\"" <<
" [" << Description() <<
"]";
268 this->PrintPreDefs(os,levelofdetail);
275 for (
Int_t i=0; i<fSize; i++) {
277 os << this->TheName() <<
"[" << i <<
"]: " <<
"\"" << this->GetValue(i) <<
"\"" <<
" [" << this->Description() <<
"]";
279 os <<
" " << this->TheName() <<
"[" << i <<
"]: " <<
"\"" << this->GetValue(i) <<
"\"";
280 if (i!=fSize-1) os << std::endl;
282 this->PrintPreDefs(os,levelofdetail);
290 if (HasPreDefinedVal() && levelofdetail>0) {
291 os << std::endl <<
"PreDefined - possible values are:" << std::endl;
292 typename std::vector<T>::const_iterator predefIt;
293 predefIt = fPreDefs.begin();
294 for (;predefIt!=fPreDefs.end(); predefIt++) {
296 os <<
" - " << (*predefIt) << std::endl;
306 if (ind >= fSize)
return kFALSE;
307 std::stringstream str(val.
Data());
322 std::stringstream str(val.
Data());
331 if (fPreDefs.size()!=0) {
334 std::vector<TString>::const_iterator predefIt;
335 predefIt = fPreDefs.begin();
336 for (;predefIt!=fPreDefs.end(); predefIt++) {
339 if (s==tVal) { valToSet = *predefIt;
break; }
343 std::stringstream str(valToSet.
Data());
353 if (valToSet==
"1" || valToSet==
"true" || valToSet==
"ktrue" || valToSet==
"t") {
354 this->
Value() =
true;
356 else if (valToSet==
"0" || valToSet==
"false" || valToSet==
"kfalse" || valToSet==
"f") {
357 this->
Value() =
false;
360 Log() <<
kFATAL <<
"<SetValueLocal> value \'" << val
361 <<
"\' can not be interpreted as boolean" <<
Endl;
virtual Int_t GetArraySize() const
virtual Bool_t IsArrayOpt() const
MsgLogger & Endl(MsgLogger &ml)
virtual void Print(std::ostream &, Int_t levelofdetail=0) const =0
const TString & Description() const
virtual Bool_t IsArrayOpt() 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 Bool_t IsPreDefinedVal(const TString &) const
virtual TString GetValue(Int_t i=-1) const =0
virtual void AddPreDefVal(const T &)
const char * Data() const
OptionBase(const TString &name, const TString &desc)
constructor
virtual Int_t GetArraySize() 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
virtual void Print(Option_t *option="") const
This method must be overridden when a class wants to print itself.
TString GetValue(Int_t i) const
virtual void Print(std::ostream &, Int_t levelofdetail=0) const
virtual const char * TheName() const
virtual Bool_t HasPreDefinedVal() const =0
virtual Int_t GetArraySize() const =0
virtual Bool_t HasPreDefinedVal() const
Option(T &ref, const TString &name, const TString &desc)
virtual Bool_t IsPreDefinedValLocal(const T &) const
const TString fDescription
void Print(std::ostream &os, const OptionType &opt)
virtual const T & Value(Int_t i=-1) const
virtual Bool_t IsPreDefinedVal(const TString &) const =0
Mother of all ROOT objects.
Abstract ClassifierFactory template that handles arbitrary types.
virtual void PrintPreDefs(std::ostream &, Int_t levelofdetail=0) const
virtual TString GetValue(Int_t i=-1) const
const T & Value(Int_t i) const
virtual void SetValueLocal(const TString &vs, Int_t i=-1)=0
virtual const char * GetName() const
Returns name of object.
std::vector< T > fPreDefs