#include <Fireworks/Core/interface/FWConfigurationManager.h>
Public Member Functions | |
void | add (const std::string &iName, FWConfigurable *) |
does not take ownership | |
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 FWConfigurationManager & | operator= (const FWConfigurationManager &) |
void | readFromOldFile (const std::string &) const |
Private Attributes | |
std::map< std::string, FWConfigurable * > | m_configurables |
Description: <one line="" class="" summary>="">
Usage: <usage>
Definition at line 32 of file FWConfigurationManager.h.
FWConfigurationManager::FWConfigurationManager | ( | ) |
Definition at line 39 of file FWConfigurationManager.cc.
{ }
FWConfigurationManager::~FWConfigurationManager | ( | ) | [virtual] |
Definition at line 48 of file FWConfigurationManager.cc.
{ }
FWConfigurationManager::FWConfigurationManager | ( | const FWConfigurationManager & | ) | [private] |
void FWConfigurationManager::add | ( | const std::string & | iName, |
FWConfigurable * | iConf | ||
) |
does not take ownership
Definition at line 68 of file FWConfigurationManager.cc.
References m_configurables.
Referenced by CmsShowMainBase::setupViewManagers().
{ assert(0!=iConf); m_configurables[iName]=iConf; }
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 351 of file FWConfigurationManager.cc.
References f, g, SimpleSAXParser::parse(), geometryXMLtoCSV::parser, readFromOldFile(), and setFrom().
{ std::ifstream f(iName.c_str()); if (f.peek() != (int) '<') return readFromOldFile(iName); // Check that the syntax is correct. SimpleSAXParser syntaxTest(f); syntaxTest.parse(); f.close(); // Read again, this time actually parse. std::ifstream g(iName.c_str()); // Actually parse the results. FWXMLConfigParser parser(g); parser.parse(); setFrom(*parser.config()); }
void FWConfigurationManager::readFromOldFile | ( | const std::string & | iName | ) | const [private] |
Definition at line 128 of file FWConfigurationManager.cc.
References edmPickEvents::command, HDQMDatabaseProducer::config, error, python::rootplot::argparse::message, and setFrom().
Referenced by readFromFile().
{ Int_t error=0; // Int_t value = gROOT->LoadMacro( iName.c_str(), &error ); if(0 != error) { std::string message("unable to load macro file "); message += iName; throw std::runtime_error(message.c_str()); } const std::string command("(Long_t)(fwConfig() )"); error = 0; Long_t lConfig = gROOT->ProcessLineFast(command.c_str(), &error); { //need to unload this macro so that we can load a new configuration // which uses the same function name in the macro Int_t error = 0; gROOT->ProcessLineSync((std::string(".U ")+iName).c_str(), &error); } if(0 != error) { std::string message("unable to properly parse configuration file "); message += iName; throw std::runtime_error(message.c_str()); } std::auto_ptr<FWConfiguration> config( reinterpret_cast<FWConfiguration*>(lConfig) ); setFrom( *config); }
void FWConfigurationManager::setFrom | ( | const FWConfiguration & | iConfig | ) | const |
Definition at line 78 of file FWConfigurationManager.cc.
References FWConfiguration::keyValues(), and m_configurables.
Referenced by readFromFile(), and readFromOldFile().
{ assert(0!=iConfig.keyValues()); for(FWConfiguration::KeyValues::const_iterator it = iConfig.keyValues()->begin(), itEnd = iConfig.keyValues()->end(); it != itEnd; ++it) { std::map<std::string,FWConfigurable*>::const_iterator itFound = m_configurables.find(it->first); assert(itFound != m_configurables.end()); itFound->second->setFrom(it->second); } }
void FWConfigurationManager::to | ( | FWConfiguration & | oConfig | ) | const |
Definition at line 92 of file FWConfigurationManager.cc.
References FWConfiguration::addKeyValue(), HDQMDatabaseProducer::config, and m_configurables.
Referenced by writeToFile().
{ FWConfiguration config; for(std::map<std::string,FWConfigurable*>::const_iterator it = m_configurables.begin(), itEnd = m_configurables.end(); it != itEnd; ++it) { it->second->addTo(config); oConfig.addKeyValue(it->first, config, true); } }
void FWConfigurationManager::writeToFile | ( | const std::string & | iName | ) | const |
Definition at line 106 of file FWConfigurationManager.cc.
References gather_cfg::cout, alignCSCRings::e, mergeVDriftHistosByStation::file, fwLog, fwlog::kInfo, python::rootplot::argparse::message, streamTo(), and to().
{ try { ofstream file(iName.c_str()); if(not file) { std::string message("unable to open file %s ", iName.c_str()); fflush(stdout); message += iName; throw std::runtime_error(message.c_str()); } FWConfiguration top; to(top); fwLog(fwlog::kInfo) << "Writing to file "<< iName.c_str() << "...\n"; fflush(stdout); streamTo(file, top, "top"); } catch (std::runtime_error &e) { std::cout << e.what() << std::endl; } }
std::map<std::string, FWConfigurable*> FWConfigurationManager::m_configurables [private] |
Definition at line 58 of file FWConfigurationManager.h.