#ifndef ROOT_TMVA_Configurable
#define ROOT_TMVA_Configurable
#include <ostream>
#include "TObject.h"
#include "TList.h"
#ifndef ROOT_TMVA_MsgLogger
#include "TMVA/MsgLogger.h"
#endif
#ifndef ROOT_TMVA_Option
#include "TMVA/Option.h"
#endif
namespace TMVA {
class MsgLogger;
class Configurable : public virtual TObject {
public:
Configurable( const TString& theOption = "" );
virtual ~Configurable();
void ParseOptions( Bool_t verbose = kTRUE);
void PrintOptions() const;
virtual const char* GetName() const { return GetConfigName(); }
const char* GetConfigName() const { return fConfigName; }
const char* GetConfigDescription() const { return fConfigDescription; }
void SetConfigName ( const char* n ) { fConfigName = TString(n); }
void SetConfigDescription( const char* d ) { fConfigDescription = TString(d); }
template<class T>
OptionBase* DeclareOptionRef( T& ref, const TString& name, const TString& desc = "" );
template<class T>
OptionBase* DeclareOptionRef( T*& ref, Int_t size, const TString& name, const TString& desc = "" );
template<class T>
void AddPreDefVal(const T&);
void CheckForUnusedOptions() const;
const TString& GetOptions() const { return fOptions; }
void SetOptions(const TString& s) { fOptions = s; }
protected:
Bool_t LooseOptionCheckingEnabled() const { return fLooseOptionCheckingEnabled; }
void EnableLooseOptions( Bool_t b = kTRUE ) { fLooseOptionCheckingEnabled = b; }
void WriteOptionsToStream ( std::ostream& o, const TString& prefix ) const;
void WriteOptionsReferenceToFile();
void ReadOptionsFromStream ( istream& istr );
void ResetSetFlag();
const TString& GetReferenceFile() const { return fReferenceFile; }
private:
void SplitOptions(const TString& theOpt, TList& loo) const;
TString fOptions;
Bool_t fLooseOptionCheckingEnabled;
OptionBase* fLastDeclaredOption;
TList fListOfOptions;
TString fConfigName;
TString fConfigDescription;
TString fReferenceFile;
public:
mutable MsgLogger fLogger;
private:
template <class T>
void AssignOpt( const TString& name, T& valAssign ) const;
public:
ClassDef(Configurable,0)
};
}
template <class T>
TMVA::OptionBase* TMVA::Configurable::DeclareOptionRef( T& ref, const TString& name, const TString& desc)
{
OptionBase* o = new Option<T>(ref, name, desc);
fListOfOptions.Add(o);
fLastDeclaredOption = o;
return o;
}
template <class T>
TMVA::OptionBase* TMVA::Configurable::DeclareOptionRef( T*& ref, Int_t size, const TString& name, const TString& desc)
{
OptionBase* o = new Option<T*>(ref, size, name, desc);
fListOfOptions.Add(o);
fLastDeclaredOption = o;
return o;
}
template<class T>
void TMVA::Configurable::AddPreDefVal(const T& val)
{
Option<T>* oc = dynamic_cast<Option<T>*>(fLastDeclaredOption);
if(oc!=0) oc->AddPreDefVal(val);
}
template <class T>
void TMVA::Configurable::AssignOpt(const TString& name, T& valAssign) const
{
TObject* opt = fListOfOptions.FindObject(name);
if (opt!=0) valAssign = ((Option<T>*)opt)->Value();
else
fLogger << kFATAL << "Option \"" << name
<< "\" not declared, please check the syntax of your option string" << Endl;
}
#endif
Last change: Sat Nov 1 10:21:32 2008
Last generated: 2008-11-01 10:21
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.