20 #include "TStopwatch.h"
85 for(FWConfiguration::KeyValues::const_iterator it = iConfig.
keyValues()->begin(),
89 std::map<std::string,FWConfigurable*>::const_iterator itFound =
m_configurables.find(it->first);
91 itFound->second->setFrom(it->second);
99 for(std::map<std::string,FWConfigurable*>::const_iterator it =
m_configurables.begin(),
103 it->second->addTo(config);
114 std::ofstream
file(iName.c_str());
118 throw std::runtime_error(message.c_str());
127 catch (std::runtime_error &
e)
129 fwLog(
fwlog::kError) <<
"FWConfigurationManager::writeToFile() " << e.what() << std::endl;
138 gROOT->LoadMacro( iName.c_str(), &
error );
142 throw std::runtime_error(message.c_str());
148 Long_t lConfig = gROOT->ProcessLineFast(command.c_str(),
155 gROOT->ProcessLineSync((
std::string(
".U ")+iName).c_str(), &error);
160 throw std::runtime_error(message.c_str());
162 std::auto_ptr<FWConfiguration>
config( reinterpret_cast<FWConfiguration*>(lConfig) );
170 #ifdef FW_CONFIG_PARSER_DEBUG
171 static char *debug_states[] = {
179 std::cerr <<
" " << where <<
" tag/data " << tag <<
"in state " << debug_states[state] << std::endl;
228 for (
size_t i = 0,
e = attributes.size();
i !=
e; ++
i)
231 if (attr.
key ==
"name")
233 else if (attr.
key ==
"version")
236 version = strtol(attr.
value.c_str(), &endptr, 10);
237 if (endptr == attr.
value.c_str())
256 throw ParserError(
"Expecting toplevel <config> tag");
265 else if (tag ==
"string")
278 throw ParserError(
"Wrong opening tag found " + tag);
295 throw ParserError(
"Wrong closing tag found " + tag);
301 m_configs.back().second->addKeyValue(key, *current);
312 throw ParserError(
"Wrong closing tag found " + tag);
330 else if (strspn(data.c_str(),
" \t\n") != data.size())
343 std::vector<std::pair<std::string, FWConfiguration *> >
m_configs;
359 std::ifstream
f(iName.c_str());
360 if (
f.peek() != (int)
'<')
369 std::ifstream
g(iName.c_str());
385 bool operator < (
const CMatch&
x)
const {
return cnt < x.cnt; }
388 std::vector<CMatch> clist;
389 clist.push_back(CMatch(
"reco.fwc"));
390 clist.push_back(CMatch(
"miniaod.fwc"));
391 clist.push_back(CMatch(
"aod.fwc"));
392 std::vector<FWJobMetadataManager::Data> & sdata = dataMng->
usableData();
394 for (std::vector<CMatch>::iterator
c = clist.begin();
c != clist.end(); ++
c ) {
395 std::string iName = gSystem->Which(TROOT::GetMacroPath(),
c->file.c_str(), kReadPermission);
396 std::ifstream
f(iName.c_str());
397 if (
f.peek() != (int)
'<') {
398 fwLog(
fwlog::kWarning) <<
"FWConfigurationManager::guessAndReadFromFile can't open "<< iName << std::endl ;
403 std::ifstream
g(iName.c_str());
407 c->cfg = parser->config();
409 for(FWConfiguration::KeyValues::const_iterator it =
c->cfg->keyValues()->begin(),
410 itEnd =
c->cfg->keyValues()->end(); it != itEnd; ++it) {
411 if (it->first ==
"EventItems" ) {
412 keyValues = it->second.keyValues();
417 for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin(); it != keyValues->end(); ++it)
422 for(std::vector<FWJobMetadataManager::Data>::iterator di = sdata.begin(); di != sdata.end(); ++di)
424 if (di->type_ == type) {
433 fwLog(
fwlog::kInfo) <<
"Loading configuration file " << clist.back().file << std::endl;
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
FWXMLConfigParser(std::istream &f)
std::string m_currentConfigName
std::vector< Attribute > Attributes
void to(FWConfiguration &) const
std::auto_ptr< FWConfiguration > m_first
const KeyValues * keyValues() const
std::vector< std::pair< std::string, FWConfiguration * > > m_configs
void streamTo(std::ostream &, const FWConfiguration &, const std::string &name)
void writeToFile(const std::string &) const
virtual ~FWConfigurationManager()
void debug_config_state_machine(const char *where, const std::string &tag, int state)
void readFromOldFile(const std::string &) const
void readFromFile(const std::string &) const
FWConfiguration * config(void)
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
virtual void startElement(const std::string &tag, Attributes &attributes) override
void pushConfig(Attributes &attributes)
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
void setFrom(const FWConfiguration &) const
void guessAndReadFromFile(FWJobMetadataManager *) const
virtual void endElement(const std::string &tag) override
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
virtual void data(const std::string &data) override
void add(const std::string &iName, FWConfigurable *)
does not take ownership
volatile std::atomic< bool > shutdown_flag false
std::map< std::string, FWConfigurable * > m_configurables