The Gaudi Framework  v33r0 (d5ea422b)
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 Gaudi::Algorithm &) override
 
StatusCode listProperties (const Gaudi::Algorithm &) const override
 
AlgorithmHistorygetAlgHistory (const Gaudi::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
 
- 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...
 
- 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
 
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, 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
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const 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...
 

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 Gaudi::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 Gaudi::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
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- 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 > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
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, " 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 46 of file HistorySvc.h.

Member Typedef Documentation

◆ DataHistMap

Definition at line 90 of file HistorySvc.h.

◆ DHMCitr

typedef DataHistMap::const_iterator HistorySvc::DHMCitr
private

Definition at line 92 of file HistorySvc.h.

◆ DHMitr

typedef DataHistMap::iterator HistorySvc::DHMitr
private

Definition at line 91 of file HistorySvc.h.

◆ PropertyList

Definition at line 88 of file HistorySvc.h.

Member Function Documentation

◆ captureState()

StatusCode HistorySvc::captureState ( )
virtual

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 170 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 ) ) { m_jobHistory->addProperty( client, prop ); }
185  }
186 
187  if ( !foundAppMgr ) {
188  auto ap = service<IProperty>( "ApplicationMgr" );
189  if ( !ap ) {
190  error() << "could not get the ApplicationMgr" << endmsg;
191  } else {
192  for ( auto prop : ap->getProperties() ) { m_jobHistory->addProperty( "ApplicationMgr", prop ); }
193  }
194  }
195  }
196  }
197 
199 
200  auto algMgr = Gaudi::svcLocator()->as<IAlgManager>();
201  if ( !algMgr ) {
202  error() << "Could not get AlgManager" << endmsg;
203  return StatusCode::FAILURE;
204  }
205 
206  size_t count = 0;
207  for ( auto ialg : algMgr->getAlgorithms() ) {
208  Gaudi::Algorithm* alg = dynamic_cast<Gaudi::Algorithm*>( ialg );
209  if ( !alg ) {
210  warning() << "Algorithm " << ialg->name() << " does not inherit from Gaudi::Algorithm. Not registering it."
211  << endmsg;
212  } else {
213  ++count;
214  registerAlg( *alg ).ignore();
215  }
216  }
217 
218  info() << "Registered " << count << " Algorithms" << endmsg;
219 
221 
222  m_isInitialized = true;
223  for ( auto algtool : m_ialgtools ) {
224  ( const_cast<IAlgTool*>( algtool ) )->addRef();
225  registerAlgTool( *algtool ).ignore();
226  }
227 
228  info() << "Registered " << m_algtoolmap.size() << " AlgTools" << endmsg;
229 
231 
232  for ( auto svc : Gaudi::svcLocator()->getServices() ) {
233  svc->addRef();
234  registerSvc( *svc ).ignore();
235  }
236 
237  info() << "Registered " << Gaudi::svcLocator()->getServices().size() << " Services" << endmsg;
238 
239  return StatusCode::SUCCESS;
240 }
StatusCode registerSvc(const IService &) override
Definition: HistorySvc.cpp:505
StatusCode registerAlgTool(const IAlgTool &) override
Definition: HistorySvc.cpp:573
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:37
virtual const std::vector< const Gaudi::Details::PropertyBase * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
virtual std::vector< std::string > getClients() const =0
Get the list of clients.
SmartIF< IFace > as()
Definition: ISvcLocator.h:113
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
JobHistory class definition.
Definition: JobHistory.h:32
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
void addProperty(const std::string &, const Gaudi::Details::PropertyBase *)
Definition: JobHistory.cpp:91
Main interface for the JobOptions service.
GAUDI_API ISvcLocator * svcLocator()
bool m_isInitialized
Definition: HistorySvc.h:100
T reset(T... args)
T count(T... args)
T size(T... args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:164
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
constexpr static const auto FAILURE
Definition: StatusCode.h:97
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:93
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:106
StatusCode registerAlg(const Gaudi::Algorithm &) override
Definition: HistorySvc.cpp:286
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:112

◆ clearState()

void HistorySvc::clearState ( )
private

Definition at line 110 of file HistorySvc.cpp.

110  {
111  clear( m_algmap );
112 
113  m_ialgtools.clear();
114  clear( m_algtoolmap );
115 
116  clear( m_svcmap );
117 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
T clear(T... args)
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:106
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108

◆ createDataHistoryObj()

DataHistory * HistorySvc::createDataHistoryObj ( const CLID id,
const std::string key,
const std::string store 
)
override

Definition at line 417 of file HistorySvc.cpp.

418  {
419 
420  if ( !m_activate ) return nullptr;
421 
422  AlgorithmHistory* algHist = nullptr;
423 
424  IAlgorithm* ialg = getCurrentIAlg();
425  if ( !ialg ) {
426  ON_DEBUG
427  debug() << "Could not discover current Algorithm:" << endl
428  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
429  algHist = nullptr;
430  } else {
431  Gaudi::Algorithm* alg = dynamic_cast<Gaudi::Algorithm*>( ialg );
432  if ( alg ) {
433  algHist = getAlgHistory( *alg );
434  } else {
435  warning() << "Could not extract concrete Algorithm:" << endl
436  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
437  algHist = nullptr;
438  }
439  }
440  return new DataHistory( id, key, algHist );
441 }
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:408
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
AlgorithmHistory class definition.
T endl(T... args)
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:334
#define ON_DEBUG
Definition: HistorySvc.cpp:50
DataHistory class definition.
Definition: DataHistory.h:33
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:38
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:95

◆ dumpProp()

std::string HistorySvc::dumpProp ( const Gaudi::Details::PropertyBase prop,
const bool  isXML = false,
int  indent = 0 
) const
private

Definition at line 666 of file HistorySvc.cpp.

666  {
667  std::ostringstream ost;
668  if ( isXML ) {
669  while ( ind > 0 ) {
670  ost << " ";
671  ind--;
672  }
673  ost << "<PROPERTY name=\"" << prop->name() << "\" value=\"" << HistoryObj::convert_string( prop->toString() )
674  << "\" documentation=\"" << HistoryObj::convert_string( prop->documentation() ) << "\">";
675  } else {
676  prop->fillStream( ost );
677  }
678  return ost.str();
679 }
const std::string name() const
property name
Definition: Property.h:46
T str(T... args)
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:59
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:30
virtual std::string toString() const =0
value -> string
std::string documentation() const
property documentation
Definition: Property.h:48

◆ dumpProperties() [1/4]

void HistorySvc::dumpProperties ( std::ofstream ofs) const
private

Definition at line 387 of file HistorySvc.cpp.

387  {
388 
389  ofs << "GLOBAL" << std::endl;
390  for ( const auto& prop : m_jobHistory->propertyPairs() ) {
391  ofs << prop.first << " " << dumpProp( prop.second ) << std::endl;
392  }
393 
394  ofs << std::endl << "SERVICES" << std::endl;
395  for ( const auto& s : m_svcmap ) dumpProperties( *s.first, ofs );
396 
397  ofs << std::endl << "ALGORITHMS" << std::endl;
398  for ( const auto& alg : m_algmap ) dumpProperties( *alg.first, ofs );
399 
400  ofs << std::endl << "ALGTOOLS" << std::endl;
401  for ( const auto& tool : m_algtoolmap ) dumpProperties( *tool.first, ofs );
402 }
T endl(T... args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:387
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:666
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:81
string s
Definition: gaudirun.py:328
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:112

◆ dumpProperties() [2/4]

void HistorySvc::dumpProperties ( const IService svc,
std::ofstream ofs 
) const
private

Definition at line 562 of file HistorySvc.cpp.

562  {
563 
564  ServiceHistory* hist = getServiceHistory( svc );
565 
566  if ( !hist ) return;
567 
568  for ( auto& prop : hist->properties() ) { ofs << svc.name() << " " << dumpProp( prop ) << std::endl; }
569 }
T endl(T... args)
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:666
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:532
ServiceHistory class definition.
const PropertyList & properties() const override

◆ dumpProperties() [3/4]

void HistorySvc::dumpProperties ( const Gaudi::Algorithm alg,
std::ofstream ofs 
) const
private

Definition at line 324 of file HistorySvc.cpp.

324  {
325 
327 
328  if ( !hist ) { return; }
329 
330  for ( auto prop : hist->properties() ) { ofs << alg.name() << " " << dumpProp( prop ) << std::endl; }
331 }
AlgorithmHistory class definition.
T endl(T... args)
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:334
const PropertyList & properties() const override
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:666

◆ dumpProperties() [4/4]

void HistorySvc::dumpProperties ( const IAlgTool alg,
std::ofstream ofs 
) const
private

Definition at line 627 of file HistorySvc.cpp.

627  {
628 
630 
631  if ( !hist ) return;
632 
633  for ( auto& prop : hist->properties() ) { ofs << alg.name() << " " << dumpProp( prop ) << std::endl; }
634 }
const PropertyList & properties() const override
T endl(T... args)
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:638
AlgToolHistory class definition.
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:666

◆ dumpState() [1/2]

void HistorySvc::dumpState ( std::ofstream ofs) const
private

Definition at line 683 of file HistorySvc.cpp.

683  {
684 
685  if ( m_outputFileTypeXML ) {
686  // xml header
687  ofs << "<?xml version=\"1.0\" ?> " << std::endl;
688  ofs << "<!--Test-xml-->" << std::endl;
689  ofs << "<SETUP>" << std::endl;
690  ofs << " <GLOBAL>" << std::endl;
691  } else {
692  ofs << "GLOBAL" << std::endl;
693  }
694 
695  std::string client_currently_open = "start";
696  for ( auto& item : m_jobHistory->propertyPairs() ) {
697  // client is the name of the component of the current property
698  const std::string& client = item.first;
699  const Gaudi::Details::PropertyBase* prp = item.second;
700 
701  if ( m_outputFileTypeXML ) {
702 
703  if ( client != client_currently_open ) {
704  if ( client_currently_open != "start" ) ofs << " </COMPONENT>" << endl;
705  ofs << " <COMPONENT name=\"" << client << "\" class=\"undefined\">" << std::endl;
706  }
707  } else {
708  ofs << client << " ";
709  }
710 
711  ofs << dumpProp( prp, m_outputFileTypeXML, 6 ) << endl;
712 
713  client_currently_open = client;
714 
715  if ( m_outputFileTypeXML ) ofs << " </COMPONENT>" << endl;
716  }
717 
718  if ( m_outputFileTypeXML ) {
719  ofs << "</GLOBAL>" << endl << "<SERVICES>" << endl;
720  } else {
721  ofs << "SERVICES" << std::endl;
722  }
723 
724  // helper to dump monitored components sorted by name
725  auto sortedDump = [&ofs, this]( const auto& map ) {
727  for ( const auto& item : map ) sorted[item.first->name()] = item.first;
728  for ( const auto& item : sorted ) dumpState( item.second, ofs );
729  };
730 
731  sortedDump( m_svcmap );
732 
733  if ( m_outputFileTypeXML ) {
734  ofs << "</SERVICES>" << endl << "<ALGORITHMS> " << endl;
735  } else {
736  ofs << "ALGORITHMS" << std::endl;
737  }
738 
739  sortedDump( m_algmap );
740 
741  if ( m_outputFileTypeXML ) {
742  ofs << "</ALGORITHMS>" << endl << "<ALGTOOLS> " << endl;
743  } else {
744  ofs << "ALGTOOLS" << std::endl;
745  }
746 
747  sortedDump( m_algtoolmap );
748 
749  if ( m_outputFileTypeXML ) { ofs << "</ALGTOOLS>" << endl << "</SETUP>" << endl; }
750 }
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:683
T endl(T... args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
STL class.
STL class.
struct GAUDI_API map
Parametrisation class for map-like implementation.
bool m_outputFileTypeXML
Definition: HistorySvc.h:129
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:42
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:666
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:81
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:112

◆ dumpState() [2/2]

void HistorySvc::dumpState ( const INamedInterface in,
std::ofstream ofs 
) const
private

Definition at line 754 of file HistorySvc.cpp.

754  {
755 
756  HistoryObj* hist = nullptr;
757  IVersHistoryObj* vhist = nullptr;
758 
759  const IService* is = nullptr;
760  const Gaudi::Algorithm* ia = nullptr;
761  const IAlgTool* it = nullptr;
762  if ( ( is = dynamic_cast<const IService*>( in ) ) != nullptr ) {
763  ON_VERBOSE
764  verbose() << in->name() << " is Service" << endmsg;
765  ServiceHistory* o = getServiceHistory( *is );
766  hist = dynamic_cast<HistoryObj*>( o );
767  vhist = dynamic_cast<IVersHistoryObj*>( o );
768  } else if ( ( ia = dynamic_cast<const Gaudi::Algorithm*>( in ) ) != nullptr ) {
769  ON_VERBOSE
770  verbose() << in->name() << " is Alg" << endmsg;
771  AlgorithmHistory* o = getAlgHistory( *ia );
772  hist = dynamic_cast<HistoryObj*>( o );
773  vhist = dynamic_cast<IVersHistoryObj*>( o );
774  } else if ( ( it = dynamic_cast<const IAlgTool*>( in ) ) != nullptr ) {
775  ON_VERBOSE
776  verbose() << in->name() << " is AlgTool" << endmsg;
777  AlgToolHistory* o = getAlgToolHistory( *it );
778  hist = dynamic_cast<HistoryObj*>( o );
779  vhist = dynamic_cast<IVersHistoryObj*>( o );
780  } else {
781  error() << "Could not dcast interface to accepted History Obj type for " << in->name() << endmsg;
782  return;
783  }
784 
785  if ( !hist || !vhist ) {
786  error() << "Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
787  << endmsg;
788  return;
789  }
790 
791  if ( m_outputFileTypeXML ) {
792  hist->dump( ofs, true );
793  } else {
794  ofs << ">> " << vhist->name() << endl << *hist << endl;
795  }
796 }
virtual void dump(std::ostream &, const bool isXML=false, int indent=0) const =0
AlgorithmHistory class definition.
T endl(T... args)
Base class for History Objects.
Definition: HistoryObj.h:31
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:334
virtual const std::string & name() const =0
Retrieve the name of the instance.
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:638
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
General service interface definition.
Definition: IService.h:28
bool m_outputFileTypeXML
Definition: HistorySvc.h:129
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
AlgToolHistory class definition.
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:33
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:532
ServiceHistory class definition.
virtual const std::string & name() const =0
#define ON_VERBOSE
Definition: HistorySvc.cpp:51
Interface for Versioned History Objects.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ finalize()

StatusCode HistorySvc::finalize ( )
override

Definition at line 267 of file HistorySvc.cpp.

267  {
268 
269  ON_VERBOSE
270  verbose() << "HistorySvc::finalize()" << endmsg;
271 
272  clearState();
273 
274  StatusCode status = Service::finalize();
275 
276  if ( status.isSuccess() ) info() << "Service finalised successfully" << endmsg;
277 
278  return status;
279 }
StatusCode finalize() override
Definition: Service.cpp:174
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
bool isSuccess() const
Definition: StatusCode.h:361
#define ON_VERBOSE
Definition: HistorySvc.cpp:51
void clearState()
Definition: HistorySvc.cpp:110
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ getAlgHistory() [1/2]

AlgorithmHistory * HistorySvc::getAlgHistory ( const Gaudi::Algorithm alg) const
override

Definition at line 334 of file HistorySvc.cpp.

334  {
335 
336  auto itr = m_algmap.find( &alg );
337  if ( itr == m_algmap.end() ) {
338  warning() << "Algorithm " << alg.name() << " not registered" << endmsg;
339  return nullptr;
340  }
341  return itr->second;
342 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T end(T... args)
T find(T... args)
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ getAlgHistory() [2/2]

void HistorySvc::getAlgHistory ( std::set< AlgorithmHistory * > &  algs) const
override

Definition at line 345 of file HistorySvc.cpp.

345 { map_to_set( m_algmap, algs ); }
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104

◆ getAlgToolHistory() [1/2]

AlgToolHistory * HistorySvc::getAlgToolHistory ( const IAlgTool alg) const
override

Definition at line 638 of file HistorySvc.cpp.

638  {
639 
640  const AlgTool* palg = dynamic_cast<const AlgTool*>( &alg );
641  auto itr = m_algtoolmap.find( palg );
642  if ( itr == m_algtoolmap.end() ) {
643  warning() << "AlgTool " << alg.name() << " not registered" << endmsg;
644  return nullptr;
645  }
646  return itr->second;
647 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T end(T... args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
T find(T... args)
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:57
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ getAlgToolHistory() [2/2]

void HistorySvc::getAlgToolHistory ( std::set< AlgToolHistory * > &  algs) const
override

Definition at line 651 of file HistorySvc.cpp.

651 { map_to_set( m_algtoolmap, algs ); }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107

◆ getCurrentIAlg()

IAlgorithm * HistorySvc::getCurrentIAlg ( ) const
private

Definition at line 408 of file HistorySvc.cpp.

408  {
409  if ( p_algCtxSvc ) return p_algCtxSvc->currentAlg();
410  warning() << "trying to create DataHistoryObj before "
411  << "HistorySvc has been initialized" << endmsg;
412  return nullptr;
413 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:102
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:202

◆ getDataHistory() [1/2]

DataHistory * HistorySvc::getDataHistory ( const CLID id,
const std::string key,
const std::string store 
) const
override

Definition at line 477 of file HistorySvc.cpp.

478  {
479 
480  DHH dhh( id, key );
481 
482  auto mitr = m_datMap.equal_range( dhh );
483  return ( mitr.first != mitr.second ) ? mitr.first->second : nullptr;
484 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:110
T equal_range(T... args)

◆ getDataHistory() [2/2]

int HistorySvc::getDataHistory ( const CLID id,
const std::string key,
const std::string storeName,
std::list< DataHistory * > &  dhlist 
) const
virtual

Definition at line 488 of file HistorySvc.cpp.

489  {
490 
491  DHH dhh( id, key );
492 
493  int n( 0 );
494 
495  auto mitr = m_datMap.equal_range( dhh );
496  for ( auto itr = mitr.first; itr != mitr.second; ++itr ) {
497  dhlist.push_back( itr->second );
498  ++n;
499  }
500  return n;
501 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:110
T push_back(T... args)
T equal_range(T... args)

◆ getJobHistory()

JobHistory * HistorySvc::getJobHistory ( ) const
override

Definition at line 405 of file HistorySvc.cpp.

405 { return m_jobHistory.get(); }
T get(T... args)
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:112

◆ getServiceHistory() [1/2]

ServiceHistory * HistorySvc::getServiceHistory ( const IService svc) const
override

Definition at line 532 of file HistorySvc.cpp.

532  {
533 
534  const IService* psvc = &svc;
535  auto itr = m_svcmap.find( psvc );
536  if ( itr != m_svcmap.end() ) return itr->second;
537 
538  warning() << "Service " << svc.name() << " not registered" << endmsg;
539  return nullptr;
540 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T end(T... args)
General service interface definition.
Definition: IService.h:28
T find(T... args)
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ getServiceHistory() [2/2]

void HistorySvc::getServiceHistory ( std::set< ServiceHistory * > &  svcs) const
override

Definition at line 543 of file HistorySvc.cpp.

543 { map_to_set( m_svcmap, svcs ); }
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108

◆ handle()

void HistorySvc::handle ( const Incident inc)
override

Definition at line 655 of file HistorySvc.cpp.

655  {
656 
657  if ( incident.type() == IncidentType::BeginEvent ) {
658  if ( captureState().isFailure() ) {
659  warning() << "Error capturing state." << endl << "Will try again at next BeginEvent incident" << endmsg;
660  }
661  }
662 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T endl(T... args)
bool isFailure() const
Definition: StatusCode.h:141
virtual StatusCode captureState()
Definition: HistorySvc.cpp:170
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ initialize()

StatusCode HistorySvc::initialize ( )
override

Definition at line 121 of file HistorySvc.cpp.

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

◆ listProperties() [1/4]

StatusCode HistorySvc::listProperties ( ) const
override

Definition at line 351 of file HistorySvc.cpp.

351  {
352 
353  auto& log = info();
354 
355  log.setColor( MSG::CYAN );
356  log << "Dumping properties for all Algorithms (" << m_algmap.size() << ")" << endmsg;
357 
358  for ( auto& alg : m_algmap ) { listProperties( *alg.first ).ignore(); }
359 
360  log << MSG::INFO;
361  log.setColor( MSG::CYAN );
362  log << "Dumping properties for all AlgTools (" << m_algtoolmap.size() << ")" << endmsg;
363 
364  for ( auto& algtool : m_algtoolmap ) {
365  ON_DEBUG
366  debug() << " --> " << algtool.second->algtool_name() << endmsg;
367  listProperties( *algtool.first ).ignore();
368  }
369 
370  log << MSG::INFO;
371  log.setColor( MSG::CYAN );
372  log << "Dumping properties for all Services (" << m_svcmap.size() << ")" << endmsg;
373 
374  for ( auto& svc : m_svcmap ) { listProperties( *svc.first ).ignore(); }
375 
376  log << MSG::INFO;
377  log.setColor( MSG::CYAN );
378  log << "Dumping properties for Job";
379  log.resetColor();
380 
381  log << std::endl << *m_jobHistory << endmsg;
382 
383  return StatusCode( StatusCode::SUCCESS, true );
384 }
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
#define ON_DEBUG
Definition: HistorySvc.cpp:50
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T size(T... args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:164
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
StatusCode listProperties() const override
Definition: HistorySvc.cpp:351
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:112

◆ listProperties() [2/4]

StatusCode HistorySvc::listProperties ( const IService svc) const
override

Definition at line 547 of file HistorySvc.cpp.

547  {
548 
549  info() << "Dumping properties for " << svc.name() << endl;
550 
551  ServiceHistory* hist = getServiceHistory( svc );
552 
553  if ( !hist ) return StatusCode::FAILURE;
554 
555  info() << svc.name() << " --> " << endl << *hist << endmsg;
556 
557  return StatusCode( StatusCode::SUCCESS, true );
558 }
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
constexpr static const auto FAILURE
Definition: StatusCode.h:97
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:532
ServiceHistory class definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ listProperties() [3/4]

StatusCode HistorySvc::listProperties ( const Gaudi::Algorithm alg) const
override

Definition at line 310 of file HistorySvc.cpp.

310  {
311 
312  info() << "Dumping properties for " << alg.name() << endl;
313 
315 
316  if ( !hist ) { return StatusCode::FAILURE; }
317 
318  info() << alg.name() << " --> " << endl << *hist << endmsg;
319 
320  return StatusCode( StatusCode::SUCCESS, true );
321 }
AlgorithmHistory class definition.
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:334
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
constexpr static const auto FAILURE
Definition: StatusCode.h:97
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ listProperties() [4/4]

StatusCode HistorySvc::listProperties ( const IAlgTool alg) const
override

Definition at line 613 of file HistorySvc.cpp.

613  {
614 
615  info() << "Dumping properties for " << alg.name() << endl;
616 
618 
619  if ( !hist ) return StatusCode::FAILURE;
620 
621  info() << alg.name() << " --> " << endl << *hist << endmsg;
622 
623  return StatusCode::SUCCESS;
624 }
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:638
AlgToolHistory class definition.
constexpr static const auto FAILURE
Definition: StatusCode.h:97
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ registerAlg()

StatusCode HistorySvc::registerAlg ( const Gaudi::Algorithm alg)
override

Definition at line 286 of file HistorySvc.cpp.

286  {
287 
288  JobHistory* job = getJobHistory();
289  if ( m_algmap.find( &alg ) != m_algmap.end() ) {
290  warning() << "Algorithm " << alg.name() << " already registered with HistorySvc" << endmsg;
291  return StatusCode::SUCCESS;
292  }
293 
294  ( const_cast<Gaudi::Algorithm*>( &alg ) )->addRef();
295 
296  m_algmap[&alg] = new AlgorithmHistory( alg, job );
297 
298  ON_DEBUG {
299  auto& log = debug();
300  log << "Registering algorithm: ";
301  log.setColor( MSG::CYAN );
302  log << alg.name() << endmsg;
303  log.resetColor();
304  }
305 
306  return StatusCode( StatusCode::SUCCESS, true );
307 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
AlgorithmHistory class definition.
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:405
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
T end(T... args)
JobHistory class definition.
Definition: JobHistory.h:32
#define ON_DEBUG
Definition: HistorySvc.cpp:50
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T find(T... args)
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:104
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ registerAlgTool()

StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg)
override

Definition at line 573 of file HistorySvc.cpp.

573  {
574 
575  if ( !m_isInitialized ) {
576  if ( !p_algCtxSvc ) {
577  if ( service( "AlgContextSvc", p_algCtxSvc, true ).isFailure() ) {
578  error() << "unable to get the AlgContextSvc" << endmsg;
579  return StatusCode::FAILURE;
580  }
581  }
582  m_ialgtools.insert( &ialg );
583  return StatusCode::SUCCESS;
584  }
585 
586  const AlgTool* alg = dynamic_cast<const AlgTool*>( &ialg );
587  if ( !alg ) {
588  error() << "Could not dcast IAlgTool \"" << ialg.name() << "\" to an AlgTool" << endmsg;
589  return StatusCode::FAILURE;
590  }
591 
592  if ( m_algtoolmap.find( alg ) != m_algtoolmap.end() ) {
593  warning() << "AlgTool " << ialg.name() << " already registered in HistorySvc" << endmsg;
594  return StatusCode::SUCCESS;
595  }
596 
597  const JobHistory* job = getJobHistory();
598  m_algtoolmap[alg] = new AlgToolHistory( *alg, job );
599 
600  ON_DEBUG {
601  auto& log = debug();
602  log << "Registering algtool: ";
603  log.setColor( MSG::CYAN );
604  log << alg->name() << endmsg;
605  log.resetColor();
606  }
607 
608  return StatusCode::SUCCESS;
609 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:405
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
T end(T... args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:107
JobHistory class definition.
Definition: JobHistory.h:32
virtual const std::string & name() const =0
Retrieve the name of the instance.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
bool m_isInitialized
Definition: HistorySvc.h:100
#define ON_DEBUG
Definition: HistorySvc.cpp:50
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:102
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
AlgToolHistory class definition.
T insert(T... args)
T find(T... args)
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:57
constexpr static const auto FAILURE
Definition: StatusCode.h:97
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:93
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:106
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ registerDataHistory()

StatusCode HistorySvc::registerDataHistory ( const CLID id,
const std::string key,
const std::string store 
)
virtual

Definition at line 444 of file HistorySvc.cpp.

444  {
445 
446  DHH dhh( id, key );
447 
448  auto boundaries = m_datMap.equal_range( dhh );
449  auto match = boundaries.second;
450 
451  if ( boundaries.first != boundaries.second ) {
452  // there is something in the map, let's look for the specific entry
453 
454  std::string algName;
455  IAlgorithm* ialg = getCurrentIAlg();
456  if ( ialg ) {
457  algName = ialg->name();
458  } else {
459  algName = "UNKNOWN";
460  }
461 
462  match = std::find_if( boundaries.first, boundaries.second,
463  [&algName]( decltype( boundaries )::first_type::reference p ) -> bool {
464  return p.second->algorithmHistory()->algorithm_name() == algName;
465  } );
466  }
467 
468  if ( match == boundaries.second ) { // not found, crete the entry
469  DataHistory* dh = createDataHistoryObj( id, key, storeName );
471  }
472 
473  return StatusCode::SUCCESS;
474 }
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:408
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:110
STL class.
DataHistory class definition.
Definition: DataHistory.h:33
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:38
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:417
T equal_range(T... args)

◆ registerJob()

StatusCode HistorySvc::registerJob ( )
override

Definition at line 348 of file HistorySvc.cpp.

348 { return StatusCode( StatusCode::SUCCESS, true ); }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61

◆ registerSvc()

StatusCode HistorySvc::registerSvc ( const IService svc)
override

Definition at line 505 of file HistorySvc.cpp.

505  {
506 
507  if ( svc.name() == "HistoryStore" ) { return StatusCode( StatusCode::SUCCESS, true ); }
508 
509  JobHistory* job = getJobHistory();
510  const IService* psvc = &svc;
511  auto itr = m_svcmap.find( psvc );
512  if ( itr == m_svcmap.end() ) {
513 
514  ON_DEBUG {
515  auto& log = debug();
516  log << "Registering Service: ";
517  log.setColor( MSG::CYAN );
518  log << svc.name() << endmsg;
519  log.resetColor();
520  }
521 
522  m_svcmap[psvc] = new ServiceHistory( &svc, job );
523 
524  ( const_cast<IService*>( psvc ) )->addRef();
525  }
526 
527  return StatusCode( StatusCode::SUCCESS, true );
528 }
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:405
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
T end(T... args)
JobHistory class definition.
Definition: JobHistory.h:32
General service interface definition.
Definition: IService.h:28
#define ON_DEBUG
Definition: HistorySvc.cpp:50
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T find(T... args)
ServiceHistory class definition.
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:108
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ reinitialize()

StatusCode HistorySvc::reinitialize ( )
override

Definition at line 87 of file HistorySvc.cpp.

87  {
88 
89  clearState();
91  return initialize();
92 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:163
StatusCode initialize() override
Definition: HistorySvc.cpp:121
void clearState()
Definition: HistorySvc.cpp:110

◆ stop()

StatusCode HistorySvc::stop ( )
override

Definition at line 244 of file HistorySvc.cpp.

244  {
245 
246  if ( !m_activate ) return StatusCode::SUCCESS;
247 
248  if ( m_dump ) { listProperties().ignore(); }
249 
250  if ( !m_outputFile.empty() ) {
252  if ( !ofs ) {
253  error() << "Unable to open output file \"m_outputFile\"" << endmsg;
254  } else {
255  // dumpProperties(ofs);
256  dumpState( ofs );
257  }
258  }
259 
260  clearState();
261 
262  return StatusCode::SUCCESS;
263 }
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:683
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Gaudi::Property< bool > m_dump
Definition: HistorySvc.h:94
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:164
Gaudi::Property< std::string > m_outputFile
Definition: HistorySvc.h:96
void clearState()
Definition: HistorySvc.cpp:110
StatusCode listProperties() const override
Definition: HistorySvc.cpp:351
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:95

Member Data Documentation

◆ m_activate

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

Definition at line 95 of file HistorySvc.h.

◆ m_algmap

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

Definition at line 104 of file HistorySvc.h.

◆ m_algtoolmap

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

Definition at line 107 of file HistorySvc.h.

◆ m_datMap

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

Definition at line 110 of file HistorySvc.h.

◆ m_dump

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

Definition at line 94 of file HistorySvc.h.

◆ m_ialgtools

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

Definition at line 106 of file HistorySvc.h.

◆ m_incidentSvc

IIncidentSvc* HistorySvc::m_incidentSvc = nullptr
private

Definition at line 126 of file HistorySvc.h.

◆ m_isInitialized

bool HistorySvc::m_isInitialized = false
private

Definition at line 100 of file HistorySvc.h.

◆ m_jobHistory

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

Definition at line 112 of file HistorySvc.h.

◆ m_outputFile

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

Definition at line 96 of file HistorySvc.h.

◆ m_outputFileTypeXML

bool HistorySvc::m_outputFileTypeXML = false
private

Definition at line 129 of file HistorySvc.h.

◆ m_svcmap

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

Definition at line 108 of file HistorySvc.h.

◆ m_toolSvc

SmartIF<IToolSvc> HistorySvc::m_toolSvc
private

Definition at line 127 of file HistorySvc.h.

◆ p_algCtxSvc

IAlgContextSvc* HistorySvc::p_algCtxSvc = nullptr
private

Definition at line 102 of file HistorySvc.h.


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