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;
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 "
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;
const std::string BeginEvent
Processing of a new event has started.
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
virtual StatusCode stop()
Stop (from RUNNING to INITIALIZED).
IntegerProperty m_outputLevel
Service output level.
virtual const std::vector< const Property * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
virtual ServiceHistory * getServiceHistory(const IService &) const
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & type() const
Access to the incident type.
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
Gaudi::StateMachine::State m_state
Service state.
SmartIF< IToolSvc > m_toolSvc
GAUDI_API void resetColor()
Reset the colors to defaults.
AlgorithmHistory * algorithmHistory() const
virtual std::string toString() const =0
value -> string
MSG::Level level()
Retrieve output level.
const std::string & name() const
property name
std::vector< std::pair< std::string, const Property * > > PropertyPairList
virtual void dump(std::ostream &, const bool isXML=false, int indent=0) const =0
AlgorithmHistory class definition.
bool isSuccess() const
Test for a status code of SUCCESS.
virtual StatusCode registerDataHistory(const CLID &id, const std::string &key, const std::string &store)
virtual StatusCode listProperties() const
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
virtual StatusCode registerJob()
virtual std::vector< std::string > getClients() const =0
Get the list of clients.
Base class for History Objects.
HistorySvc class definition.
std::multimap< DHH, DataHistory * > m_datMap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
const std::string & documentation() const
property documentation
JobHistory class definition.
bool isFailure() const
Test for a status code of FAILURE.
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
IAlgorithm * getCurrentIAlg() const
#define DECLARE_COMPONENT(type)
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual const std::list< IAlgorithm * > & getAlgorithms() const =0
Return the list of Algorithms.
GAUDI_API void setColor(MSG::Color col)
Set the text color.
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
virtual void handle(const Incident &inc)
Inform that a new incident has occurred.
virtual unsigned long addRef()
Add reference to object.
std::set< const Algorithm * > m_algs
Main interface for the JobOptions service.
DHH(const CLID &i, const std::string &k)
GAUDI_API ISvcLocator * svcLocator()
const std::string & algorithm_name() const
General service interface definition.
virtual StatusCode registerSvc(const IService &)
This class is used for returning status codes from appropriate routines.
HistorySvc(const std::string &name, ISvcLocator *svc)
virtual StatusCode registerAlgTool(const IAlgTool &)
DataHistory class definition.
IAlgContextSvc * p_algCtxSvc
virtual const std::string & name() const
The identifying name of the algorithm object.
JobHistory * m_jobHistory
virtual StatusCode registerAlg(const Algorithm &)
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
const PropertyList & properties() const
unsigned int CLID
Class ID definition.
void addProperty(const std::string &, const Property *)
DataHistMap::const_iterator DHMCitr
The IAlgorithm is the interface implemented by the Algorithm base class.
const TYPE & value() const
explicit conversion
const PropertyPairList & propertyPairs() const
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
AlgToolHistory class definition.
void dumpState(std::ofstream &) const
const PropertyList & properties() const
IIncidentSvc * m_incidentSvc
virtual DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store)
Base class from which all concrete algorithm classes should be derived.
IInterface compliant class extending IInterface with the name() method.
Property base class allowing Property* collections to be "homogeneous".
virtual DataHistory * getDataHistory(const CLID &id, const std::string &key, const std::string &store) const
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
const PropertyList & properties() const
void dumpProperties(std::ofstream &) const
static std::string convert_string(const std::string &)
Base class for all Incidents (computing events).
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
void setLevel(int level)
Update outputlevel.
Templated class to add the standard messaging functionalities.
ServiceHistory class definition.
virtual const std::string & name() const =0
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
std::set< const IService * > m_svcs
virtual const std::list< IService * > & getServices() const =0
Get a reference to a service and create it if it does not exists.
std::set< const IAlgTool * > m_ialgtools
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Interface for Versioned History Objects.
The IProperty is the basic interface for all components which have properties that can be set or get...
bool operator<(const Gaudi::Time &t1, const Gaudi::Time &t2)
DataHistMap::iterator DHMitr
virtual IAlgorithm * currentAlg() const =0
accessor to current algorithm:
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
virtual StatusCode captureState()
std::map< const IService *, ServiceHistory * > m_svcmap
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual StatusCode reinitialize()
Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
std::set< const AlgTool * > m_algtools
virtual JobHistory * getJobHistory() const
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.