// $Id: Config.hh,v 1.12 2005/10/18 23:17:30 thea Exp $ // Author: Daniel De Marco Jan, 25 2002 /***************************************************************************** * ESAF: Euso Simulation and Analysis Framework * * * * Id: Config * * Package: Base * * Coordinator: Marco.Pallavicini * * * *****************************************************************************/ #ifndef __CONFIG_HH__ #define __CONFIG_HH__ #include #include #include "ConfigFileParser.hh" #include "EsafConfigurable.hh" //////////////////////////////////////////////////////////////////////////////// // // // Config // // // // ESAF configuration manager // // // //////////////////////////////////////////////////////////////////////////////// class Config : public EsafMsgSource { public: virtual ~Config(); static Config *Get(); void AssociateParent(const string& c_name, const string& p_name); // associate one class name with parent name // this mechanism allow to ask for base class parameters getting the right file // in case of inheritance trees void AddUserDefinition(const string &ClassName, const string &expr); // add a definition of a class variable that overtakes the config file one Bool_t UseConfig(const string& standard_config_name); inline Bool_t IsStandardConfigDefined() const; Bool_t LoadUserConfig( const char* ); // load a set of user definitions from file inline const char* GetCfgDump() { return fCfgDump.c_str(); } ConfigFileParser *GetCF(const string &ClassType, const string &ClassName, const string &path="" ); // returns the ConfigFileParser object corresponding to ClassName and ClassType inline ConfigFileParser *GetCF(const EsafConfigurable *obj); // returns a standard configuration, i.e. a single ConfigFileParser with // all parameters ConfigFileParser *GetStandardConfig(); inline const char* GetStdConfigList() const { return fStdConfigList.c_str(); }; const map &GetStandardConfigMap() const {return fStandards;} void SaveConfig( const char* name = 0 ); void SetCfgDump( const char* name ); inline void SetStdConfigList( const char* fname ) { fStdConfigList = fname; } void Reset(Bool_t user=kFALSE); // reset: clear internal maps in order to force configuration file reading private: void ResetUserDef(); Config(); // private ctor static Config *fMe; // singleton void LoadStandardConfigs(); // load standard configurations map fCfs; map fStandards; map* > fUserDef; map fChildTable; string fCurrentConfig; string fStdConfigList; string fCfgDump; // config dump filename friend class SimuApplication; ClassDef(Config,0) }; //______________________________________________________________________________ inline ConfigFileParser *Config::GetCF(const EsafConfigurable *obj) { return GetCF( obj->ClassType(), obj->ClassName() ); } //______________________________________________________________________________ inline Bool_t Config::IsStandardConfigDefined() const { // // Returns true if a standard configuration was selected // return !(fCurrentConfig == "None" ); } #endif /* __CONFIG_HH__ */