The Gaudi Framework  v29r0 (ff2e7097)
HistorySvc Class Reference

HistorySvc class definition. More...

#include <src/HistorySvc.h>

Inheritance diagram for HistorySvc:
Collaboration diagram for HistorySvc:

Public Member Functions

StatusCode initialize () override
 
StatusCode reinitialize () override
 
StatusCode finalize () override
 
StatusCode stop () override
 
virtual StatusCode captureState ()
 
StatusCode registerJob () override
 
StatusCode listProperties () const override
 
JobHistorygetJobHistory () const override
 
StatusCode registerSvc (const IService &) override
 
StatusCode listProperties (const IService &) const override
 
ServiceHistorygetServiceHistory (const IService &) const override
 
void getServiceHistory (std::set< ServiceHistory * > &) const override
 
StatusCode registerAlg (const Algorithm &) override
 
StatusCode listProperties (const Algorithm &) const override
 
AlgorithmHistorygetAlgHistory (const Algorithm &) const override
 
void getAlgHistory (std::set< AlgorithmHistory * > &) const override
 
StatusCode registerAlgTool (const IAlgTool &) override
 
StatusCode listProperties (const IAlgTool &) const override
 
AlgToolHistorygetAlgToolHistory (const IAlgTool &) const override
 
void getAlgToolHistory (std::set< AlgToolHistory * > &) const override
 
DataHistorycreateDataHistoryObj (const CLID &id, const std::string &key, const std::string &store) override
 
virtual StatusCode registerDataHistory (const CLID &id, const std::string &key, const std::string &store)
 
DataHistorygetDataHistory (const CLID &id, const std::string &key, const std::string &store) const override
 
virtual int getDataHistory (const CLID &id, const std::string &key, const std::string &storeName, std::list< DataHistory * > &dhlist) const
 
void handle (const Incident &inc) override
 
 ~HistorySvc () override=default
 
- Public Member Functions inherited from extends< Service, IHistorySvc, IIncidentListener >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 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<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, 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 >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
 ~PropertyHolder () override=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
 Specializations for various GaudiHandles. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 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...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces... >
 ~extend_interfaces () override=default
 Virtual destructor. 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 Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
 
IAlgorithmgetCurrentIAlg () const
 

Private Attributes

Gaudi::Property< bool > m_dump {this, "Dump", false}
 
Gaudi::Property< bool > m_activate {this, "Activate", true}
 
Gaudi::Property< std::stringm_outputFile {this, "OutputFile"}
 
bool m_isInitialized = false
 
IAlgContextSvcp_algCtxSvc = nullptr
 
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
 
std::set< const IAlgTool * > m_ialgtools
 
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
 
std::map< const IService *, ServiceHistory * > m_svcmap
 
std::multimap< DHH, DataHistory * > m_datMap
 
std::unique_ptr< JobHistorym_jobHistory
 
IIncidentSvcm_incidentSvc = nullptr
 
SmartIF< IToolSvcm_toolSvc
 
bool m_outputFileTypeXML = false
 

Additional Inherited Members

- Public Types inherited from extends< Service, IHistorySvc, IIncidentListener >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Detailed Description

HistorySvc class definition.

Definition at line 36 of file HistorySvc.h.

Member Typedef Documentation

Definition at line 84 of file HistorySvc.h.

typedef DataHistMap::const_iterator HistorySvc::DHMCitr
private

Definition at line 86 of file HistorySvc.h.

typedef DataHistMap::iterator HistorySvc::DHMitr
private

Definition at line 85 of file HistorySvc.h.

Definition at line 82 of file HistorySvc.h.

Constructor & Destructor Documentation

HistorySvc::~HistorySvc ( )
overridedefault

Member Function Documentation

StatusCode HistorySvc::captureState ( )
virtual

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 169 of file HistorySvc.cpp.

170 {
171 
172  if ( !m_jobHistory ) {
174  IJobOptionsSvc* jo;
175  if ( service( "JobOptionsSvc", jo ).isFailure() ) {
176  error() << "Could not get jobOptionsSvc - "
177  << "not adding properties to JobHistory" << endmsg;
178  } else {
179 
180  bool foundAppMgr( false );
181 
182  for ( auto& client : jo->getClients() ) {
183  if ( client == "ApplicationMgr" ) foundAppMgr = true;
184  for ( auto prop : *jo->getProperties( client ) ) {
185  m_jobHistory->addProperty( client, prop );
186  }
187  }
188 
189  if ( !foundAppMgr ) {
190  auto ap = service<IProperty>( "ApplicationMgr" );
191  if ( !ap ) {
192  error() << "could not get the ApplicationMgr" << endmsg;
193  } else {
194  for ( auto prop : ap->getProperties() ) {
195  m_jobHistory->addProperty( "ApplicationMgr", prop );
196  }
197  }
198  }
199  }
200  }
201 
203 
204  auto algMgr = Gaudi::svcLocator()->as<IAlgManager>();
205  if ( !algMgr ) {
206  error() << "Could not get AlgManager" << endmsg;
207  return StatusCode::FAILURE;
208  }
209 
210  size_t count = 0;
211  for ( auto ialg : algMgr->getAlgorithms() ) {
212  Algorithm* alg = dynamic_cast<Algorithm*>( ialg );
213  if ( !alg ) {
214  warning() << "Algorithm " << ialg->name() << " does not inherit from Algorithm. Not registering it." << endmsg;
215  } else {
216  ++count;
217  registerAlg( *alg ).ignore();
218  }
219  }
220 
221  info() << "Registered " << count << " Algorithms" << endmsg;
222 
224 
225  m_isInitialized = true;
226  for ( auto algtool : m_ialgtools ) {
227  ( const_cast<IAlgTool*>( algtool ) )->addRef();
228  registerAlgTool( *algtool ).ignore();
229  }
230 
231  info() << "Registered " << m_algtoolmap.size() << " AlgTools" << endmsg;
232 
234 
235  for ( auto svc : Gaudi::svcLocator()->getServices() ) {
236  svc->addRef();
237  registerSvc( *svc ).ignore();
238  }
239 
240  info() << "Registered " << Gaudi::svcLocator()->getServices().size() << " Services" << endmsg;
241 
242  return StatusCode::SUCCESS;
243 }
StatusCode registerSvc(const IService &) override
Definition: HistorySvc.cpp:535
StatusCode registerAlgTool(const IAlgTool &) override
Definition: HistorySvc.cpp:612
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode registerAlg(const Algorithm &) override
Definition: HistorySvc.cpp:293
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
JobHistory class definition.
Definition: JobHistory.h:22
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
void addProperty(const std::string &, const Gaudi::Details::PropertyBase *)
Definition: JobHistory.cpp:85
Main interface for the JobOptions service.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
GAUDI_API ISvcLocator * svcLocator()
bool m_isInitialized
Definition: HistorySvc.h:94
virtual std::vector< std::string > getClients() const =0
Get the list of clients.
T reset(T...args)
virtual const std::vector< const Gaudi::Details::PropertyBase * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
T count(T...args)
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
T size(T...args)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
virtual const std::list< IService * > & getServices() const =0
Get a reference to a service and create it if it does not exists.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:100
void ignore() const
Definition: StatusCode.h:109
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:106
void HistorySvc::clearState ( )
private

Definition at line 107 of file HistorySvc.cpp.

