All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ConfigManager.cxx
Go to the documentation of this file.
1 #ifndef __FLASHMATCHBASE_CONFIGMANAGER_CXX__
2 #define __FLASHMATCHBASE_CONFIGMANAGER_CXX__
3 
4 #include "ConfigManager.h"
5 #include "PSetUtils.h"
6 namespace flashmatch {
7 
8  ConfigManager* ConfigManager::_me = nullptr;
9 
10  void ConfigManager::AddConfigFile(const std::string cfg_file)
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  }
19 
20  void ConfigManager::AddConfigString(const std::string cfg_str)
21  {
22  PSet p;
23  p.add(cfg_str);
24  _cfg.add_pset(p);
25  }
26 
27  const PSet& ConfigManager::GetConfig(const std::string cfg)
28  {
29  return _cfg.get_pset(cfg);
30  }
31 
32 }
33 
34 #endif
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
pdgs p
Definition: selectors.fcl:22
std::set< std::string > _cfg_files
Definition: ConfigManager.h:53
static ConfigManager * _me
Definition: ConfigManager.h:52
void AddConfigString(const std::string cfg_str)
Adder of configuration from parsed string.
void AddConfigFile(const std::string cfg_file)
Adder of configuration from a file.
Utility functions in Base/PSet.
void add(const std::string &data)
Set data contents.
Definition: PSet.cxx:177
const PSet & GetConfig(const std::string cfg)
Configuration retrieval method.
Class def header for a class flashmatch::ConfigManager.
const PSet & get_pset(const std::string &key) const
None-template function to retrieve parameter set (deprecated)
Definition: PSet.cxx:376
A nested configuration parameter set holder for flashmatch framework.
Definition: PSet.h:26