20 #include "TStopwatch.h" 74 assert(
nullptr!=iConf);
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());
116 std::string message =
"unable to open file " + iName;
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);
158 std::string message(
"unable to properly parse configuration file ");
160 throw std::runtime_error(message.c_str());
162 std::unique_ptr<FWConfiguration>
config( reinterpret_cast<FWConfiguration*>(lConfig) );
177 std::ifstream
f(iName.c_str());
178 if (
f.peek() != (
int)
'<')
187 std::ifstream
g(iName.c_str());
203 bool operator < (
const CMatch&
x)
const {
return cnt < x.cnt; }
206 std::vector<CMatch> clist;
207 clist.push_back(CMatch(
"reco.fwc"));
208 clist.push_back(CMatch(
"miniaod.fwc"));
209 clist.push_back(CMatch(
"aod.fwc"));
210 std::vector<FWJobMetadataManager::Data> & sdata = dataMng->
usableData();
212 for (std::vector<CMatch>::iterator
c = clist.begin();
c != clist.end(); ++
c ) {
213 std::string iName = gSystem->Which(TROOT::GetMacroPath(),
c->file.c_str(), kReadPermission);
214 std::ifstream
f(iName.c_str());
215 if (
f.peek() != (
int)
'<') {
216 fwLog(
fwlog::kWarning) <<
"FWConfigurationManager::guessAndReadFromFile can't open "<< iName << std::endl ;
221 std::ifstream
g(iName.c_str());
225 c->cfg = parser->config();
227 for(FWConfiguration::KeyValues::const_iterator it =
c->cfg->keyValues()->begin(),
228 itEnd =
c->cfg->keyValues()->end(); it != itEnd; ++it) {
229 if (it->first ==
"EventItems" ) {
230 keyValues = it->second.keyValues();
235 for (FWConfiguration::KeyValues::const_iterator it = keyValues->begin(); it != keyValues->end(); ++it)
240 for(std::vector<FWJobMetadataManager::Data>::iterator di = sdata.begin(); di != sdata.end(); ++di)
242 if (di->type_ == type) {
250 std::sort(clist.begin(), clist.end());
251 fwLog(
fwlog::kInfo) <<
"Loading configuration file " << clist.back().file << std::endl;
254 return clist.back().file;
std::vector< std::pair< std::string, FWConfiguration > > KeyValues
void to(FWConfiguration &) const
const KeyValues * keyValues() const
void writeToFile(const std::string &) const
virtual ~FWConfigurationManager()
void readFromOldFile(const std::string &) const
void readFromFile(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
bool operator<(const FedChannelConnection &, const FedChannelConnection &)
void setFrom(const FWConfiguration &) const
FWConfiguration & addKeyValue(const std::string &, const FWConfiguration &)
std::string guessAndReadFromFile(FWJobMetadataManager *) const
void add(const std::string &iName, FWConfigurable *)
does not take ownership
static void streamTo(std::ostream &oTo, const FWConfiguration &iConfig, const std::string &name)
std::map< std::string, FWConfigurable * > m_configurables