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 <constantinos.andreopoulos \at cern.ch>
10  University of Liverpool & STFC Rutherford Appleton Laboratory
11 
12 \created May 06, 2004
13 
14 \cpright Copyright (c) 2003-2020, 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 (void);
70  bool LoadGlobalParamLists(void);
71  bool LoadCommonLists( const string & file_id );
72  bool LoadTuneGeneratorList(void);
73  bool LoadSingleAlgConfig (string alg_name, string file_name);
74  bool LoadRegistries (string key_base, string file_name, string root);
75  int AddParameterVector (Registry * r, string pt, string pn, string pv, const string & delim = ";" );
76  void AddConfigParameter (Registry * r, string pt, string pn, string pv);
77  void AddBasicParameter (Registry * r, string pt, string pn, string pv);
78  void AddRootObjParameter (Registry * r, string pt, string pn, string pv);
79 
80 
82 
83  map<string, Registry *> fRegistryPool; ///< algorithm/param_set -> Registry
84  map<string, string> fConfigFiles; ///< algorithm -> XML config file
85  vector<string> fConfigKeyList; ///< list of all available configuration keys
86  string fMasterConfig; ///< lists config files for all algorithms
87 
88  struct Cleaner {
91  if (AlgConfigPool::fInstance !=0) {
94  }
95  }
96  };
97  friend struct Cleaner;
98 };
99 
100 } // genie namespace
101 
102 #endif // _ALG_CONFIG_POOL_H_
vector< string > fConfigKeyList
list of all available configuration keys
Definition: AlgConfigPool.h:85
THE MAIN GENIE PROJECT NAMESPACE
Definition: AlgCmp.h:25
string delim()
Definition: fcldump.cxx:40
bool LoadGlobalParamLists(void)
void Print(ostream &stream) const
std::string string
Definition: nybbler.cc:12
A singleton class holding all configuration registries built while parsing all loaded XML configurati...
Definition: AlgConfigPool.h:40
struct vector vector
Algorithm abstract base class.
Definition: Algorithm.h:53
void AddConfigParameter(Registry *r, string pt, string pn, string pv)
bool LoadSingleAlgConfig(string alg_name, string file_name)
QCString file_name
Registry * CommonList(const string &file_id, const string &set_name) const
void AddRootObjParameter(Registry *r, string pt, string pn, string pv)
static AlgConfigPool * fInstance
Definition: AlgConfigPool.h:81
def key(type, name=None)
Definition: graph.py:13
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 LoadRegistries(string key_base, string file_name, string root)
map< string, string > fConfigFiles
algorithm -> XML config file
Definition: AlgConfigPool.h:84
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 -> Registry
Definition: AlgConfigPool.h:83
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:86