All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HistorySvc Class Reference

HistorySvc class definition. More...

#include <src/HistorySvc.h>

Inheritance diagram for HistorySvc:
Collaboration diagram for HistorySvc:

Public Member Functions

virtual StatusCode initialize ()
 Initialization (from CONFIGURED to INITIALIZED). More...
 
virtual StatusCode reinitialize ()
 Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED). More...
 
virtual StatusCode finalize ()
 Finalize (from INITIALIZED to CONFIGURED). More...
 
virtual StatusCode stop ()
 Stop (from RUNNING to INITIALIZED). More...
 
virtual StatusCode captureState ()
 
virtual StatusCode registerJob ()
 
virtual StatusCode listProperties () const
 
virtual JobHistorygetJobHistory () const
 
virtual StatusCode registerSvc (const IService &)
 
virtual StatusCode listProperties (const IService &) const
 
virtual ServiceHistorygetServiceHistory (const IService &) const
 
virtual void getServiceHistory (std::set< ServiceHistory * > &) const
 
virtual StatusCode registerAlg (const Algorithm &)
 
virtual StatusCode listProperties (const Algorithm &) const
 
virtual AlgorithmHistorygetAlgHistory (const Algorithm &) const
 
virtual void getAlgHistory (std::set< AlgorithmHistory * > &) const
 
virtual StatusCode registerAlgTool (const IAlgTool &)
 
virtual StatusCode listProperties (const IAlgTool &) const
 
virtual AlgToolHistorygetAlgToolHistory (const IAlgTool &) const
 
virtual void getAlgToolHistory (std::set< AlgToolHistory * > &) const
 
virtual DataHistorycreateDataHistoryObj (const CLID &id, const std::string &key, const std::string &store)
 
virtual StatusCode registerDataHistory (const CLID &id, const std::string &key, const std::string &store)
 
virtual DataHistorygetDataHistory (const CLID &id, const std::string &key, const std::string &store) const
 
virtual int getDataHistory (const CLID &id, const std::string &key, const std::string &storeName, std::list< DataHistory * > &dhlist) const
 
 HistorySvc (const std::string &name, ISvcLocator *svc)
 
virtual void handle (const Incident &inc)
 Inform that a new incident has occurred. More...
 
virtual ~HistorySvc ()
 
- Public Member Functions inherited from extends2< Service, IHistorySvc, IIncidentListener >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments. More...
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments. More...
 
 extends2 (A1 a1)
 Templated constructor with 1 argument. More...
 
 extends2 ()
 Default constructor. More...
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast. More...
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface. More...
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames. More...
 
virtual ~extends2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance. More...
 
virtual const std::string & name () const
 Retrieve name of the service. More...
 
virtual StatusCode configure ()
 Configuration (from OFFLINE to CONFIGURED). More...
 
virtual StatusCode start ()
 Start (from INITIALIZED to RUNNING). More...
 
virtual StatusCode terminate ()
 Initialization (from CONFIGURED to OFFLINE). More...
 
virtual Gaudi::StateMachine::State FSMState () const
 Get the current state. More...
 
virtual Gaudi::StateMachine::State targetFSMState () const
 When we are in the middle of a transition, get the state where the transition is leading us. More...
 
virtual StatusCode restart ()
 Initialization (from RUNNING to RUNNING, via INITIALIZED). More...
 
virtual StatusCode sysInitialize ()
 Initialize Service. More...
 
virtual StatusCode sysStart ()
 Initialize Service. More...
 
virtual StatusCode sysStop ()
 Initialize Service. More...
 
virtual StatusCode sysFinalize ()
 Finalize Service. More...
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service. More...
 
virtual StatusCode sysRestart ()
 Re-initialize the Service. More...
 
virtual StatusCode setProperty (const Property &p)
 Set the property by property. More...
 
virtual StatusCode setProperty (const std::string &s)
 Set the property by string. More...
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 Set the property by std::string. More...
 
virtual StatusCode getProperty (Property *p) const
 Get the property by property. More...
 
virtual const PropertygetProperty (const std::string &name) const
 Get the property by name. More...
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 Get the property by std::string. More...
 
virtual const std::vector
< Property * > & 
getProperties () const
 Get list of properties. More...
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
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. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments. More...
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments. More...
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument. More...
 
 CommonMessaging ()
 Default constructor. More...
 
virtual ~CommonMessaging ()
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces3< IService, IProperty, IStateful >
virtual ~extend_interfaces3 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IService
 DeclareInterfaceID (IService, 3, 0)
 InterfaceID. More...
 
virtual ~IService ()
 virtual destructor More...
 
- Public Member Functions inherited from INamedInterface
 DeclareInterfaceID (INamedInterface, 1, 0)
 InterfaceID. More...
 
virtual ~INamedInterface ()
 Virtual destructor (always needed for abstract classes). More...
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance. More...
 
virtual unsigned long refCount () const =0
 Current reference count. More...
 
