CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Member Functions | Private Attributes
FWConfigurationManager Class Reference

#include <Fireworks/Core/interface/FWConfigurationManager.h>

Public Member Functions

void add (const std::string &iName, FWConfigurable *)
 does not take ownership More...
 
 FWConfigurationManager ()
 
void readFromFile (const std::string &) const
 
void setFrom (const FWConfiguration &) const
 
void to (FWConfiguration &) const
 
void writeToFile (const std::string &) const
 
virtual ~FWConfigurationManager ()
 

Private Member Functions

 FWConfigurationManager (const FWConfigurationManager &)
 
const FWConfigurationManageroperator= (const FWConfigurationManager &)
 
void readFromOldFile (const std::string &) const
 

Private Attributes

std::map< std::string,
FWConfigurable * > 
m_configurables
 

Detailed Description

Description: <one line="" class="" summary>="">

Usage: <usage>

Definition at line 31 of file FWConfigurationManager.h.

Constructor & Destructor Documentation

FWConfigurationManager::FWConfigurationManager ( )

Definition at line 38 of file FWConfigurationManager.cc.

39 {
40 }
FWConfigurationManager::~FWConfigurationManager ( )
virtual

Definition at line 47 of file FWConfigurationManager.cc.

48 {
49 }
FWConfigurationManager::FWConfigurationManager ( const FWConfigurationManager )
private

Member Function Documentation

void FWConfigurationManager::add ( const std::string &  iName,
FWConfigurable iConf 
)

does not take ownership

Definition at line 67 of file FWConfigurationManager.cc.

References m_configurables.

Referenced by CmsShowMainBase::setupViewManagers().

68 {
69  assert(0!=iConf);
70  m_configurables[iName]=iConf;
71 }
std::map< std::string, FWConfigurable * > m_configurables
const FWConfigurationManager& FWConfigurationManager::operator= ( const FWConfigurationManager )
private
void FWConfigurationManager::readFromFile ( const std::string &  iName) const

Reads the configuration specified in iName and creates the internal representation in terms of FWConfigutation objects.

Notice that if the file does not start with '<' the old CINT macro based system is used.

Definition at line 350 of file FWConfigurationManager.cc.

References f, g, SimpleSAXParser::parse(), geometryXMLtoCSV::parser, readFromOldFile(), and setFrom().

351 {
352  std::ifstream f(iName.c_str());
353  if (f.peek() != (int) '<')
354  return readFromOldFile(iName);
355 
356  // Check that the syntax is correct.
357  SimpleSAXParser syntaxTest(f);
358  syntaxTest.parse();
359  f.close();
360 
361  // Read again, this time actually parse.
362  std::ifstream g(iName.c_str());
363  // Actually parse the results.
365  parser.parse();
366  setFrom(*parser.config());
367 }
void readFromOldFile(const std::string &) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
void setFrom(const FWConfiguration &) const
double f[11][100]
void FWConfigurationManager::readFromOldFile ( const std::string &  iName) const
private

Definition at line 127 of file FWConfigurationManager.cc.

References edmPickEvents::command, HDQMDatabaseProducer::config, relativeConstraints::error, python.rootplot.argparse::message, setFrom(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by readFromFile().

128 {
129  Int_t error=0;
130  // Int_t value =
131  gROOT->LoadMacro( iName.c_str(), &error );
132  if(0 != error) {
133  std::string message("unable to load macro file ");
134  message += iName;
135  throw std::runtime_error(message.c_str());
136  }
137 
138  const std::string command("(Long_t)(fwConfig() )");
139 
140  error = 0;
141  Long_t lConfig = gROOT->ProcessLineFast(command.c_str(),
142  &error);
143 
144  {
145  //need to unload this macro so that we can load a new configuration
146  // which uses the same function name in the macro
147  Int_t error = 0;
148  gROOT->ProcessLineSync((std::string(".U ")+iName).c_str(), &error);
149  }
150  if(0 != error) {
151  std::string message("unable to properly parse configuration file ");
152  message += iName;
153  throw std::runtime_error(message.c_str());
154  }
155  std::auto_ptr<FWConfiguration> config( reinterpret_cast<FWConfiguration*>(lConfig) );
156 
157  setFrom( *config);
158 }
void setFrom(const FWConfiguration &) const
void FWConfigurationManager::setFrom ( const FWConfiguration iConfig) const

Definition at line 77 of file FWConfigurationManager.cc.

References FWConfiguration::keyValues(), and m_configurables.

Referenced by readFromFile(), and readFromOldFile().

78 {
79  assert(0!=iConfig.keyValues());
80  for(FWConfiguration::KeyValues::const_iterator it = iConfig.keyValues()->begin(),
81  itEnd = iConfig.keyValues()->end();
82  it != itEnd;
83  ++it) {
84  std::map<std::string,FWConfigurable*>::const_iterator itFound = m_configurables.find(it->first);
85  assert(itFound != m_configurables.end());
86  itFound->second->setFrom(it->second);
87  }
88 }
const KeyValues * keyValues() const
std::map< std::string, FWConfigurable * > m_configurables
void FWConfigurationManager::to ( FWConfiguration oConfig) const

Definition at line 91 of file FWConfigurationManager.cc.

References FWConfiguration::addKeyValue(), HDQMDatabaseProducer::config, and m_configurables.

Referenced by writeToFile().

92 {
94  for(std::map<std::string,FWConfigurable*>::const_iterator it = m_configurables.begin(),
95  itEnd = m_configurables.end();
96  it != itEnd;
97  ++it) {
98  it->second->addTo(config);
99  oConfig.addKeyValue(it->first, config, true);
100  }
101 }
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
std::map< std::string, FWConfigurable * > m_configurables
void FWConfigurationManager::writeToFile ( const std::string &  iName) const

Definition at line 105 of file FWConfigurationManager.cc.

References gather_cfg::cout, alignCSCRings::e, mergeVDriftHistosByStation::file, fwLog, fwlog::kInfo, python.rootplot.argparse::message, streamTo(), AlCaHLTBitMon_QueryRunRegistry::string, to(), and fff_deletion::top.

106 {
107  try
108  {
109  std::ofstream file(iName.c_str());
110  if(not file) {
111  std::string message("unable to open file %s ", iName.c_str());
112  fflush(stdout);
113  message += iName;
114  throw std::runtime_error(message.c_str());
115  }
117  to(top);
118  fwLog(fwlog::kInfo) << "Writing to file "<< iName.c_str() << "...\n";
119  fflush(stdout);
120 
121  streamTo(file, top, "top");
122  }
123  catch (std::runtime_error &e) { std::cout << e.what() << std::endl; }
124 }
void to(FWConfiguration &) const
void streamTo(std::ostream &, const FWConfiguration &, const std::string &name)
#define fwLog(_level_)
Definition: fwLog.h:50
tuple cout
Definition: gather_cfg.py:121

Member Data Documentation

std::map<std::string, FWConfigurable*> FWConfigurationManager::m_configurables
private

Definition at line 57 of file FWConfigurationManager.h.

Referenced by add(), setFrom(), and to().