ConfigManager.h
Go to the documentation of this file.
1 #ifndef WIRECELL_CONFIGMANAGER
2 #define WIRECELL_CONFIGMANAGER
3 
5 
6 namespace WireCell {
7 
8  /** Bundle up some policy for handling configuration.
9  *
10  * Overall configuration object is a list of configuration
11  * objects for each configurable instance.
12  *
13  * Each instance configuration is a dict with keys:
14  *
15  * - type gives the registered class name
16  * - name gives an instance name, ("" by default if omitted)
17  * - data gives a type-specific Configuration dictionary for the instance.
18  *
19  */
20  class ConfigManager {
22  public:
23  ConfigManager();
25 
26  /// Extend current list of configuration objects with more.
27  void extend(Configuration more);
28 
29 
30  // Add a fully-built configurable configuration for an instance, return its index
31  int add(Configuration& cfg);
32 
33  // Add a configurable configuration by parts, return its index
34  int add(Configuration& data, const std::string& type, const std::string& name="");
35 
36  /// Return top-level, aggregate configuration
37  Configuration all() const { return m_top; }
38 
39  Configuration at(int index) const;
40 
41  /// Return index of configuration for given class and instance
42  /// names. If not found, returned index == -1;
43  int index(const std::string& type, const std::string& name="") const;
44 
45  /// Return the number of configuration objects.
46  int size() const { return m_top.size(); }
47 
48  /// Remove configuration at given index and return it.
49  Configuration pop(int ind);
50 
51  /// Return a list of all known configurables
52  typedef std::pair<std::string, std::string> ClassInstance;
53  std::vector<ClassInstance> configurables() const;
54 
55  };
56 
57 }
58 
59 
60 #endif
61 
static QCString name
Definition: declinfo.cpp:673
std::vector< ClassInstance > configurables() const
std::string string
Definition: nybbler.cc:12
std::pair< std::string, std::string > ClassInstance
Return a list of all known configurables.
Definition: ConfigManager.h:52
cfg
Definition: dbjson.py:29
basic_data data
Definition: format.h:764
void extend(Configuration more)
Extend current list of configuration objects with more.
Configuration all() const
Return top-level, aggregate configuration.
Definition: ConfigManager.h:37
int size() const
Return the number of configuration objects.
Definition: ConfigManager.h:46
Configuration at(int index) const
int add(Configuration &cfg)
Definition: Main.h:22
int index(const std::string &type, const std::string &name="") const
Json::Value Configuration
Definition: Configuration.h:50
Configuration pop(int ind)
Remove configuration at given index and return it.