virtual ~IInterface ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IProperty
 DeclareInterfaceID (IProperty, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IStateful
 DeclareInterfaceID (IStateful, 1, 0)
 InterfaceID. More...
 
virtual ~IStateful ()
 
- Public Member Functions inherited from extend_interfaces2< IHistorySvc, IIncidentListener >
virtual ~extend_interfaces2 ()
 Virtual destructor. More...
 
- Public Member Functions inherited from IHistorySvc
 DeclareInterfaceID (IHistorySvc, 2, 0)
 InterfaceID. More...
 
- Public Member Functions inherited from IIncidentListener
 DeclareInterfaceID (IIncidentListener, 2, 0)
 InterfaceID. More...
 

Private Types

typedef
IVersHistoryObj::PropertyList 
PropertyList
 
typedef std::multimap< DHH,
DataHistory * > 
DataHistMap
 
typedef DataHistMap::iterator DHMitr
 
typedef DataHistMap::const_iterator DHMCitr
 

Private Member Functions

void clearState ()
 
void dumpProperties (std::ofstream &) const
 
void dumpProperties (const IService &, std::ofstream &) const
 
void dumpProperties (const Algorithm &, std::ofstream &) const
 
void dumpProperties (const IAlgTool &, std::ofstream &) const
 
void dumpState (std::ofstream &) const
 
void dumpState (const INamedInterface *, std::ofstream &) const
 
std::string dumpProp (const Property *, const bool isXML=false, int indent=0) const
 
IAlgorithmgetCurrentIAlg () const
 

Private Attributes

bool m_isInitialized
 
bool m_dump
 
bool m_activate
 
IAlgContextSvcp_algCtxSvc
 
std::set< const Algorithm * > m_algs
 
std::map< const Algorithm
*, AlgorithmHistory * > 
m_algmap
 
std::set< const IAlgTool * > m_ialgtools
 
std::set< const AlgTool * > m_algtools
 
std::map< const AlgTool
*, AlgToolHistory * > 
m_algtoolmap
 
std::set< const IService * > m_svcs
 
std::map< const IService
*, ServiceHistory * > 
m_svcmap
 
std::multimap< DHH, DataHistory * > m_datMap
 
JobHistorym_jobHistory
 
std::string m_outputFile
 
IIncidentSvcm_incidentSvc
 
SmartIF< IToolSvcm_toolSvc
 
MsgStream m_log
 
bool m_outputFileTypeXML
 

Additional Inherited Members

- Public Types inherited from extends2< Service, IHistorySvc, IIncidentListener >
typedef extends2 base_class
 Typedef to this class. More...
 
typedef extend_interfaces2
< IHistorySvc,
IIncidentListener
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from Service
typedef
Gaudi::PluginService::Factory
< IService *, const
std::string &, ISvcLocator * > 
Factory
 
- Public Types inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
typedef CommonMessaging base_class
 
- Public Types inherited from implements3< IService, IProperty, IStateful >
typedef implements3 base_class
 Typedef to this class. More...
 
typedef extend_interfaces3
< IService, IProperty,
IStateful
extend_interfaces_base
 Typedef to the base of this class. More...
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces. More...
 
- Public Types inherited from extend_interfaces3< IService, IProperty, IStateful >
typedef mpl::fold< typename
IService::iid::iids::type,
typename mpl::fold< typename
IProperty::iid::iids::type,
typename
IStateful::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type, mpl::insert< mpl::_1,
mpl::_2 > >::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Public Types inherited from IInterface
enum  Status { SUCCESS = 1, NO_INTERFACE, VERSMISMATCH, LAST_ERROR }
 Return status. More...
 
typedef Gaudi::InterfaceId
< IInterface, 0, 0 > 
iid
 Interface ID. More...
 
typedef mpl::set1< iidext_iids
 Extra interfaces. More...
 
- Public Types inherited from extend_interfaces2< IHistorySvc, IIncidentListener >
typedef mpl::fold< typename
IHistorySvc::iid::iids::type,
typename
IIncidentListener::iid::iids::type,
mpl::insert< mpl::_1, mpl::_2 >
>::type 
ext_iids
 MPL set of interfaces extended by this one. More...
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface. More...
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level. More...
 
Gaudi::StateMachine::State m_state
 Service state. More...
 
Gaudi::StateMachine::State m_targetState
 Service state. More...
 
- Protected Attributes inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
SmartIF< IMessageSvcm_msgsvc
 Pointer to the message service;. More...
 
std::auto_ptr< MsgStreamm_msgStream
 The predefined message stream. More...
 
bool m_streamWithService
 Flag to create a new MsgStream if it was created without the message service. More...
 

Detailed Description

HistorySvc class definition.

Definition at line 43 of file HistorySvc.h.

Member Typedef Documentation

typedef std::multimap<DHH,DataHistory*> HistorySvc::DataHistMap
private

Definition at line 98 of file HistorySvc.h.

typedef DataHistMap::const_iterator HistorySvc::DHMCitr
private

Definition at line 100 of file HistorySvc.h.

typedef DataHistMap::iterator HistorySvc::DHMitr
private

Definition at line 99 of file HistorySvc.h.

Definition at line 96 of file HistorySvc.h.

Constructor & Destructor Documentation

HistorySvc::HistorySvc ( const std::string &  name,
ISvcLocator svc 
)

Definition at line 73 of file HistorySvc.cpp.

74  : base_class( name, svc ),
75  m_isInitialized(false),
76  m_dump(false),
77  p_algCtxSvc(0),
78  m_jobHistory(0),
79  m_outputFile(""),
80  m_incidentSvc(0),
81  m_log(msgSvc(), name ),
82  m_outputFileTypeXML(false)
83 
84 {
85  declareProperty("Dump",m_dump);
86  declareProperty("Activate", m_activate=true);
87  declareProperty("OutputFile",m_outputFile);
88 
89  // hack to bring in environ
90  vector<string> envtmp = System::getEnv();
91  envtmp.size(); // prevent icc remark #177: X declared but never referenced
92 }
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:608
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
extends2 base_class
Typedef to this class.
Definition: extends.h:77
std::string m_outputFile
Definition: HistorySvc.h:126
bool m_activate
Definition: HistorySvc.h:106
bool m_isInitialized
Definition: HistorySvc.h:104
bool m_outputFileTypeXML
Definition: HistorySvc.h:145
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
JobHistory * m_jobHistory
Definition: HistorySvc.h:124
MsgStream m_log
Definition: HistorySvc.h:144
virtual const std::string & name() const
Retrieve name of the service.
Definition: Service.cpp:331
IIncidentSvc * m_incidentSvc
Definition: HistorySvc.h:141
bool m_dump
Definition: HistorySvc.h:105
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:211
HistorySvc::~HistorySvc ( )
virtual

Definition at line 96 of file HistorySvc.cpp.

96  {
97  delete m_jobHistory;
98 }
JobHistory * m_jobHistory
Definition: HistorySvc.h:124

Member Function Documentation

StatusCode HistorySvc::captureState ( )
virtual

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 201 of file HistorySvc.cpp.

201  {
202 
203  if (m_jobHistory == 0) {
204  m_jobHistory = new JobHistory;
205  IJobOptionsSvc *jo;
206  if (service("JobOptionsSvc",jo).isFailure()) {
207  m_log << MSG::ERROR
208  << "Could not get jobOptionsSvc - "
209  << "not adding properties to JobHistory" << endmsg;
210  } else {
211 
212  bool foundAppMgr(false);
213 
214  for (auto& client: jo->getClients()) {
215  if (client == "ApplicationMgr") foundAppMgr = true;
216  for (auto prop: *jo->getProperties(client)) {
217  m_jobHistory->addProperty(client, prop);
218  }
219  }
220 
221  if (!foundAppMgr) {
222  IProperty *ap;
223  if (service("ApplicationMgr", ap).isFailure()) {
224  m_log << MSG::ERROR << "could not get the ApplicationMgr" << endmsg;
225  } else {
226  for (auto prop: ap->getProperties()) {
227  m_jobHistory->addProperty("ApplicationMgr", prop);
228  }
229  }
230  }
231 
232  }
233  }
234 
236 
237  StatusCode sc;
238  IAlgManager* algMgr = 0;
240  pp_cast<void>(&algMgr) );
241  if (sc.isFailure()) {
242  m_log << MSG::ERROR << "Could not get AlgManager" << endmsg;
243  return StatusCode::FAILURE;
244  } else {
245  size_t count = 0;
246  for (auto ialg: algMgr->getAlgorithms()) {
247  Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
248  if (alg == 0) {
249  m_log << MSG::WARNING << "Algorithm " << ialg->name()
250  << " does not inherit from Algorithm. Not registering it."
251  << endmsg;
252  } else {
253  ++count;
254  registerAlg( *alg ).ignore();
255  }
256  }
257 
258  m_log << MSG::INFO << "Registered " << count << " Algorithms" << endmsg;
259 
260  }
261 
263 
264  m_isInitialized = true;
265  for (auto algtool: m_ialgtools) {
266  (const_cast<IAlgTool*>(algtool))->addRef();
267  registerAlgTool(*algtool).ignore();
268  }
269 
270  m_log << MSG::INFO << "Registered " << m_algtools.size() << " AlgTools"
271  << endmsg;
272 
274 
275  for (auto svc: Gaudi::svcLocator()->getServices()) {
276  svc->addRef();
277  registerSvc(*svc).ignore();
278  }
279 
280  m_log << MSG::INFO;
281  m_log << "Registered " << Gaudi::svcLocator()->getServices().size() << " Services" << endmsg;
282 
283  return StatusCode::SUCCESS;
284 
285 
286 }
virtual const std::vector< const Property * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
virtual const std::vector< Property * > & getProperties() const =0
Get list of properties.
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:28
virtual std::vector< std::string > getClients() const =0
Get the list of clients.
virtual const std::vector< IAlgorithm * > & getAlgorithms() const =0
Return the list of Algorithms.
JobHistory class definition.
Definition: JobHistory.h:25
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
Main interface for the JobOptions service.
GAUDI_API ISvcLocator * svcLocator()
bool m_isInitialized
Definition: HistorySvc.h:104
virtual StatusCode registerSvc(const IService &)
Definition: HistorySvc.cpp:680
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual StatusCode registerAlgTool(const IAlgTool &)
Definition: HistorySvc.cpp:783
JobHistory * m_jobHistory
Definition: HistorySvc.h:124
virtual StatusCode registerAlg(const Algorithm &)
Definition: HistorySvc.cpp:344
void addProperty(const std::string &, const Property *)
Definition: JobHistory.cpp:87
MsgStream m_log
Definition: HistorySvc.h:144
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
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.
Definition: Service.h:142
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
Definition: HistorySvc.h:113
void ignore() const
Definition: StatusCode.h:107
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:22
static const InterfaceID & interfaceID()
Return an instance of InterfaceID identifying the interface.
Definition: IInterface.h:171
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::set< const AlgTool * > m_algtools
Definition: HistorySvc.h:114
virtual StatusCode queryInterface(const InterfaceID &ti, void **pp)=0
Set the void** to the pointer to the requested interface of the instance.
void HistorySvc::clearState ( )
private

