35 #define ON_DEBUG if (UNLIKELY(outputLevel() <= MSG::DEBUG))
36 #define ON_VERBOSE if (UNLIKELY(outputLevel() <= MSG::VERBOSE))
51 DHH(
const CLID&
i,
const std::string& k):id(i), key(k) {}
57 return (key < rhs.
key);
66 m_isInitialized(false),
72 m_log(msgSvc(), name ),
73 m_outputFileTypeXML(false)
107 std::map<const Algorithm*, AlgorithmHistory*>::iterator algitr;
110 (
const_cast<Algorithm*
> (algitr->first))->release();
117 std::map<const AlgTool*, AlgToolHistory*>::iterator atitr;
119 (
const_cast<AlgTool*
> (atitr->first))->release();
120 delete atitr->second;
125 std::map<const IService*, ServiceHistory*>::iterator svitr;
127 (
const_cast<IService*
> (svitr->first))->release();
128 delete svitr->second;
154 static const bool CREATEIF(
true);
177 const bool rethrow =
false;
178 const bool oneShot =
true;
200 if (
service(
"JobOptionsSvc",jo).isFailure()) {
202 <<
"Could not get jobOptionsSvc - "
203 <<
"not adding properties to JobHistory" <<
endmsg;
206 bool foundAppMgr(
false);
208 std::vector<std::string> clients = jo->
getClients();
209 std::vector<std::string>::const_iterator it;
210 std::vector<const Property*>::const_iterator itr;
211 for (it=clients.begin(); it!=clients.end(); ++it) {
212 if (*it ==
"ApplicationMgr") {
215 const std::vector<const Property*> *props = jo->
getProperties(*it);
216 for (itr=props->begin(); itr != props->end(); ++itr) {
223 if (
service(
"ApplicationMgr",ap).isFailure()) {
226 std::vector<Property*>::const_iterator itr2;
228 for (itr2=props.begin(); itr2 != props.end(); ++itr2) {
242 pp_cast<void>(&algMgr) );
248 std::list<IAlgorithm*> algs;
250 std::list<IAlgorithm*>::const_iterator itr;
251 for (itr=algs.begin(); itr!=algs.end(); ++itr) {
255 <<
" does not inherit from Algorithm. Not registering it."
263 m_log <<
"Registered " << algs.size() <<
" Algorithms" <<
endmsg;
270 std::set<const IAlgTool*>::const_iterator itra;
272 (
const_cast<IAlgTool*
>(*itra))->addRef();
283 std::list<IService*>::const_iterator itrs;
284 for (itrs=svcs.begin(); itrs!=svcs.end(); ++itrs) {
290 m_log <<
"Registered " << svcs.size() <<
" Services" <<
endmsg;
358 <<
" already registered with HistorySvc" <<
endmsg;
362 (
const_cast<Algorithm*
>(&alg))->addRef();
395 std::string str = ost.str();
413 PropertyList::const_iterator itr;
415 ofs << alg.
name() <<
" " <<
dumpProp(*itr) << std::endl;
425 set<const Algorithm*>::const_iterator itr =
m_algs.find(palg);
426 if ( itr ==
m_algs.end() ) {
432 map<const Algorithm*, AlgorithmHistory*>::const_iterator itr2;
435 return ( itr2->second );
443 set<const Algorithm*>::const_iterator itr;
470 m_log <<
"Dumping properties for all Algorithms (" <<
m_algmap.size()
473 std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
486 std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
490 const AlgTool* alg = itr_a->first;
498 m_log <<
"Dumping properties for all Services (" <<
m_svcmap.size()
501 std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
511 m_log <<
"Dumping properties for Job";
516 std::string str = ost.str();
529 ofs <<
"GLOBAL" << std::endl;
531 JobHistory::PropertyPairList::const_iterator itrj;
532 for (itrj=props.begin(); itrj != props.end(); ++itrj) {
533 std::string client = itrj->first;
535 ofs << client <<
" " <<
dumpProp(prp) << std::endl;
538 ofs << std::endl <<
"SERVICES" << std::endl;
539 std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
547 ofs << std::endl <<
"ALGORITHMS" << std::endl;
548 std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
556 ofs << std::endl <<
"ALGTOOLS" << std::endl;
557 std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
559 const AlgTool* alg = itr_a->first;
581 <<
"HistorySvc has been initialized" <<
endmsg;
594 const std::string& ) {
605 <<
"Could not discover current Algorithm:" << endl
606 <<
" object CLID: " <<
id <<
" key: \"" << key
615 <<
"Could not extract concrete Algorithm:"
617 <<
" object CLID: " <<
id <<
" key: \"" << key
632 const std::string& storeName) {
636 pair<DHMitr,DHMitr> mitr =
m_datMap.equal_range(dhh);
638 if (mitr.first == mitr.second) {
641 m_datMap.insert(pair<DHH,DataHistory*>(dhh,dh));
649 algName = ialg->
name();
654 for (
DHMitr itr = mitr.first; itr != mitr.second; ++itr) {
664 m_datMap.insert(pair<DHH,DataHistory*>(dhh,dh));
676 const std::string& )
const {
680 pair<DHMCitr,DHMCitr> mitr =
m_datMap.equal_range(dhh);
682 if(mitr.first == mitr.second) {
686 return mitr.first->second;
695 std::list<DataHistory*>& dhlist)
const {
701 pair<DHMCitr,DHMCitr> mitr =
m_datMap.equal_range(dhh);
703 for (
DHMCitr itr=mitr.first; itr != mitr.second; ++itr) {
704 dhlist.push_back(itr->second);
717 if ( svc.
name() ==
"HistoryStore" ) {
724 map<const IService*, ServiceHistory*>::const_iterator itr =
754 map<const IService*, ServiceHistory*>::const_iterator itr =
762 return ( itr->second );
770 set<const IService*>::const_iterator itr;
795 std::string str = ost.str();
816 PropertyList::const_iterator itr;
818 ofs << svc.
name() <<
" " <<
dumpProp(*itr) << std::endl;
843 <<
"\" to an AlgTool" <<
endmsg;
849 <<
" already registered in HistorySvc" <<
endmsg;
854 (
const_cast<AlgTool*
>(alg))->addRef();
887 std::string str = ost.str();
905 PropertyList::const_iterator itr;
907 ofs << alg.
name() <<
" " <<
dumpProp(*itr) << std::endl;
918 set<const AlgTool*>::const_iterator itr =
m_algtools.find(palg);
925 map<const AlgTool*, AlgToolHistory*>::const_iterator itr2;
928 return ( itr2->second );
937 set<const AlgTool*>::const_iterator itr;
954 <<
"Will try again at next BeginEvent incident" <<
endmsg;
965 std::ostringstream ost;
971 ost <<
"<PROPERTY name=\"" << prop->
name()
989 ofs <<
"<?xml version=\"1.0\" ?> " << std::endl;
990 ofs <<
"<!--Test-xml-->" << std::endl;
991 ofs <<
"<SETUP>" << std::endl;
992 ofs <<
" <GLOBAL>" << std::endl;
994 ofs <<
"GLOBAL" << std::endl;
998 JobHistory::PropertyPairList::const_iterator itrj;
999 std::string client_currently_open =
"start";
1000 for (itrj=props.begin(); itrj != props.end(); ++itrj) {
1002 std::string client = itrj->first;
1003 const Property* prp = itrj->second;
1007 if (client != client_currently_open) {
1008 if(client_currently_open!=
"start") ofs <<
" </COMPONENT>" << endl;
1009 ofs <<
" <COMPONENT name=\""
1010 << client <<
"\" class=\"undefined\">" << std::endl;
1013 ofs << client <<
" ";
1018 client_currently_open = client;
1021 ofs <<
" </COMPONENT>" << endl;
1026 ofs <<
"</GLOBAL>" << endl <<
"<SERVICES>" << endl;
1028 ofs <<
"SERVICES" << std::endl;
1031 std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
1033 const IService* svc = itr_s->first;
1040 ofs <<
"</SERVICES>" << endl <<
"<ALGORITHMS> " << endl;
1042 ofs <<
"ALGORITHMS" << std::endl;
1045 std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
1055 ofs <<
"</ALGORITHMS>" << endl <<
"<ALGTOOLS> " << endl;
1057 ofs <<
"ALGTOOLS" << std::endl;
1060 std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
1062 const AlgTool* alg = itr_a->first;
1069 ofs <<
"</ALGTOOLS>" << endl <<
"</SETUP>" << endl;
1085 if ( (is=dynamic_cast<const IService*>(in)) != 0) {
1091 }
else if ( (ia = dynamic_cast<const Algorithm*>(in)) != 0 ) {
1097 }
else if ( (it = dynamic_cast<const IAlgTool*>(in)) != 0 ) {
1105 <<
"Could not dcast interface to accepted History Obj type for "
1106 << in->
name() << endreq;
1110 if (hist == 0 || vhist == 0) {
1111 m_log <<
MSG::ERROR <<
"Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
1117 hist->
dump(ofs,
true);
1119 ofs <<
">> " << vhist->
name() << endl << *hist << endl;