GENIEGenerator
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
AlgConfigPool.h
Go to the documentation of this file.
1 //____________________________________________________________________________
2 /*!
3 
4 \class genie::AlgConfigPool
5 
6 \brief A singleton class holding all configuration registries built while
7  parsing all loaded XML configuration files.
8 
9 \author Costas Andreopoulos <c.andreopoulos \at cern.ch>
10  University of Liverpool
11 
12 \created May 06, 2004
13 
14 \cpright Copyright (c) 2003-2024, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16 */
17 //____________________________________________________________________________
18 
19 #ifndef _ALG_CONFIG_POOL_H_
20 #define _ALG_CONFIG_POOL_H_
21 
22 #include <map>
23 #include <vector>
24 #include <string>
25 #include <iostream>
26 
29 
30 using std::map;
31 using std::vector;
32 using std::string;
33 using std::ostream;
34 
35 namespace genie {
36 
37 class AlgConfigPool;
38 ostream & operator << (ostream & stream, const AlgConfigPool & cp);
39 
41 
42 public:
43  static AlgConfigPool * Instance();
44 
45  Registry * FindRegistry (string key) const;
46  Registry * FindRegistry (string alg_name, string param_set) const;
47  Registry * FindRegistry (const Algorithm * algorithm) const;
48  Registry * FindRegistry (const AlgId & algid) const;
49 
50  Registry * GlobalParameterList(void) const;
51  Registry * CommonList( const string & file_id, const string & set_name ) const;
52  Registry * TuneGeneratorList(void) const;
53 
54 
55  const vector<string> & ConfigKeyList (void) const;
56 
57  void Print(ostream & stream) const;
58  friend ostream & operator << (ostream & stream, const AlgConfigPool & cp);
59 
60 private:
61  AlgConfigPool();
62  AlgConfigPool(const AlgConfigPool & config_pool);
63  virtual ~AlgConfigPool();
64 
65  // methods for loading all algorithm XML configuration files
66  string BuildConfigKey (string alg_name, string param_set) const;
67  string BuildConfigKey (const Algorithm * algorithm) const;
68  bool LoadAlgConfig (void);
69  bool LoadMasterConfig (std::string configname);
70  bool LoadMasterConfigs (void);
71  bool LoadGlobalParamLists(void);
72  bool LoadCommonLists( const string & file_id );
73  bool LoadTuneGeneratorList(void);
74  bool LoadSingleAlgConfig (string alg_name, string file_name);
75  bool LoadRegistries (string key_base, string file_name, string root);
76  int AddParameterVector (Registry * r, string pt, string pn, string pv, const string & delim = ";" );
77  int AddParameterMatrix (Registry * r, string pt, string pn, string pv, const string & rowdelim, const string & coldelim );
78  int AddParameterMatrix (Registry * r, string pt, string pn, string pv);
79  void AddConfigParameter (Registry * r, string pt, string pn, string pv);
80  void AddBasicParameter (Registry * r, string pt, string pn, string pv);
81  void AddRootObjParameter (Registry * r, string pt, string pn, string pv);
82 
83 
85 
86  map<string, Registry *> fRegistryPool; ///< algorithm/param_set -> Registry
87  map<string, string> fConfigFiles; ///< algorithm -> XML config file
88  vector<string> fConfigKeyList; ///< list of all available configuration keys
89  string fMasterConfig; ///< lists config files for all algorithms
90 
91  struct Cleaner {
94  if (AlgConfigPool::fInstance !=0) {
97  }
98  }
99  };
100  friend struct Cleaner;
101 };
102 
103 } // genie namespace
104 
105 #endif // _ALG_CONFIG_POOL_H_
vector< string > fConfigKeyList
list of all available configuration keys
Definition: AlgConfigPool.h:88
bool LoadGlobalParamLists(void)
void Print(ostream &stream) const
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
Algorithm abstract base class.
Definition: Algorithm.h:54
void AddConfigParameter(Registry *r, string pt, string pn, string pv)
bool LoadSingleAlgConfig(string alg_name, string file_name)
Registry * CommonList(const string &file_id, const string &set_name) const
int AddParameterMatrix(Registry *r, string pt, string pn, string pv, const string &rowdelim, const string &coldelim)
void AddRootObjParameter(Registry *r, string pt, string pn, string pv)
static AlgConfigPool * fInstance
Definition: AlgConfigPool.h:84
Registry * TuneGeneratorList(void) const
void AddBasicParameter(Registry *r, string pt, string pn, string pv)
bool LoadTuneGeneratorList(void)
const vector< string > & ConfigKeyList(void) const
Registry * GlobalParameterList(void) const
Algorithm ID (algorithm name + configuration set name)
Definition: AlgId.h:34
int AddParameterVector(Registry *r, string pt, string pn, string pv, const string &delim=";")
bool LoadMasterConfigs(void)
bool LoadRegistries(string key_base, string file_name, string root)
map< string, string > fConfigFiles
algorithm -&gt; XML config file
Definition: AlgConfigPool.h:87
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:65
map< string, Registry * > fRegistryPool
algorithm/param_set -&gt; Registry
Definition: AlgConfigPool.h:86
bool LoadMasterConfig(std::string configname)
Registry * FindRegistry(string key) const
friend ostream & operator<<(ostream &stream, const AlgConfigPool &cp)
string BuildConfigKey(string alg_name, string param_set) const
bool LoadCommonLists(const string &file_id)
static AlgConfigPool * Instance()
string fMasterConfig
lists config files for all algorithms
Definition: AlgConfigPool.h:89