Definition at line 127 of file HistorySvc.cpp.

127  {
128  m_algs.clear();
129  clear(m_algmap);
130 
131  m_ialgtools.clear();
132  m_algtools.clear();
133  clear(m_algtoolmap);
134 
135  m_svcs.clear();
136  clear(m_svcmap);
137 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
std::set< const Algorithm * > m_algs
Definition: HistorySvc.h:110
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
std::set< const IService * > m_svcs
Definition: HistorySvc.h:117
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:113
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
std::set< const AlgTool * > m_algtools
Definition: HistorySvc.h:114
DataHistory * HistorySvc::createDataHistoryObj ( const CLID id,
const std::string &  key,
const std::string &  store 
)
virtual

Implements IHistorySvc.

Definition at line 565 of file HistorySvc.cpp.

566  {
567 
568  if (!m_activate) return 0;
569 
570 
571  AlgorithmHistory *algHist;
572 
573  IAlgorithm* ialg = getCurrentIAlg();
574  if (ialg == 0) {
575  ON_DEBUG
576  m_log << MSG::DEBUG
577  << "Could not discover current Algorithm:" << endl
578  << " object CLID: " << id << " key: \"" << key
579  << "\"" << endmsg;
580  algHist = 0;
581  } else {
582  Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
583  if (alg != 0) {
584  algHist = getAlgHistory( *alg );
585  } else {
587  << "Could not extract concrete Algorithm:"
588  << endl
589  << " object CLID: " << id << " key: \"" << key
590  << "\"" << endmsg;
591  algHist = 0;
592  }
593  }
594 
595  DataHistory *hist = new DataHistory(id, key, algHist);
596 
597  return hist;
598 
599 }
AlgorithmHistory class definition.
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:550
bool m_activate
Definition: HistorySvc.h:106
#define ON_DEBUG
Definition: HistorySvc.cpp:35
DataHistory class definition.
Definition: DataHistory.h:25
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:413
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:20
MsgStream m_log
Definition: HistorySvc.h:144
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::string HistorySvc::dumpProp ( const Property prop,
const bool  isXML = false,
int  indent = 0 
) const
private

Definition at line 913 of file HistorySvc.cpp.

913  {
914  std::ostringstream ost;
915  if (isXML) {
916  while (ind > 0) {
917  ost << " ";
918  ind --;
919  }
920  ost << "<PROPERTY name=\"" << prop->name()
921  << "\" value=\"" << HistoryObj::convert_string(prop->toString())
922  << "\" documentation=\"" << HistoryObj::convert_string(prop->documentation())
923  << "\">";
924  } else {
925  prop->fillStream(ost);
926  }
927  return ost.str();
928 }
virtual std::string toString() const =0
value -> string
const std::string & name() const
property name
Definition: Property.h:47
const std::string & documentation() const
property documentation
Definition: Property.h:49
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:182
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:29
void HistorySvc::dumpProperties ( std::ofstream &  ofs) const
private

Definition at line 498 of file HistorySvc.cpp.

498  {
499 
500 
501  ofs << "GLOBAL" << std::endl;
503  JobHistory::PropertyPairList::const_iterator itrj;
504  for (itrj=props.begin(); itrj != props.end(); ++itrj) {
505  std::string client = itrj->first;
506  const Property* prp = itrj->second;
507  ofs << client << " " << dumpProp(prp) << std::endl;
508  }
509 
510  ofs << std::endl << "SERVICES" << std::endl;
511  std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
512  for (itr_s=m_svcmap.begin(); itr_s != m_svcmap.end(); ++itr_s) {
513  const IService* svc = itr_s->first;
514 
515  dumpProperties( *svc, ofs );
516 
517  }
518 
519  ofs << std::endl << "ALGORITHMS" << std::endl;
520  std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
521  for (itr=m_algmap.begin(); itr != m_algmap.end(); ++itr) {
522  const Algorithm* alg = itr->first;
523 
524  dumpProperties( *alg, ofs );
525 
526  }
527 
528  ofs << std::endl << "ALGTOOLS" << std::endl;
529  std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
530  for (itr_a=m_algtoolmap.begin(); itr_a != m_algtoolmap.end(); ++itr_a) {
531  const AlgTool* alg = itr_a->first;
532 
533  dumpProperties( *alg, ofs );
534 
535  }
536 
537 
538 }
std::vector< std::pair< std::string, const Property * > > PropertyPairList
Definition: JobHistory.h:29
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
General service interface definition.
Definition: IService.h:19
JobHistory * m_jobHistory
Definition: HistorySvc.h:124
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:80
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:913
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:498
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:34
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
void HistorySvc::dumpProperties ( const IService svc,
std::ofstream &  ofs 
) const
private

Definition at line 766 of file HistorySvc.cpp.

766  {
767 
768  ServiceHistory *hist = getServiceHistory( svc );
769 
770  if (hist == 0) {
771  return;
772  }
773 
774  for (auto &prop: hist->properties()) {
775  ofs << svc.name() << " " << dumpProp(prop) << std::endl;
776  }
777 
778 }
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:716
virtual const std::string & name() const =0
Retrieve the name of the instance.
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:913
const PropertyList & properties() const
ServiceHistory class definition.
void HistorySvc::dumpProperties ( const Algorithm alg,
std::ofstream &  ofs 
) const
private

Definition at line 396 of file HistorySvc.cpp.

396  {
397 
398  AlgorithmHistory *hist = getAlgHistory( alg );
399 
400  if (hist == 0) {
401  return;
402  }
403 
404  PropertyList::const_iterator itr;
405  for (auto prop: hist->properties()) {
406  ofs << alg.name() << " " << dumpProp(prop) << std::endl;
407  }
408 
409 }
AlgorithmHistory class definition.
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:413
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:913
const PropertyList & properties() const
void HistorySvc::dumpProperties ( const IAlgTool alg,
std::ofstream &  ofs 
) const
private

Definition at line 854 of file HistorySvc.cpp.

854  {
855 
856  AlgToolHistory *hist = getAlgToolHistory( alg );
857 
858  if (hist == 0) {
859  return;
860  }
861 
862  for (auto& prop: hist->properties()) {
863  ofs << alg.name() << " " << dumpProp(prop) << std::endl;
864  }
865 
866 }
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:871
const PropertyList & properties() const
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:913
AlgToolHistory class definition.
void HistorySvc::dumpState ( std::ofstream &  ofs) const
private

Definition at line 933 of file HistorySvc.cpp.

933  {
934 
935 
936  if(m_outputFileTypeXML) {
937  //xml header
938  ofs << "<?xml version=\"1.0\" ?> " << std::endl;
939  ofs << "<!--Test-xml-->" << std::endl;
940  ofs << "<SETUP>" << std::endl;
941  ofs << " <GLOBAL>" << std::endl;
942  } else {
943  ofs << "GLOBAL" << std::endl;
944  }
945 
946  std::string client_currently_open = "start";
947  for (auto& item: m_jobHistory->propertyPairs()) {
948  // client is the name of the component of the current property
949  const std::string& client = item.first;
950  const Property* prp = item.second;
951 
952  if (m_outputFileTypeXML) {
953 
954  if (client != client_currently_open) {
955  if(client_currently_open!="start") ofs << " </COMPONENT>" << endl;
956  ofs << " <COMPONENT name=\""
957  << client << "\" class=\"undefined\">" << std::endl;
958  }
959  } else {
960  ofs << client << " ";
961  }
962 
963  ofs << dumpProp(prp,m_outputFileTypeXML,6) << endl;
964 
965  client_currently_open = client;
966 
968  ofs << " </COMPONENT>" << endl;
969  }
970 
971 
972  if(m_outputFileTypeXML) {
973  ofs << "</GLOBAL>" << endl << "<SERVICES>" << endl;
974  } else {
975  ofs << "SERVICES" << std::endl;
976  }
977 
978  for (auto& item: m_svcmap) {
979  const IService* svc = item.first;
980  dumpState(svc, ofs);
981  }
982 
983  if(m_outputFileTypeXML) {
984  ofs << "</SERVICES>" << endl << "<ALGORITHMS> " << endl;
985  } else {
986  ofs << "ALGORITHMS" << std::endl;
987  }
988 
989  for (auto& item: m_algmap) {
990  const Algorithm* alg = item.first;
991  dumpState(alg, ofs);
992  }
993 
994 
995  if(m_outputFileTypeXML) {
996  ofs << "</ALGORITHMS>" << endl << "<ALGTOOLS> " << endl;
997  } else {
998  ofs << "ALGTOOLS" << std::endl;
999  }
1000 
1001  for (auto& item: m_algtoolmap) {
1002  const AlgTool* algtool = item.first;
1003  dumpState(algtool, ofs);
1004  }
1005 
1006  if(m_outputFileTypeXML) {
1007  ofs << "</ALGTOOLS>" << endl << "</SETUP>" << endl;
1008  }
1009 
1010 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
General service interface definition.
Definition: IService.h:19
bool m_outputFileTypeXML
Definition: HistorySvc.h:145
JobHistory * m_jobHistory
Definition: HistorySvc.h:124
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:80
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:913
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:933
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:43
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:34
tuple item
print s1,s2
Definition: ana.py:146
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
void HistorySvc::dumpState ( const INamedInterface in,
std::ofstream &  ofs 
) const
private

Definition at line 1015 of file HistorySvc.cpp.

1015  {
1016 
1017  HistoryObj *hist(0);
1018  IVersHistoryObj *vhist(0);
1019 
1020  const IService* is(0);
1021  const Algorithm* ia(0);
1022  const IAlgTool* it(0);
1023  if ( (is=dynamic_cast<const IService*>(in)) != 0) {
1024  ON_VERBOSE
1025  m_log << MSG::VERBOSE << in->name() << " is Service" << endmsg;
1026  ServiceHistory* o = getServiceHistory( *is );
1027  hist = dynamic_cast<HistoryObj*>( o );
1028  vhist = dynamic_cast<IVersHistoryObj*>( o );
1029  } else if ( (ia = dynamic_cast<const Algorithm*>(in)) != 0 ) {
1030  ON_VERBOSE
1031  m_log << MSG::VERBOSE << in->name() << " is Alg" << endmsg;
1032  AlgorithmHistory *o = getAlgHistory( *ia );
1033  hist = dynamic_cast<HistoryObj*>( o );
1034  vhist = dynamic_cast<IVersHistoryObj*>( o );
1035  } else if ( (it = dynamic_cast<const IAlgTool*>(in)) != 0 ) {
1036  ON_VERBOSE
1037  m_log << MSG::VERBOSE << in->name() << " is AlgTool" << endmsg;
1038  AlgToolHistory *o = getAlgToolHistory( *it );
1039  hist = dynamic_cast<HistoryObj*>( o );
1040  vhist = dynamic_cast<IVersHistoryObj*>( o );
1041  } else {
1042  m_log << MSG::ERROR
1043  << "Could not dcast interface to accepted History Obj type for "
1044  << in->name() << endmsg;
1045  return;
1046  }
1047 
1048  if (hist == 0 || vhist == 0) {
1049  m_log << MSG::ERROR << "Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
1050  << endmsg;
1051  return;
1052  }
1053 
1054  if (m_outputFileTypeXML) {
1055  hist->dump(ofs,true);
1056  } else {
1057  ofs << ">> " << vhist->name() << endl << *hist << endl;
1058  }
1059 
1060 }
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:716
AlgorithmHistory class definition.
Base class for History Objects.
Definition: HistoryObj.h:24
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:871
General service interface definition.
Definition: IService.h:19
bool m_outputFileTypeXML
Definition: HistorySvc.h:145
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:413
MsgStream m_log
Definition: HistorySvc.h:144
AlgToolHistory class definition.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ServiceHistory class definition.
#define ON_VERBOSE
Definition: HistorySvc.cpp:36
Interface for Versioned History Objects.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode HistorySvc::finalize ( )
virtual

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from Service.

Definition at line 321 of file HistorySvc.cpp.

321  {
322 
323  ON_VERBOSE
324  m_log << MSG::VERBOSE << "HistorySvc::finalize()" << endmsg;
325 
326 
327  clearState();
328 
329  StatusCode status = Service::finalize();
330 
331  if ( status.isSuccess() )
332  m_log << MSG::INFO << "Service finalised successfully" << endmsg;
333 
334  return status;
335 
336 }
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
MsgStream m_log
Definition: HistorySvc.h:144
#define ON_VERBOSE
Definition: HistorySvc.cpp:36
void clearState()
Definition: HistorySvc.cpp:127
virtual StatusCode finalize()
Finalize (from INITIALIZED to CONFIGURED).
Definition: Service.cpp:199
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
AlgorithmHistory * HistorySvc::getAlgHistory ( const Algorithm alg) const
virtual

Implements IHistorySvc.

Definition at line 413 of file HistorySvc.cpp.

413  {
414 
415  const Algorithm *palg = &alg;
416  set<const Algorithm*>::const_iterator itr = m_algs.find(palg);
417  if ( itr == m_algs.end() ) {
418  m_log << MSG::WARNING << "Algorithm " << alg.name() << " not registered"
419  << endmsg;
420  return 0;
421  }
422 
423  map<const Algorithm*, AlgorithmHistory*>::const_iterator itr2;
424  itr2 = m_algmap.find( *itr );
425 
426  return ( itr2->second );
427 
428 }
std::set< const Algorithm * > m_algs
Definition: HistorySvc.h:110
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
MsgStream m_log
Definition: HistorySvc.h:144
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void HistorySvc::getAlgHistory ( std::set< AlgorithmHistory * > &  algs) const
virtual

Implements IHistorySvc.

Definition at line 432 of file HistorySvc.cpp.

432  {
433  map_to_set(m_algmap, algs);
434 }
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
AlgToolHistory * HistorySvc::getAlgToolHistory ( const IAlgTool alg) const
virtual

Implements IHistorySvc.

Definition at line 871 of file HistorySvc.cpp.

871  {
872 
873  const AlgTool *palg = dynamic_cast<const AlgTool*>(&alg);
874  set<const AlgTool*>::const_iterator itr = m_algtools.find(palg);
875  if ( itr == m_algtools.end() ) {
876  m_log << MSG::WARNING << "AlgTool " << alg.name() << " not registered"
877  << endmsg;
878  return 0;
879  }
880 
881  map<const AlgTool*, AlgToolHistory*>::const_iterator itr2;
882  itr2 = m_algtoolmap.find( *itr );
883 
884  return ( itr2->second );
885 
886 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
virtual const std::string & name() const =0
Retrieve the name of the instance.
MsgStream m_log
Definition: HistorySvc.h:144
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:34
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::set< const AlgTool * > m_algtools
Definition: HistorySvc.h:114
void HistorySvc::getAlgToolHistory ( std::set< AlgToolHistory * > &  algs) const
virtual

Implements IHistorySvc.

Definition at line 891 of file HistorySvc.cpp.

891  {
892  map_to_set(m_algtoolmap, algs);
893 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
IAlgorithm * HistorySvc::getCurrentIAlg ( ) const
private

Definition at line 550 of file HistorySvc.cpp.

550  {
551  if (p_algCtxSvc == 0) {
552  m_log << MSG::WARNING << "trying to create DataHistoryObj before "
553  << "HistorySvc has been initialized" << endmsg;
554  return 0;
555 
556  } else {
557  return p_algCtxSvc->currentAlg();
558  }
559 }
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
MsgStream m_log
Definition: HistorySvc.h:144
virtual IAlgorithm * currentAlg() const =0
accessor to current algorithm:
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
DataHistory * HistorySvc::getDataHistory ( const CLID id,
const std::string &  key,
const std::string &  store 
) const
virtual

Implements IHistorySvc.

Definition at line 640 of file HistorySvc.cpp.

641  {
642 
643  DHH dhh(id,key);
644 
645  pair<DHMCitr,DHMCitr> mitr = m_datMap.equal_range(dhh);
646 
647  if(mitr.first == mitr.second) {
648  return 0;
649  }
650 
651  return mitr.first->second;
652 
653 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:120
int HistorySvc::getDataHistory ( const CLID id,
const std::string &  key,
const std::string &  storeName,
std::list< DataHistory * > &  dhlist 
) const
virtual

Definition at line 658 of file HistorySvc.cpp.

660  {
661 
662  DHH dhh(id,key);
663 
664  int n(0);
665 
666  pair<DHMCitr,DHMCitr> mitr = m_datMap.equal_range(dhh);
667 
668  for (DHMCitr itr=mitr.first; itr != mitr.second; ++itr) {
669  dhlist.push_back(itr->second);
670  n++;
671  }
672 
673  return n;
674 
675 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:120
DataHistMap::const_iterator DHMCitr
Definition: HistorySvc.h:100
JobHistory * HistorySvc::getJobHistory ( ) const
virtual

Implements IHistorySvc.

Definition at line 542 of file HistorySvc.cpp.

542  {
543 
544  return m_jobHistory;
545 
546 }
JobHistory * m_jobHistory
Definition: HistorySvc.h:124
ServiceHistory * HistorySvc::getServiceHistory ( const IService svc) const
virtual

Implements IHistorySvc.

Definition at line 716 of file HistorySvc.cpp.

716  {
717 
718  const IService *psvc = &svc;
719  map<const IService*, ServiceHistory*>::const_iterator itr =
720  m_svcmap.find(psvc);
721  if ( itr == m_svcmap.end() ) {
722  m_log << MSG::WARNING << "Service " << svc.name() << " not registered"
723  << endmsg;
724  return 0;
725  }
726 
727  return ( itr->second );
728 
729 }
virtual const std::string & name() const =0
Retrieve the name of the instance.
General service interface definition.
Definition: IService.h:19
MsgStream m_log
Definition: HistorySvc.h:144
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void HistorySvc::getServiceHistory ( std::set< ServiceHistory * > &  svcs) const
virtual

Implements IHistorySvc.

Definition at line 733 of file HistorySvc.cpp.

733  {
734  map_to_set(m_svcmap, svcs);
735 }
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
void HistorySvc::handle ( const Incident )
virtual

Inform that a new incident has occurred.

Implements IIncidentListener.

Definition at line 898 of file HistorySvc.cpp.

898  {
899 
900  if (incident.type() == IncidentType::BeginEvent) {
901  if (captureState().isFailure()) {
902  m_log << MSG::WARNING << "Error capturing state." << endl
903  << "Will try again at next BeginEvent incident" << endmsg;
904  }
905  }
906 
907 }
const std::string BeginEvent
Processing of a new event has started.
Definition: Incident.h:60
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
MsgStream m_log
Definition: HistorySvc.h:144
virtual StatusCode captureState()
Definition: HistorySvc.cpp:201
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode HistorySvc::initialize ( )
virtual

Initialization (from CONFIGURED to INITIALIZED).

Reimplemented from Service.

Definition at line 142 of file HistorySvc.cpp.

142  {
143 
144  StatusCode status = Service::initialize();
146 
147  if (status.isFailure()) {
148 
149  ON_DEBUG
150  m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
151  << endmsg;
152  return status;
153  }
154 
155  ON_DEBUG
156  m_log << MSG::DEBUG << "Initializing HistorySvc" << endmsg;
157 
158  if (!m_activate) return StatusCode::SUCCESS;
159 
160  static const bool CREATEIF(true);
161 
162  if ( service("AlgContextSvc",p_algCtxSvc,CREATEIF).isFailure() ) {
163  m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
164  return StatusCode::FAILURE;
165  }
166 
167  if (service("IncidentSvc", m_incidentSvc, CREATEIF).isFailure()) {
168  m_log << MSG::ERROR << "unable to get the IncidentSvc" << endmsg;
169  return StatusCode::FAILURE;
170  }
171 
172  // create a weak dependency on the ToolSvc, so that it doesn't get deleted
173  // before we're done with it in finalize
174  m_toolSvc = serviceLocator()->service("ToolSvc");
175  if (! m_toolSvc) {
176  m_log << MSG::ERROR << "could not retrieve the ToolSvc handle !"
177  << endmsg;
178  return StatusCode::FAILURE;
179  }
180 
181  // add listener to be triggered by first BeginEvent with low priority
182  // so it gets called first
183  const bool rethrow = false;
184  const bool oneShot = true; // make the listener called only once
186  std::numeric_limits<long>::min(),rethrow,oneShot);
187 
188  if (m_outputFile.find(".XML") != string::npos || m_outputFile.find(".xml") != string::npos) {
189  ON_DEBUG
190  m_log << MSG::DEBUG << "output format is XML" << endmsg;
191  m_outputFileTypeXML = true;
192  }
193 
194  m_isInitialized = true;
195 
196  return StatusCode::SUCCESS;
197 
198 }
const std::string BeginEvent
Processing of a new event has started.
Definition: Incident.h:60
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:243
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:142
std::string m_outputFile
Definition: HistorySvc.h:126
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:85
bool m_activate
Definition: HistorySvc.h:106
bool m_isInitialized
Definition: HistorySvc.h:104
#define ON_DEBUG
Definition: HistorySvc.cpp:35
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
bool m_outputFileTypeXML
Definition: HistorySvc.h:145
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
MsgStream m_log
Definition: HistorySvc.h:144
const TYPE & value() const
explicit conversion
Definition: Property.h:355
#define min(a, b)
IIncidentSvc * m_incidentSvc
Definition: HistorySvc.h:141
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: Service.cpp:74
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.
Definition: MsgStream.h:106
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.
Definition: Service.h:142
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.
Definition: Service.cpp:336
StatusCode HistorySvc::listProperties ( ) const
virtual

Implements IHistorySvc.

Definition at line 450 of file HistorySvc.cpp.

450  {
451 
452  m_log << MSG::INFO;
454  m_log << "Dumping properties for all Algorithms (" << m_algmap.size()
455  << ")" << endmsg;
456 
457  for (auto& alg: m_algmap) {
458  listProperties(*alg.first).ignore();
459  }
460 
461  m_log << MSG::INFO;
463  m_log << "Dumping properties for all AlgTools (" << m_algtoolmap.size()
464  << ")" << endmsg;
465 
466  for (auto& algtool: m_algtoolmap) {
467  ON_DEBUG
468  m_log << MSG::DEBUG << " --> " << algtool.second->algtool_name() << endmsg;
469  listProperties(*algtool.first).ignore();
470  }
471 
472  m_log << MSG::INFO;
474  m_log << "Dumping properties for all Services (" << m_svcmap.size()
475  << ")" << endmsg;
476 
477  for (auto& svc: m_svcmap) {
478  listProperties(*svc.first).ignore();
479  }
480 
481  m_log << MSG::INFO;
483  m_log << "Dumping properties for Job";
484  m_log.resetColor();
485 
486  ostringstream ost;
487  ost << *m_jobHistory;
488  std::string str = ost.str();
489 
490  m_log << std::endl << str << endmsg;
491 
492  return StatusCode(StatusCode::SUCCESS,true);
493 
494 }
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:117
virtual StatusCode listProperties() const
Definition: HistorySvc.cpp:450
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:90
#define ON_DEBUG
Definition: HistorySvc.cpp:35
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
JobHistory * m_jobHistory
Definition: HistorySvc.h:124
MsgStream m_log
Definition: HistorySvc.h:144
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
void ignore() const
Definition: StatusCode.h:107
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode HistorySvc::listProperties ( const IService svc) const
virtual

Implements IHistorySvc.

Definition at line 740 of file HistorySvc.cpp.

740  {
741 
742  m_log << MSG::INFO << "Dumping properties for " << svc.name() << endl;
743 
744  ServiceHistory *hist = getServiceHistory( svc );
745 
746  if (hist == 0) {
747  return StatusCode::FAILURE;
748  }
749 
750  ostringstream ost;
751  ost << *hist;
752 
753  std::string str = ost.str();
754 
755  m_log << MSG::INFO << svc.name() << " --> " << endl << str << endmsg;
756 
757 
758 
759  return StatusCode(StatusCode::SUCCESS,true);
760 
761 }
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:716
virtual const std::string & name() const =0
Retrieve the name of the instance.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
MsgStream m_log
Definition: HistorySvc.h:144
ServiceHistory class definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode HistorySvc::listProperties ( const Algorithm alg) const
virtual

Implements IHistorySvc.

Definition at line 373 of file HistorySvc.cpp.

373  {
374 
375  m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
376 
377  AlgorithmHistory *hist = getAlgHistory( alg );
378 
379  if (hist == 0) {
380  return StatusCode::FAILURE;
381  }
382 
383  ostringstream ost;
384  ost << *hist;
385 
386  std::string str = ost.str();
387 
388  m_log << MSG::INFO << alg.name() << " --> " << endl << str << endmsg;
389 
390  return StatusCode(StatusCode::SUCCESS,true);
391 
392 }
AlgorithmHistory class definition.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:413
MsgStream m_log
Definition: HistorySvc.h:144
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode HistorySvc::listProperties ( const IAlgTool alg) const
virtual

Implements IHistorySvc.

Definition at line 831 of file HistorySvc.cpp.

831  {
832 
833  m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
834 
835  AlgToolHistory *hist = getAlgToolHistory( alg );
836 
837  if (hist == 0) {
838  return StatusCode::FAILURE;
839  }
840 
841  ostringstream ost;
842  ost << *hist;
843 
844  std::string str = ost.str();
845 
846  m_log << MSG::INFO << alg.name() << " --> " << endl << str << endmsg;
847 
848  return StatusCode::SUCCESS;
849 
850 }
virtual const std::string & name() const =0
Retrieve the name of the instance.
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:871
MsgStream m_log
Definition: HistorySvc.h:144
AlgToolHistory class definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode HistorySvc::registerAlg ( const Algorithm alg)
virtual

Implements IHistorySvc.

Definition at line 344 of file HistorySvc.cpp.

344  {
345 
346  JobHistory *job = getJobHistory();
347  if (m_algmap.find(&alg) != m_algmap.end()) {
348  m_log << MSG::WARNING << "Algorithm " << alg.name()
349  << " already registered with HistorySvc" << endmsg;
350  return StatusCode::SUCCESS;
351  }
352 
353  (const_cast<Algorithm*>(&alg))->addRef();
354 
355  m_algs.insert(&alg);
356 
357  AlgorithmHistory *algHist = new AlgorithmHistory(alg, job);
358  m_algmap[&alg] = algHist;
359 
360  ON_DEBUG {
361  m_log << MSG::DEBUG << "Registering algorithm: ";
363  m_log << alg.name() << endmsg;
364  m_log.resetColor();
365  }
366 
367  return StatusCode(StatusCode::SUCCESS,true);
368 
369 }
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:117
AlgorithmHistory class definition.
JobHistory class definition.
Definition: JobHistory.h:25
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:90
std::set< const Algorithm * > m_algs
Definition: HistorySvc.h:110
#define ON_DEBUG
Definition: HistorySvc.cpp:35
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
virtual const std::string & name() const
The identifying name of the algorithm object.
Definition: Algorithm.cpp:837
MsgStream m_log
Definition: HistorySvc.h:144
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:61
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:111
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:542
StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg)
virtual

Implements IHistorySvc.

Definition at line 783 of file HistorySvc.cpp.

783  {
784 
785  if (! m_isInitialized) {
786  if (p_algCtxSvc == 0) {
787  if ( service("AlgContextSvc",p_algCtxSvc,true).isFailure() ) {
788  m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
789  return StatusCode::FAILURE;
790  }
791  }
792 
793  m_ialgtools.insert(&ialg);
794  return StatusCode::SUCCESS;
795  }
796 
797  const AlgTool *alg = dynamic_cast<const AlgTool*>( &ialg );
798  if ( alg == 0 ) {
799  m_log << MSG::ERROR << "Could not dcast IAlgTool \"" << ialg.name()
800  << "\" to an AlgTool" << endmsg;
801  return StatusCode::FAILURE;
802  }
803 
804  if (m_algtools.find(alg) != m_algtools.end()) {
805  m_log << MSG::WARNING << "AlgTool " << ialg.name()
806  << " already registered in HistorySvc" << endmsg;
807  return StatusCode::SUCCESS;
808  }
809 
810  m_algtools.insert(alg);
811  (const_cast<AlgTool*>(alg))->addRef();
812 
813  const JobHistory *job = getJobHistory();
814  AlgToolHistory *algHist = new AlgToolHistory(*alg, job);
815  m_algtoolmap[alg] = algHist;
816 
817  if (m_log.level() <= MSG::DEBUG) {
818  m_log << MSG::DEBUG << "Registering algtool: ";
820  m_log << alg->name() << endmsg;
821  m_log.resetColor();
822  }
823 
824  return StatusCode::SUCCESS;
825 
826 }
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:117
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:115
JobHistory class definition.
Definition: JobHistory.h:25
virtual const std::string & name() const =0
Retrieve the name of the instance.
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:90
bool m_isInitialized
Definition: HistorySvc.h:104
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
MsgStream m_log
Definition: HistorySvc.h:144
AlgToolHistory class definition.
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:34
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.
Definition: Service.h:142
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:113
virtual const std::string & name() const
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:51
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::set< const AlgTool * > m_algtools
Definition: HistorySvc.h:114
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:542
StatusCode HistorySvc::registerDataHistory ( const CLID id,
const std::string &  key,
const std::string &  store 
)
virtual

Definition at line 603 of file HistorySvc.cpp.

604  {
605 
606  DHH dhh(id,key);
607 
608  auto boundaries = m_datMap.equal_range(dhh);
609  auto match = boundaries.second;
610 
611  if (boundaries.first != boundaries.second) {
612  // there is something in the map, let's look for the specific entry
613 
614  std::string algName;
615  IAlgorithm *ialg = getCurrentIAlg();
616  if (ialg) {
617  algName = ialg->name();
618  } else {
619  algName = "UNKNOWN";
620  }
621 
622  match = std::find_if(boundaries.first, boundaries.second,
623  [&algName](decltype(boundaries)::first_type::reference p) -> bool {
624  return p.second->algorithmHistory()->algorithm_name() == algName;
625  });
626  }
627 
628  if (match == boundaries.second) { // not found, crete the entry
629  DataHistory *dh = createDataHistoryObj(id, key, storeName);
630  m_datMap.insert(pair<DHH, DataHistory*>(dhh,dh));
631  }
632 
633  return StatusCode::SUCCESS;
634 
635 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:120
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:550
virtual const std::string & name() const =0
Retrieve the name of the instance.
DataHistory class definition.
Definition: DataHistory.h:25
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:20
virtual DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store)
Definition: HistorySvc.cpp:565
TO * reference(FROM *from)
Definition: KeyedObject.cpp:21
StatusCode HistorySvc::registerJob ( )
virtual

Implements IHistorySvc.

Definition at line 439 of file HistorySvc.cpp.

439  {
440 
441 
442  return StatusCode(StatusCode::SUCCESS,true);
443 
444 
445 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
StatusCode HistorySvc::registerSvc ( const IService svc)
virtual

Implements IHistorySvc.

Definition at line 680 of file HistorySvc.cpp.

680  {
681 
682  if ( svc.name() == "HistoryStore" ) {
683  // m_log << MSG::WARNING << "not registering store" << endmsg;
684  return StatusCode(StatusCode::SUCCESS,true);
685  }
686 
687  JobHistory *job = getJobHistory();
688  const IService* psvc = &svc;
689  map<const IService*, ServiceHistory*>::const_iterator itr =
690  m_svcmap.find(psvc);
691  if (itr == m_svcmap.end()) {
692 
693  if (m_log.level() <= MSG::DEBUG) {
694  m_log << MSG::DEBUG << "Registering Service: ";
696  m_log << svc.name() << endmsg;
697  }
698 
699  m_svcs.insert(psvc);
700 
701  ServiceHistory *svcHist = new ServiceHistory(&svc, job);
702  m_svcmap[psvc] = svcHist;
703 
704  (const_cast<IService*>(psvc))->addRef();
705 
706  }
707 
708  m_log.resetColor();
709  return StatusCode(StatusCode::SUCCESS,true);
710 
711 }
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:117
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
JobHistory class definition.
Definition: JobHistory.h:25
virtual const std::string & name() const =0
Retrieve the name of the instance.
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:90
virtual unsigned long addRef()
Add reference to object.
Definition: DataObject.cpp:53
General service interface definition.
Definition: IService.h:19
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:30
MsgStream m_log
Definition: HistorySvc.h:144
ServiceHistory class definition.
std::set< const IService * > m_svcs
Definition: HistorySvc.h:117
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:118
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:542
StatusCode HistorySvc::reinitialize ( )
virtual

Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).

Reimplemented from Service.

Definition at line 102 of file HistorySvc.cpp.

102  {
103 
104  clearState();
105 
107 
108  return initialize();
109 
110 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:245
virtual StatusCode initialize()
Initialization (from CONFIGURED to INITIALIZED).
Definition: HistorySvc.cpp:142
void clearState()
Definition: HistorySvc.cpp:127
StatusCode HistorySvc::stop ( )
virtual

Stop (from RUNNING to INITIALIZED).

Reimplemented from Service.

Definition at line 290 of file HistorySvc.cpp.

290  {
291 
292  if (!m_activate) return StatusCode::SUCCESS;
293 
294  if (m_dump) {
296  }
297 
298  if (m_outputFile != "") {
299  std::ofstream ofs;
300  ofs.open(m_outputFile.c_str());
301  if (!ofs) {
302  m_log << MSG::ERROR << "Unable to open output file \"m_outputFile\""
303  << endmsg;
304  } else {
305 
306  // dumpProperties(ofs);
307  dumpState(ofs);
308 
309  ofs.close();
310  }
311  }
312 
313  clearState();
314 
315  return StatusCode::SUCCESS;
316 
317 }
virtual StatusCode listProperties() const
Definition: HistorySvc.cpp:450
std::string m_outputFile
Definition: HistorySvc.h:126
bool m_activate
Definition: HistorySvc.h:106
MsgStream m_log
Definition: HistorySvc.h:144
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:933
bool m_dump
Definition: HistorySvc.h:105
void ignore() const
Definition: StatusCode.h:107
void clearState()
Definition: HistorySvc.cpp:127
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

Member Data Documentation

bool HistorySvc::m_activate
private

Definition at line 106 of file HistorySvc.h.

std::map<const Algorithm*, AlgorithmHistory*> HistorySvc::m_algmap
private

Definition at line 111 of file HistorySvc.h.

std::set<const Algorithm*> HistorySvc::m_algs
private

Definition at line 110 of file HistorySvc.h.

std::map<const AlgTool*, AlgToolHistory*> HistorySvc::m_algtoolmap
private

Definition at line 115 of file HistorySvc.h.

std::set<const AlgTool*> HistorySvc::m_algtools
private

Definition at line 114 of file HistorySvc.h.

std::multimap<DHH, DataHistory*> HistorySvc::m_datMap
private

Definition at line 120 of file HistorySvc.h.

bool HistorySvc::m_dump
private

Definition at line 105 of file HistorySvc.h.

std::set<const IAlgTool*> HistorySvc::m_ialgtools
private

Definition at line 113 of file HistorySvc.h.

IIncidentSvc* HistorySvc::m_incidentSvc
private

Definition at line 141 of file HistorySvc.h.

bool HistorySvc::m_isInitialized
private

Definition at line 104 of file HistorySvc.h.

JobHistory* HistorySvc::m_jobHistory
private

Definition at line 124 of file HistorySvc.h.

MsgStream HistorySvc::m_log
mutableprivate

Definition at line 144 of file HistorySvc.h.

std::string HistorySvc::m_outputFile
private

Definition at line 126 of file HistorySvc.h.

bool HistorySvc::m_outputFileTypeXML
private

Definition at line 145 of file HistorySvc.h.

std::map<const IService*, ServiceHistory*> HistorySvc::m_svcmap
private

Definition at line 118 of file HistorySvc.h.

std::set<const IService*> HistorySvc::m_svcs
private

Definition at line 117 of file HistorySvc.h.

SmartIF<IToolSvc> HistorySvc::m_toolSvc
private

Definition at line 142 of file HistorySvc.h.

IAlgContextSvc* HistorySvc::p_algCtxSvc
private

Definition at line 108 of file HistorySvc.h.


The documentation for this class was generated from the following files: