All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Static Public Member Functions | Private Attributes | Static Private Attributes | List of all members
flashmatch::ConfigManager Class Reference

Utility class to register a set of configurations Provides also a shared instance through which registered configurations can be shared beyond a single owner.
Using flashmatch::PSet, the uniqueness of configuration parameters is guaranteed (no worry to "overwrite")
. More...

#include <ConfigManager.h>

Public Member Functions

 ConfigManager ()
 Default constructor. More...
 
 ~ConfigManager ()
 Default destructor. More...
 
void AddConfigFile (const std::string cfg_file)
 Adder of configuration from a file. More...
 
void AddConfigString (const std::string cfg_str)
 Adder of configuration from parsed string. More...
 
const PSetGetConfig (const std::string cfg)
 Configuration retrieval method. More...
 

Static Public Member Functions

static const ConfigManagerget ()
 Shared static reference getter. More...
 

Private Attributes

std::set< std::string > _cfg_files
 
PSet _cfg
 

Static Private Attributes

static ConfigManager_me = nullptr
 

Detailed Description

Utility class to register a set of configurations Provides also a shared instance through which registered configurations can be shared beyond a single owner.
Using flashmatch::PSet, the uniqueness of configuration parameters is guaranteed (no worry to "overwrite")
.

Definition at line 28 of file ConfigManager.h.

Constructor & Destructor Documentation

flashmatch::ConfigManager::ConfigManager ( )
inline

Default constructor.

Definition at line 33 of file ConfigManager.h.

33 {}
flashmatch::ConfigManager::~ConfigManager ( )
inline

Default destructor.

Definition at line 36 of file ConfigManager.h.

36 {}

Member Function Documentation

void flashmatch::ConfigManager::AddConfigFile ( const std::string  cfg_file)

Adder of configuration from a file.

Definition at line 10 of file ConfigManager.cxx.

11  {
12  if(_cfg_files.find(cfg_file)!=_cfg_files.end()) {
13  std::cerr << "Duplicate addition of config fiel: " << cfg_file << std::endl;
14  throw std::exception();
15  }
16 
17  _cfg.add_pset(CreatePSetFromFile(cfg_file));
18  }
PSet CreatePSetFromFile(std::string fname, std::string cfg_name)
Given a configuration file (full path), create and return flashmatch::PSet.
Definition: PSetUtils.cxx:32
BEGIN_PROLOG could also be cerr
void add_pset(const PSet &p)
Insert method for a PSet rep.
Definition: PSet.cxx:147
std::set< std::string > _cfg_files
Definition: ConfigManager.h:53
void flashmatch::ConfigManager::AddConfigString ( const std::string  cfg_str)

Adder of configuration from parsed string.

Definition at line 20 of file ConfigManager.cxx.

21  {
22  PSet p;
23  p.add(cfg_str);
24  _cfg.add_pset(p);
25  }
void add_pset(const PSet &p)
Insert method for a PSet rep.
Definition: PSet.cxx:147
pdgs p
Definition: selectors.fcl:22
static const ConfigManager& flashmatch::ConfigManager::get ( )
inlinestatic

Shared static reference getter.

Definition at line 38 of file ConfigManager.h.

39  {
40  if(!_me) _me = new ConfigManager;
41  return *_me;
42  }
static ConfigManager * _me
Definition: ConfigManager.h:52
ConfigManager()
Default constructor.
Definition: ConfigManager.h:33
const PSet & flashmatch::ConfigManager::GetConfig ( const std::string  cfg)

Configuration retrieval method.

Definition at line 27 of file ConfigManager.cxx.

28  {
29  return _cfg.get_pset(cfg);
30  }
const PSet & get_pset(const std::string &key) const
None-template function to retrieve parameter set (deprecated)
Definition: PSet.cxx:376

Member Data Documentation

PSet flashmatch::ConfigManager::_cfg
private

Definition at line 54 of file ConfigManager.h.

std::set<std::string> flashmatch::ConfigManager::_cfg_files
private

Definition at line 53 of file ConfigManager.h.

ConfigManager * flashmatch::ConfigManager::_me = nullptr
staticprivate

Definition at line 52 of file ConfigManager.h.


The documentation for this class was generated from the following files: