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 <costas.andreopoulos \at stfc.ac.uk>
10  University of Liverpool & STFC Rutherford Appleton Lab
11 
12 \created May 06, 2004
13 
14 \cpright Copyright (c) 2003-2019, The GENIE Collaboration
15  For the full text of the license visit http://copyright.genie-mc.org
16  or see $GENIE/LICENSE
17 */
18 //____________________________________________________________________________
19 
20 #ifndef _ALG_CONFIG_POOL_H_
21 #define _ALG_CONFIG_POOL_H_
22 
23 #include <map>
24 #include <vector>
25 #include <string>
26 #include <iostream>
27 
30 
31 using std::map;
32 using std::vector;
33 using std::string;
34 using std::ostream;
35 
36 namespace genie {
37 
38 class AlgConfigPool;
39 ostream & operator << (ostream & stream, const AlgConfigPool & cp);
40 
42 
43 public:
44  static AlgConfigPool * Instance();
45 
46  Registry * FindRegistry (string key) const;
47  Registry * FindRegistry (string alg_name, string param_set) const;
48  Registry * FindRegistry (const Algorithm * algorithm) const;
49  Registry * FindRegistry (const AlgId & algid) const;
50 
51  Registry * GlobalParameterList(void) const;
52  Registry * CommonList( const string & file_id, const string & set_name ) const;
53  Registry * TuneGeneratorList(void) const;
54 
55 
56  const vector<string> & ConfigKeyList (void) const;
57 
58  void Print(ostream & stream) const;
59  friend ostream & operator << (ostream & stream, const AlgConfigPool & cp);
60 
61 private:
62  AlgConfigPool();
63  AlgConfigPool(const AlgConfigPool & config_pool);
64  virtual ~AlgConfigPool();
65 
66  // methods for loading all algorithm XML configuration files
67  string BuildConfigKey (string alg_name, string param_set) const;
68  string BuildConfigKey (const Algorithm * algorithm) const;
69  bool LoadAlgConfig (void);
70  bool LoadMasterConfig (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  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 
81 
82  map<string, Registry *> fRegistryPool; ///< algorithm/param_set -> Registry
83  map<string, string> fConfigFiles; ///< algorithm -> XML config file
84  vector<string> fConfigKeyList; ///< list of all available configuration keys
85  string fMasterConfig; ///< lists config files for all algorithms
86 
87  struct Cleaner {
90  if (AlgConfigPool::fInstance !=0) {
93  }
94  }
95  };
96  friend struct Cleaner;
97 };
98 
99 } // genie namespace
100 
101 #endif // _ALG_CONFIG_POOL_H_
vector< string > fConfigKeyList
list of all available configuration keys
Definition: AlgConfigPool.h:84
THE MAIN GENIE PROJECT NAMESPACE
Definition: GeneratorBase.h:8
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:41
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
void AddRootObjParameter(Registry *r, string pt, string pn, string pv)
static AlgConfigPool * fInstance
Definition: AlgConfigPool.h:80
Registry * TuneGeneratorList(void) const
root
Link up the nodes tree #####.
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:35
bool LoadRegistries(string key_base, string file_name, string root)
map< string, string > fConfigFiles
algorithm -> XML config file
Definition: AlgConfigPool.h:83
ostream & operator<<(ostream &stream, const AlgConfigPool &config_pool)
A registry. Provides the container for algorithm configuration parameters.
Definition: Registry.h:66
map< string, Registry * > fRegistryPool
algorithm/param_set -> Registry
Definition: AlgConfigPool.h:82
TRandom3 r(0)
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:85
enum BeamMode string