108 {
109  clear( m_algmap );
110 
111  m_ialgtools.clear();
112  clear( m_algtoolmap );
113 
114  clear( m_svcmap );
115 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
T clear(T...args)
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:100
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
DataHistory * HistorySvc::createDataHistoryObj ( const CLID id,
const std::string key,
const std::string store 
)
override

Definition at line 443 of file HistorySvc.cpp.

445 {
446 
447  if ( !m_activate ) return nullptr;
448 
449  AlgorithmHistory* algHist = nullptr;
450 
451  IAlgorithm* ialg = getCurrentIAlg();
452  if ( !ialg ) {
453  ON_DEBUG
454  debug() << "Could not discover current Algorithm:" << endl
455  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
456  algHist = nullptr;
457  } else {
458  Algorithm* alg = dynamic_cast<Algorithm*>( ialg );
459  if ( alg ) {
460  algHist = getAlgHistory( *alg );
461  } else {
462  warning() << "Could not extract concrete Algorithm:" << endl
463  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
464  algHist = nullptr;
465  }
466  }
467  return new DataHistory( id, key, algHist );
468 }
AlgorithmHistory class definition.
T endl(T...args)
AlgorithmHistory * getAlgHistory(const Algorithm &) const override
Definition: HistorySvc.cpp:352
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:433
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
#define ON_DEBUG
Definition: HistorySvc.cpp:40
DataHistory class definition.
Definition: DataHistory.h:23
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:89
std::string HistorySvc::dumpProp ( const Gaudi::Details::PropertyBase prop,
const bool  isXML = false,
int  indent = 0 
) const
private

Definition at line 713 of file HistorySvc.cpp.

714 {
715  std::ostringstream ost;
716  if ( isXML ) {
717  while ( ind > 0 ) {
718  ost << " ";
719  ind--;
720  }
721  ost << "<PROPERTY name=\"" << prop->name() << "\" value=\"" << HistoryObj::convert_string( prop->toString() )
722  << "\" documentation=\"" << HistoryObj::convert_string( prop->documentation() ) << "\">";
723  } else {
724  prop->fillStream( ost );
725  }
726  return ost.str();
727 }
const std::string name() const
property name
Definition: Property.h:40
virtual std::string toString() const =0
value -> string
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:52
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:20
std::string documentation() const
property documentation
Definition: Property.h:42
void HistorySvc::dumpProperties ( std::ofstream ofs) const
private

Definition at line 411 of file HistorySvc.cpp.

412 {
413 
414  ofs << "GLOBAL" << std::endl;
415  for ( const auto& prop : m_jobHistory->propertyPairs() ) {
416  ofs << prop.first << " " << dumpProp( prop.second ) << std::endl;
417  }
418 
419  ofs << std::endl << "SERVICES" << std::endl;
420  for ( const auto& s : m_svcmap ) dumpProperties( *s.first, ofs );
421 
422  ofs << std::endl << "ALGORITHMS" << std::endl;
423  for ( const auto& alg : m_algmap ) dumpProperties( *alg.first, ofs );
424 
425  ofs << std::endl << "ALGTOOLS" << std::endl;
426  for ( const auto& tool : m_algtoolmap ) dumpProperties( *tool.first, ofs );
427 }
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:713
T endl(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:72
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:411
string s
Definition: gaudirun.py:253
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:106
void HistorySvc::dumpProperties ( const IService svc,
std::ofstream ofs 
) const
private

Definition at line 598 of file HistorySvc.cpp.

599 {
600 
601  ServiceHistory* hist = getServiceHistory( svc );
602 
603  if ( !hist ) return;
604 
605  for ( auto& prop : hist->properties() ) {
606  ofs << svc.name() << " " << dumpProp( prop ) << std::endl;
607  }
608 }
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:713
T endl(T...args)
const PropertyList & properties() const override
ServiceHistory class definition.
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:566
void HistorySvc::dumpProperties ( const Algorithm alg,
std::ofstream ofs 
) const
private

Definition at line 336 of file HistorySvc.cpp.

337 {
338 
339  AlgorithmHistory* hist = getAlgHistory( alg );
340 
341  if ( !hist ) {
342  return;
343  }
344 
345  PropertyList::const_iterator itr;
346  for ( auto prop : hist->properties() ) {
347  ofs << alg.name() << " " << dumpProp( prop ) << std::endl;
348  }
349 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:713
AlgorithmHistory class definition.
T endl(T...args)
AlgorithmHistory * getAlgHistory(const Algorithm &) const override
Definition: HistorySvc.cpp:352
const PropertyList & properties() const override
void HistorySvc::dumpProperties ( const IAlgTool alg,
std::ofstream ofs 
) const
private

Definition at line 669 of file HistorySvc.cpp.

670 {
671 
672  AlgToolHistory* hist = getAlgToolHistory( alg );
673 
674  if ( !hist ) return;
675 
676  for ( auto& prop : hist->properties() ) {
677  ofs << alg.name() << " " << dumpProp( prop ) << std::endl;
678  }
679 }
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:683
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:713
T endl(T...args)
const PropertyList & properties() const override
AlgToolHistory class definition.
virtual const std::string & name() const =0
Retrieve the name of the instance.
void HistorySvc::dumpState ( std::ofstream ofs) const
private

Definition at line 731 of file HistorySvc.cpp.

732 {
733 
734  if ( m_outputFileTypeXML ) {
735  // xml header
736  ofs << "<?xml version=\"1.0\" ?> " << std::endl;
737  ofs << "<!--Test-xml-->" << std::endl;
738  ofs << "<SETUP>" << std::endl;
739  ofs << " <GLOBAL>" << std::endl;
740  } else {
741  ofs << "GLOBAL" << std::endl;
742  }
743 
744  std::string client_currently_open = "start";
745  for ( auto& item : m_jobHistory->propertyPairs() ) {
746  // client is the name of the component of the current property
747  const std::string& client = item.first;
748  const Gaudi::Details::PropertyBase* prp = item.second;
749 
750  if ( m_outputFileTypeXML ) {
751 
752  if ( client != client_currently_open ) {
753  if ( client_currently_open != "start" ) ofs << " </COMPONENT>" << endl;
754  ofs << " <COMPONENT name=\"" << client << "\" class=\"undefined\">" << std::endl;
755  }
756  } else {
757  ofs << client << " ";
758  }
759 
760  ofs << dumpProp( prp, m_outputFileTypeXML, 6 ) << endl;
761 
762  client_currently_open = client;
763 
764  if ( m_outputFileTypeXML ) ofs << " </COMPONENT>" << endl;
765  }
766 
767  if ( m_outputFileTypeXML ) {
768  ofs << "</GLOBAL>" << endl << "<SERVICES>" << endl;
769  } else {
770  ofs << "SERVICES" << std::endl;
771  }
772 
773  for ( auto& item : m_svcmap ) {
774  const IService* svc = item.first;
775  dumpState( svc, ofs );
776  }
777 
778  if ( m_outputFileTypeXML ) {
779  ofs << "</SERVICES>" << endl << "<ALGORITHMS> " << endl;
780  } else {
781  ofs << "ALGORITHMS" << std::endl;
782  }
783 
784  for ( auto& item : m_algmap ) {
785  const Algorithm* alg = item.first;
786  dumpState( alg, ofs );
787  }
788 
789  if ( m_outputFileTypeXML ) {
790  ofs << "</ALGORITHMS>" << endl << "<ALGTOOLS> " << endl;
791  } else {
792  ofs << "ALGTOOLS" << std::endl;
793  }
794 
795  for ( auto& item : m_algtoolmap ) {
796  const AlgTool* algtool = item.first;
797  dumpState( algtool, ofs );
798  }
799 
800  if ( m_outputFileTypeXML ) {
801  ofs << "</ALGTOOLS>" << endl << "</SETUP>" << endl;
802  }
803 }
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:713
T endl(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
STL class.
General service interface definition.
Definition: IService.h:18
bool m_outputFileTypeXML
Definition: HistorySvc.h:123
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:72
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:731
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:48
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:106
void HistorySvc::dumpState ( const INamedInterface in,
std::ofstream ofs 
) const
private

Definition at line 807 of file HistorySvc.cpp.

808 {
809 
810  HistoryObj* hist = nullptr;
811  IVersHistoryObj* vhist = nullptr;
812 
813  const IService* is = nullptr;
814  const Algorithm* ia = nullptr;
815  const IAlgTool* it = nullptr;
816  if ( ( is = dynamic_cast<const IService*>( in ) ) != nullptr ) {
817  ON_VERBOSE
818  verbose() << in->name() << " is Service" << endmsg;
819  ServiceHistory* o = getServiceHistory( *is );
820  hist = dynamic_cast<HistoryObj*>( o );
821  vhist = dynamic_cast<IVersHistoryObj*>( o );
822  } else if ( ( ia = dynamic_cast<const Algorithm*>( in ) ) != nullptr ) {
823  ON_VERBOSE
824  verbose() << in->name() << " is Alg" << endmsg;
825  AlgorithmHistory* o = getAlgHistory( *ia );
826  hist = dynamic_cast<HistoryObj*>( o );
827  vhist = dynamic_cast<IVersHistoryObj*>( o );
828  } else if ( ( it = dynamic_cast<const IAlgTool*>( in ) ) != nullptr ) {
829  ON_VERBOSE
830  verbose() << in->name() << " is AlgTool" << endmsg;
831  AlgToolHistory* o = getAlgToolHistory( *it );
832  hist = dynamic_cast<HistoryObj*>( o );
833  vhist = dynamic_cast<IVersHistoryObj*>( o );
834  } else {
835  error() << "Could not dcast interface to accepted History Obj type for " << in->name() << endmsg;
836  return;
837  }
838 
839  if ( !hist || !vhist ) {
840  error() << "Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
841  << endmsg;
842  return;
843  }
844 
845  if ( m_outputFileTypeXML ) {
846  hist->dump( ofs, true );
847  } else {
848  ofs << ">> " << vhist->name() << endl << *hist << endl;
849  }
850 }
virtual const std::string & name() const =0
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:683
AlgorithmHistory class definition.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
T endl(T...args)
AlgorithmHistory * getAlgHistory(const Algorithm &) const override
Definition: HistorySvc.cpp:352
virtual void dump(std::ostream &, const bool isXML=false, int indent=0) const =0
Base class for History Objects.
Definition: HistoryObj.h:21
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
General service interface definition.
Definition: IService.h:18
bool m_outputFileTypeXML
Definition: HistorySvc.h:123
AlgToolHistory class definition.
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ServiceHistory class definition.
#define ON_VERBOSE
Definition: HistorySvc.cpp:41
Interface for Versioned History Objects.
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:566
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode HistorySvc::finalize ( )
override

Definition at line 273 of file HistorySvc.cpp.

274 {
275 
276  ON_VERBOSE
277  verbose() << "HistorySvc::finalize()" << endmsg;
278 
279  clearState();
280 
281  StatusCode status = Service::finalize();
282 
283  if ( status.isSuccess() ) info() << "Service finalised successfully" << endmsg;
284 
285  return status;
286 }
StatusCode finalize() override
Definition: Service.cpp:174
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:75
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
#define ON_VERBOSE
Definition: HistorySvc.cpp:41
void clearState()
Definition: HistorySvc.cpp:107
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
AlgorithmHistory * HistorySvc::getAlgHistory ( const Algorithm alg) const
override

Definition at line 352 of file HistorySvc.cpp.

353 {
354 
355  auto itr = m_algmap.find( &alg );
356  if ( itr == m_algmap.end() ) {
357  warning() << "Algorithm " << alg.name() << " not registered" << endmsg;
358  return nullptr;
359  }
360  return itr->second;
361 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
T end(T...args)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T find(T...args)
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void HistorySvc::getAlgHistory ( std::set< AlgorithmHistory * > &  algs) const
override

Definition at line 364 of file HistorySvc.cpp.

364 { map_to_set( m_algmap, algs ); }
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
AlgToolHistory * HistorySvc::getAlgToolHistory ( const IAlgTool alg) const
override

Definition at line 683 of file HistorySvc.cpp.

684 {
685 
686  const AlgTool* palg = dynamic_cast<const AlgTool*>( &alg );
687  auto itr = m_algtoolmap.find( palg );
688  if ( itr == m_algtoolmap.end() ) {
689  warning() << "AlgTool " << alg.name() << " not registered" << endmsg;
690  return nullptr;
691  }
692  return itr->second;
693 }
T end(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T find(T...args)
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:48
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
void HistorySvc::getAlgToolHistory ( std::set< AlgToolHistory * > &  algs) const
override

Definition at line 697 of file HistorySvc.cpp.

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

Definition at line 433 of file HistorySvc.cpp.

434 {
435  if ( p_algCtxSvc ) return p_algCtxSvc->currentAlg();
436  warning() << "trying to create DataHistoryObj before "
437  << "HistorySvc has been initialized" << endmsg;
438  return nullptr;
439 }
virtual IAlgorithm * currentAlg() const =0
accessor to current algorithm:
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:96
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
DataHistory * HistorySvc::getDataHistory ( const CLID id,
const std::string key,
const std::string store 
) const
override

Definition at line 505 of file HistorySvc.cpp.

507 {
508 
509  DHH dhh( id, key );
510 
511  auto mitr = m_datMap.equal_range( dhh );
512  return ( mitr.first != mitr.second ) ? mitr.first->second : nullptr;
513 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:104
T equal_range(T...args)
int HistorySvc::getDataHistory ( const CLID id,
const std::string key,
const std::string storeName,
std::list< DataHistory * > &  dhlist 
) const
virtual

Definition at line 517 of file HistorySvc.cpp.

519 {
520 
521  DHH dhh( id, key );
522 
523  int n( 0 );
524 
525  auto mitr = m_datMap.equal_range( dhh );
526  for ( auto itr = mitr.first; itr != mitr.second; ++itr ) {
527  dhlist.push_back( itr->second );
528  ++n;
529  }
530  return n;
531 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:104
T push_back(T...args)
T equal_range(T...args)
JobHistory * HistorySvc::getJobHistory ( ) const
override

Definition at line 430 of file HistorySvc.cpp.

430 { return m_jobHistory.get(); }
T get(T...args)
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:106
ServiceHistory * HistorySvc::getServiceHistory ( const IService svc) const
override

Definition at line 566 of file HistorySvc.cpp.

567 {
568 
569  const IService* psvc = &svc;
570  auto itr = m_svcmap.find( psvc );
571  if ( itr != m_svcmap.end() ) return itr->second;
572 
573  warning() << "Service " << svc.name() << " not registered" << endmsg;
574  return nullptr;
575 }
T end(T...args)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
General service interface definition.
Definition: IService.h:18
T find(T...args)
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
void HistorySvc::getServiceHistory ( std::set< ServiceHistory * > &  svcs) const
override

Definition at line 578 of file HistorySvc.cpp.

578 { map_to_set( m_svcmap, svcs ); }
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
void HistorySvc::handle ( const Incident inc)
override

Definition at line 701 of file HistorySvc.cpp.

702 {
703 
704  if ( incident.type() == IncidentType::BeginEvent ) {
705  if ( captureState().isFailure() ) {
706  warning() << "Error capturing state." << endl << "Will try again at next BeginEvent incident" << endmsg;
707  }
708  }
709 }
T endl(T...args)
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
virtual StatusCode captureState()
Definition: HistorySvc.cpp:169
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode HistorySvc::initialize ( )
override

Definition at line 119 of file HistorySvc.cpp.

120 {
121 
122  StatusCode status = Service::initialize();
123  if ( status.isFailure() ) {
124  ON_DEBUG
125  debug() << "Failed to initialize the base class (Service)" << endmsg;
126  return status;
127  }
128 
129  ON_DEBUG
130  debug() << "Initializing HistorySvc" << endmsg;
131 
132  if ( !m_activate ) return StatusCode::SUCCESS;
133 
134  static const bool CREATEIF( true );
135 
136  if ( service( "AlgContextSvc", p_algCtxSvc, CREATEIF ).isFailure() ) {
137  error() << "unable to get the AlgContextSvc" << endmsg;
138  return StatusCode::FAILURE;
139  }
140 
141  if ( service( "IncidentSvc", m_incidentSvc, CREATEIF ).isFailure() ) {
142  error() << "unable to get the IncidentSvc" << endmsg;
143  return StatusCode::FAILURE;
144  }
145 
146  // create a weak dependency on the ToolSvc, so that it doesn't get deleted
147  // before we're done with it in finalize
148  m_toolSvc = serviceLocator()->service( "ToolSvc" );
149  if ( !m_toolSvc ) {
150  error() << "could not retrieve the ToolSvc handle !" << endmsg;
151  return StatusCode::FAILURE;
152  }
153 
154  // add listener to be triggered by first BeginEvent with low priority
155  // so it gets called first
156  const bool rethrow = false;
157  const bool oneShot = true; // make the listener called only once
158  m_incidentSvc->addListener( this, IncidentType::BeginEvent, std::numeric_limits<long>::min(), rethrow, oneShot );
159 
160  m_outputFileTypeXML = ba::iends_with( m_outputFile.value(), ".xml" );
161  ON_DEBUG if ( m_outputFileTypeXML ) { debug() << "output format is XML" << endmsg; }
162 
163  m_isInitialized = true;
164 
165  return StatusCode::SUCCESS;
166 }
StatusCode initialize() override
Definition: Service.cpp:64
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:121
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool m_isInitialized
Definition: HistorySvc.h:94
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
bool m_outputFileTypeXML
Definition: HistorySvc.h:123
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:96
IIncidentSvc * m_incidentSvc
Definition: HistorySvc.h:120
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
Gaudi::Property< std::string > m_outputFile
Definition: HistorySvc.h:90
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:89
StatusCode HistorySvc::listProperties ( ) const
override

Definition at line 370 of file HistorySvc.cpp.

371 {
372 
373  auto& log = info();
374 
375  log.setColor( MSG::CYAN );
376  log << "Dumping properties for all Algorithms (" << m_algmap.size() << ")" << endmsg;
377 
378  for ( auto& alg : m_algmap ) {
379  listProperties( *alg.first ).ignore();
380  }
381 
382  log << MSG::INFO;
383  log.setColor( MSG::CYAN );
384  log << "Dumping properties for all AlgTools (" << m_algtoolmap.size() << ")" << endmsg;
385 
386  for ( auto& algtool : m_algtoolmap ) {
387  ON_DEBUG
388  debug() << " --> " << algtool.second->algtool_name() << endmsg;
389  listProperties( *algtool.first ).ignore();
390  }
391 
392  log << MSG::INFO;
393  log.setColor( MSG::CYAN );
394  log << "Dumping properties for all Services (" << m_svcmap.size() << ")" << endmsg;
395 
396  for ( auto& svc : m_svcmap ) {
397  listProperties( *svc.first ).ignore();
398  }
399 
400  log << MSG::INFO;
401  log.setColor( MSG::CYAN );
402  log << "Dumping properties for Job";
403  log.resetColor();
404 
405  log << std::endl << *m_jobHistory << endmsg;
406 
407  return StatusCode( StatusCode::SUCCESS, true );
408 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode listProperties() const override
Definition: HistorySvc.cpp:370
T endl(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
T size(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
void ignore() const
Definition: StatusCode.h:109
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:106
StatusCode HistorySvc::listProperties ( const IService svc) const
override

Definition at line 582 of file HistorySvc.cpp.

583 {
584 
585  info() << "Dumping properties for " << svc.name() << endl;
586 
587  ServiceHistory* hist = getServiceHistory( svc );
588 
589  if ( !hist ) return StatusCode::FAILURE;
590 
591  info() << svc.name() << " --> " << endl << *hist << endmsg;
592 
593  return StatusCode( StatusCode::SUCCESS, true );
594 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T endl(T...args)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
ServiceHistory class definition.
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:566
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode HistorySvc::listProperties ( const Algorithm alg) const
override

Definition at line 319 of file HistorySvc.cpp.

320 {
321 
322  info() << "Dumping properties for " << alg.name() << endl;
323 
324  AlgorithmHistory* hist = getAlgHistory( alg );
325 
326  if ( !hist ) {
327  return StatusCode::FAILURE;
328  }
329 
330  info() << alg.name() << " --> " << endl << *hist << endmsg;
331 
332  return StatusCode( StatusCode::SUCCESS, true );
333 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
AlgorithmHistory class definition.
T endl(T...args)
AlgorithmHistory * getAlgHistory(const Algorithm &) const override
Definition: HistorySvc.cpp:352
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode HistorySvc::listProperties ( const IAlgTool alg) const
override

Definition at line 654 of file HistorySvc.cpp.

655 {
656 
657  info() << "Dumping properties for " << alg.name() << endl;
658 
659  AlgToolHistory* hist = getAlgToolHistory( alg );
660 
661  if ( !hist ) return StatusCode::FAILURE;
662 
663  info() << alg.name() << " --> " << endl << *hist << endmsg;
664 
665  return StatusCode::SUCCESS;
666 }
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:683
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T endl(T...args)
AlgToolHistory class definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode HistorySvc::registerAlg ( const Algorithm alg)
override

Definition at line 293 of file HistorySvc.cpp.

294 {
295 
296  JobHistory* job = getJobHistory();
297  if ( m_algmap.find( &alg ) != m_algmap.end() ) {
298  warning() << "Algorithm " << alg.name() << " already registered with HistorySvc" << endmsg;
299  return StatusCode::SUCCESS;
300  }
301 
302  ( const_cast<Algorithm*>( &alg ) )->addRef();
303 
304  m_algmap[&alg] = new AlgorithmHistory( alg, job );
305 
306  ON_DEBUG
307  {
308  auto& log = debug();
309  log << "Registering algorithm: ";
310  log.setColor( MSG::CYAN );
311  log << alg.name() << endmsg;
312  log.resetColor();
313  }
314 
315  return StatusCode( StatusCode::SUCCESS, true );
316 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:731
AlgorithmHistory class definition.
T end(T...args)
JobHistory class definition.
Definition: JobHistory.h:22
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:430
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:98
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg)
override

Definition at line 612 of file HistorySvc.cpp.

613 {
614 
615  if ( !m_isInitialized ) {
616  if ( !p_algCtxSvc ) {
617  if ( service( "AlgContextSvc", p_algCtxSvc, true ).isFailure() ) {
618  error() << "unable to get the AlgContextSvc" << endmsg;
619  return StatusCode::FAILURE;
620  }
621  }
622  m_ialgtools.insert( &ialg );
623  return StatusCode::SUCCESS;
624  }
625 
626  const AlgTool* alg = dynamic_cast<const AlgTool*>( &ialg );
627  if ( !alg ) {
628  error() << "Could not dcast IAlgTool \"" << ialg.name() << "\" to an AlgTool" << endmsg;
629  return StatusCode::FAILURE;
630  }
631 
632  if ( m_algtoolmap.find( alg ) != m_algtoolmap.end() ) {
633  warning() << "AlgTool " << ialg.name() << " already registered in HistorySvc" << endmsg;
634  return StatusCode::SUCCESS;
635  }
636 
637  const JobHistory* job = getJobHistory();
638  m_algtoolmap[alg] = new AlgToolHistory( *alg, job );
639 
640  ON_DEBUG
641  {
642  auto& log = debug();
643  log << "Registering algtool: ";
644  log.setColor( MSG::CYAN );
645  log << alg->name() << endmsg;
646  log.resetColor();
647  }
648 
649  return StatusCode::SUCCESS;
650 }
T end(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:101
JobHistory class definition.
Definition: JobHistory.h:22
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
bool m_isInitialized
Definition: HistorySvc.h:94
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:430
#define ON_DEBUG
Definition: HistorySvc.cpp:40
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:96
AlgToolHistory class definition.
T insert(T...args)
T find(T...args)
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:63
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:48
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn&#39;t already exist.
Definition: Service.h:85
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:100
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode HistorySvc::registerDataHistory ( const CLID id,
const std::string key,
const std::string store 
)
virtual

Definition at line 471 of file HistorySvc.cpp.

472 {
473 
474  DHH dhh( id, key );
475 
476  auto boundaries = m_datMap.equal_range( dhh );
477  auto match = boundaries.second;
478 
479  if ( boundaries.first != boundaries.second ) {
480  // there is something in the map, let's look for the specific entry
481 
482  std::string algName;
483  IAlgorithm* ialg = getCurrentIAlg();
484  if ( ialg ) {
485  algName = ialg->name();
486  } else {
487  algName = "UNKNOWN";
488  }
489 
490  match = std::find_if( boundaries.first, boundaries.second,
491  [&algName]( decltype( boundaries )::first_type::reference p ) -> bool {
492  return p.second->algorithmHistory()->algorithm_name() == algName;
493  } );
494  }
495 
496  if ( match == boundaries.second ) { // not found, crete the entry
497  DataHistory* dh = createDataHistoryObj( id, key, storeName );
499  }
500 
501  return StatusCode::SUCCESS;
502 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:104
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:433
STL class.
DataHistory class definition.
Definition: DataHistory.h:23
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
T insert(T...args)
T find_if(T...args)
DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store) override
Definition: HistorySvc.cpp:443
TO * reference(FROM *from)
Definition: KeyedObject.cpp:21
T equal_range(T...args)
StatusCode HistorySvc::registerJob ( )
override

Definition at line 367 of file HistorySvc.cpp.

367 { return StatusCode( StatusCode::SUCCESS, true ); }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
StatusCode HistorySvc::registerSvc ( const IService svc)
override

Definition at line 535 of file HistorySvc.cpp.

536 {
537 
538  if ( svc.name() == "HistoryStore" ) {
539  return StatusCode( StatusCode::SUCCESS, true );
540  }
541 
542  JobHistory* job = getJobHistory();
543  const IService* psvc = &svc;
544  auto itr = m_svcmap.find( psvc );
545  if ( itr == m_svcmap.end() ) {
546 
547  ON_DEBUG
548  {
549  auto& log = debug();
550  log << "Registering Service: ";
551  log.setColor( MSG::CYAN );
552  log << svc.name() << endmsg;
553  log.resetColor();
554  }
555 
556  m_svcmap[psvc] = new ServiceHistory( &svc, job );
557 
558  ( const_cast<IService*>( psvc ) )->addRef();
559  }
560 
561  return StatusCode( StatusCode::SUCCESS, true );
562 }
T end(T...args)
JobHistory class definition.
Definition: JobHistory.h:22
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:430
General service interface definition.
Definition: IService.h:18
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
ServiceHistory class definition.
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:102
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
StatusCode HistorySvc::reinitialize ( )
override

Definition at line 80 of file HistorySvc.cpp.

81 {
82 
83  clearState();
85  return initialize();
86 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:160
StatusCode initialize() override
Definition: HistorySvc.cpp:119
void clearState()
Definition: HistorySvc.cpp:107
StatusCode HistorySvc::stop ( )
override

Definition at line 247 of file HistorySvc.cpp.

248 {
249 
250  if ( !m_activate ) return StatusCode::SUCCESS;
251 
252  if ( m_dump ) {
254  }
255 
256  if ( !m_outputFile.empty() ) {
258  if ( !ofs ) {
259  error() << "Unable to open output file \"m_outputFile\"" << endmsg;
260  } else {
261  // dumpProperties(ofs);
262  dumpState( ofs );
263  }
264  }
265 
266  clearState();
267 
268  return StatusCode::SUCCESS;
269 }
StatusCode listProperties() const override
Definition: HistorySvc.cpp:370
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
STL class.
Gaudi::Property< bool > m_dump
Definition: HistorySvc.h:88
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:731
Gaudi::Property< std::string > m_outputFile
Definition: HistorySvc.h:90
void ignore() const
Definition: StatusCode.h:109
void clearState()
Definition: HistorySvc.cpp:107
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:89

Member Data Documentation

Gaudi::Property<bool> HistorySvc::m_activate {this, "Activate", true}
private

Definition at line 89 of file HistorySvc.h.

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

Definition at line 98 of file HistorySvc.h.

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

Definition at line 101 of file HistorySvc.h.

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

Definition at line 104 of file HistorySvc.h.

Gaudi::Property<bool> HistorySvc::m_dump {this, "Dump", false}
private

Definition at line 88 of file HistorySvc.h.

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

Definition at line 100 of file HistorySvc.h.

IIncidentSvc* HistorySvc::m_incidentSvc = nullptr
private

Definition at line 120 of file HistorySvc.h.

bool HistorySvc::m_isInitialized = false
private

Definition at line 94 of file HistorySvc.h.

std::unique_ptr<JobHistory> HistorySvc::m_jobHistory
private

Definition at line 106 of file HistorySvc.h.

Gaudi::Property<std::string> HistorySvc::m_outputFile {this, "OutputFile"}
private

Definition at line 90 of file HistorySvc.h.

bool HistorySvc::m_outputFileTypeXML = false
private

Definition at line 123 of file HistorySvc.h.

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

Definition at line 102 of file HistorySvc.h.

SmartIF<IToolSvc> HistorySvc::m_toolSvc
private

Definition at line 121 of file HistorySvc.h.

IAlgContextSvc* HistorySvc::p_algCtxSvc = nullptr
private

Definition at line 96 of file HistorySvc.h.


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