The Gaudi Framework  v31r0 (aeb156f0)
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, "[[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 80 of file HistorySvc.h.

typedef DataHistMap::const_iterator HistorySvc::DHMCitr
private

Definition at line 82 of file HistorySvc.h.

typedef DataHistMap::iterator HistorySvc::DHMitr
private

Definition at line 81 of file HistorySvc.h.

Definition at line 78 of file HistorySvc.h.

Member Function Documentation

StatusCode HistorySvc::captureState ( )
virtual

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 160 of file HistorySvc.cpp.

160  {
161 
162  if ( !m_jobHistory ) {
164  IJobOptionsSvc* jo;
165  if ( service( "JobOptionsSvc", jo ).isFailure() ) {
166  error() << "Could not get jobOptionsSvc - "
167  << "not adding properties to JobHistory" << endmsg;
168  } else {
169 
170  bool foundAppMgr( false );
171 
172  for ( auto& client : jo->getClients() ) {
173  if ( client == "ApplicationMgr" ) foundAppMgr = true;
174  for ( auto prop : *jo->getProperties( client ) ) { m_jobHistory->addProperty( client, prop ); }
175  }
176 
177  if ( !foundAppMgr ) {
178  auto ap = service<IProperty>( "ApplicationMgr" );
179  if ( !ap ) {
180  error() << "could not get the ApplicationMgr" << endmsg;
181  } else {
182  for ( auto prop : ap->getProperties() ) { m_jobHistory->addProperty( "ApplicationMgr", prop ); }
183  }
184  }
185  }
186  }
187 
189 
190  auto algMgr = Gaudi::svcLocator()->as<IAlgManager>();
191  if ( !algMgr ) {
192  error() << "Could not get AlgManager" << endmsg;
193  return StatusCode::FAILURE;
194  }
195 
196  size_t count = 0;
197  for ( auto ialg : algMgr->getAlgorithms() ) {
198  Gaudi::Algorithm* alg = dynamic_cast<Gaudi::Algorithm*>( ialg );
199  if ( !alg ) {
200  warning() << "Algorithm " << ialg->name() << " does not inherit from Gaudi::Algorithm. Not registering it."
201  << endmsg;
202  } else {
203  ++count;
204  registerAlg( *alg ).ignore();
205  }
206  }
207 
208  info() << "Registered " << count << " Algorithms" << endmsg;
209 
211 
212  m_isInitialized = true;
213  for ( auto algtool : m_ialgtools ) {
214  ( const_cast<IAlgTool*>( algtool ) )->addRef();
215  registerAlgTool( *algtool ).ignore();
216  }
217 
218  info() << "Registered " << m_algtoolmap.size() << " AlgTools" << endmsg;
219 
221 
222  for ( auto svc : Gaudi::svcLocator()->getServices() ) {
223  svc->addRef();
224  registerSvc( *svc ).ignore();
225  }
226 
227  info() << "Registered " << Gaudi::svcLocator()->getServices().size() << " Services" << endmsg;
228 
229  return StatusCode::SUCCESS;
230 }
StatusCode registerSvc(const IService &) override
Definition: HistorySvc.cpp:496
StatusCode registerAlgTool(const IAlgTool &) override
Definition: HistorySvc.cpp:564
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
SmartIF< IFace > as()
Definition: ISvcLocator.h:103
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
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:81
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:90
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)
T size(T...args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
virtual const std::list< IService * > & getServices() const =0
Get a reference to a service and create it if it does not exists.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:83
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:96
StatusCode registerAlg(const Gaudi::Algorithm &) override
Definition: HistorySvc.cpp:276
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:102
void HistorySvc::clearState ( )
private

Definition at line 100 of file HistorySvc.cpp.

100  {
101  clear( m_algmap );
102 
103  m_ialgtools.clear();
104  clear( m_algtoolmap );
105 
106  clear( m_svcmap );
107 }
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
T clear(T...args)
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:94
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:96
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:98
DataHistory * HistorySvc::createDataHistoryObj ( const CLID id,
const std::string key,
const std::string store 
)
override

Definition at line 408 of file HistorySvc.cpp.

409  {
410 
411  if ( !m_activate ) return nullptr;
412 
413  AlgorithmHistory* algHist = nullptr;
414 
415  IAlgorithm* ialg = getCurrentIAlg();
416  if ( !ialg ) {
417  ON_DEBUG
418  debug() << "Could not discover current Algorithm:" << endl
419  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
420  algHist = nullptr;
421  } else {
422  Gaudi::Algorithm* alg = dynamic_cast<Gaudi::Algorithm*>( ialg );
423  if ( alg ) {
424  algHist = getAlgHistory( *alg );
425  } else {
426  warning() << "Could not extract concrete Algorithm:" << endl
427  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
428  algHist = nullptr;
429  }
430  }
431  return new DataHistory( id, key, algHist );
432 }
AlgorithmHistory class definition.
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:325
T endl(T...args)
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:399
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
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:85
std::string HistorySvc::dumpProp ( const Gaudi::Details::PropertyBase prop,
const bool  isXML = false,
int  indent = 0 
) const
private

Definition at line 657 of file HistorySvc.cpp.

657  {
658  std::ostringstream ost;
659  if ( isXML ) {
660  while ( ind > 0 ) {
661  ost << " ";
662  ind--;
663  }
664  ost << "<PROPERTY name=\"" << prop->name() << "\" value=\"" << HistoryObj::convert_string( prop->toString() )
665  << "\" documentation=\"" << HistoryObj::convert_string( prop->documentation() ) << "\">";
666  } else {
667  prop->fillStream( ost );
668  }
669  return ost.str();
670 }
const std::string name() const
property name
Definition: Property.h:36
virtual std::string toString() const =0
value -> string
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:49
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:20
std::string documentation() const
property documentation
Definition: Property.h:38
void HistorySvc::dumpProperties ( std::ofstream ofs) const
private

Definition at line 378 of file HistorySvc.cpp.

378  {
379 
380  ofs << "GLOBAL" << std::endl;
381  for ( const auto& prop : m_jobHistory->propertyPairs() ) {
382  ofs << prop.first << " " << dumpProp( prop.second ) << std::endl;
383  }
384 
385  ofs << std::endl << "SERVICES" << std::endl;
386  for ( const auto& s : m_svcmap ) dumpProperties( *s.first, ofs );
387 
388  ofs << std::endl << "ALGORITHMS" << std::endl;
389  for ( const auto& alg : m_algmap ) dumpProperties( *alg.first, ofs );
390 
391  ofs << std::endl << "ALGTOOLS" << std::endl;
392  for ( const auto& tool : m_algtoolmap ) dumpProperties( *tool.first, ofs );
393 }
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:657
T endl(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:71
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:378
string s
Definition: gaudirun.py:312
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:94
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:98
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:102
void HistorySvc::dumpProperties ( const IService svc,
std::ofstream ofs 
) const
private

Definition at line 553 of file HistorySvc.cpp.

553  {
554 
555  ServiceHistory* hist = getServiceHistory( svc );
556 
557  if ( !hist ) return;
558 
559  for ( auto& prop : hist->properties() ) { ofs << svc.name() << " " << dumpProp( prop ) << std::endl; }
560 }
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:657
T endl(T...args)
const PropertyList & properties() const override
ServiceHistory class definition.
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:523
void HistorySvc::dumpProperties ( const Gaudi::Algorithm alg,
std::ofstream ofs 
) const
private

Definition at line 314 of file HistorySvc.cpp.

314  {
315 
316  AlgorithmHistory* hist = getAlgHistory( alg );
317 
318  if ( !hist ) { return; }
319 
320  PropertyList::const_iterator itr;
321  for ( auto prop : hist->properties() ) { ofs << alg.name() << " " << dumpProp( prop ) << std::endl; }
322 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:635
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:657
AlgorithmHistory class definition.
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:325
T endl(T...args)
const PropertyList & properties() const override
void HistorySvc::dumpProperties ( const IAlgTool alg,
std::ofstream ofs 
) const
private

Definition at line 618 of file HistorySvc.cpp.

618  {
619 
620  AlgToolHistory* hist = getAlgToolHistory( alg );
621 
622  if ( !hist ) return;
623 
624  for ( auto& prop : hist->properties() ) { ofs << alg.name() << " " << dumpProp( prop ) << std::endl; }
625 }
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:629
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:657
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 674 of file HistorySvc.cpp.

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

Definition at line 745 of file HistorySvc.cpp.

745  {
746 
747  HistoryObj* hist = nullptr;
748  IVersHistoryObj* vhist = nullptr;
749 
750  const IService* is = nullptr;
751  const Gaudi::Algorithm* ia = nullptr;
752  const IAlgTool* it = nullptr;
753  if ( ( is = dynamic_cast<const IService*>( in ) ) != nullptr ) {
754  ON_VERBOSE
755  verbose() << in->name() << " is Service" << endmsg;
756  ServiceHistory* o = getServiceHistory( *is );
757  hist = dynamic_cast<HistoryObj*>( o );
758  vhist = dynamic_cast<IVersHistoryObj*>( o );
759  } else if ( ( ia = dynamic_cast<const Gaudi::Algorithm*>( in ) ) != nullptr ) {
760  ON_VERBOSE
761  verbose() << in->name() << " is Alg" << endmsg;
762  AlgorithmHistory* o = getAlgHistory( *ia );
763  hist = dynamic_cast<HistoryObj*>( o );
764  vhist = dynamic_cast<IVersHistoryObj*>( o );
765  } else if ( ( it = dynamic_cast<const IAlgTool*>( in ) ) != nullptr ) {
766  ON_VERBOSE
767  verbose() << in->name() << " is AlgTool" << endmsg;
768  AlgToolHistory* o = getAlgToolHistory( *it );
769  hist = dynamic_cast<HistoryObj*>( o );
770  vhist = dynamic_cast<IVersHistoryObj*>( o );
771  } else {
772  error() << "Could not dcast interface to accepted History Obj type for " << in->name() << endmsg;
773  return;
774  }
775 
776  if ( !hist || !vhist ) {
777  error() << "Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
778  << endmsg;
779  return;
780  }
781 
782  if ( m_outputFileTypeXML ) {
783  hist->dump( ofs, true );
784  } else {
785  ofs << ">> " << vhist->name() << endl << *hist << endl;
786  }
787 }
virtual const std::string & name() const =0
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:629
AlgorithmHistory class definition.
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:325
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
T endl(T...args)
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:119
AlgToolHistory class definition.
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
ServiceHistory class definition.
#define ON_VERBOSE
Definition: HistorySvc.cpp:41
Interface for Versioned History Objects.
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:523
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode HistorySvc::finalize ( )
override

Definition at line 257 of file HistorySvc.cpp.

257  {
258 
259  ON_VERBOSE
260  verbose() << "HistorySvc::finalize()" << endmsg;
261 
262  clearState();
263 
264  StatusCode status = Service::finalize();
265 
266  if ( status.isSuccess() ) info() << "Service finalised successfully" << endmsg;
267 
268  return status;
269 }
StatusCode finalize() override
Definition: Service.cpp:164
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
bool isSuccess() const
Definition: StatusCode.h:267
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
#define ON_VERBOSE
Definition: HistorySvc.cpp:41
void clearState()
Definition: HistorySvc.cpp:100
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
AlgorithmHistory * HistorySvc::getAlgHistory ( const Gaudi::Algorithm alg) const
override

Definition at line 325 of file HistorySvc.cpp.

325  {
326 
327  auto itr = m_algmap.find( &alg );
328  if ( itr == m_algmap.end() ) {
329  warning() << "Algorithm " << alg.name() << " not registered" << endmsg;
330  return nullptr;
331  }
332  return itr->second;
333 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:635
T end(T...args)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T find(T...args)
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:94
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
void HistorySvc::getAlgHistory ( std::set< AlgorithmHistory * > &  algs) const
override

Definition at line 336 of file HistorySvc.cpp.

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

Definition at line 629 of file HistorySvc.cpp.

629  {
630 
631  const AlgTool* palg = dynamic_cast<const AlgTool*>( &alg );
632  auto itr = m_algtoolmap.find( palg );
633  if ( itr == m_algtoolmap.end() ) {
634  warning() << "AlgTool " << alg.name() << " not registered" << endmsg;
635  return nullptr;
636  }
637  return itr->second;
638 }
T end(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
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:47
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 642 of file HistorySvc.cpp.

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

Definition at line 399 of file HistorySvc.cpp.

399  {
400  if ( p_algCtxSvc ) return p_algCtxSvc->currentAlg();
401  warning() << "trying to create DataHistoryObj before "
402  << "HistorySvc has been initialized" << endmsg;
403  return nullptr;
404 }
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:92
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
DataHistory * HistorySvc::getDataHistory ( const CLID id,
const std::string key,
const std::string store 
) const
override

Definition at line 468 of file HistorySvc.cpp.

469  {
470 
471  DHH dhh( id, key );
472 
473  auto mitr = m_datMap.equal_range( dhh );
474  return ( mitr.first != mitr.second ) ? mitr.first->second : nullptr;
475 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:100
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 479 of file HistorySvc.cpp.

480  {
481 
482  DHH dhh( id, key );
483 
484  int n( 0 );
485 
486  auto mitr = m_datMap.equal_range( dhh );
487  for ( auto itr = mitr.first; itr != mitr.second; ++itr ) {
488  dhlist.push_back( itr->second );
489  ++n;
490  }
491  return n;
492 }
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:100
T push_back(T...args)
T equal_range(T...args)
JobHistory * HistorySvc::getJobHistory ( ) const
override

Definition at line 396 of file HistorySvc.cpp.

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

Definition at line 523 of file HistorySvc.cpp.

523  {
524 
525  const IService* psvc = &svc;
526  auto itr = m_svcmap.find( psvc );
527  if ( itr != m_svcmap.end() ) return itr->second;
528 
529  warning() << "Service " << svc.name() << " not registered" << endmsg;
530  return nullptr;
531 }
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:98
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
void HistorySvc::getServiceHistory ( std::set< ServiceHistory * > &  svcs) const
override

Definition at line 534 of file HistorySvc.cpp.

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

Definition at line 646 of file HistorySvc.cpp.

646  {
647 
648  if ( incident.type() == IncidentType::BeginEvent ) {
649  if ( captureState().isFailure() ) {
650  warning() << "Error capturing state." << endl << "Will try again at next BeginEvent incident" << endmsg;
651  }
652  }
653 }
T endl(T...args)
bool isFailure() const
Definition: StatusCode.h:130
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
virtual StatusCode captureState()
Definition: HistorySvc.cpp:160
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode HistorySvc::initialize ( )
override

Definition at line 111 of file HistorySvc.cpp.

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

Definition at line 342 of file HistorySvc.cpp.

342  {
343 
344  auto& log = info();
345 
346  log.setColor( MSG::CYAN );
347  log << "Dumping properties for all Algorithms (" << m_algmap.size() << ")" << endmsg;
348 
349  for ( auto& alg : m_algmap ) { listProperties( *alg.first ).ignore(); }
350 
351  log << MSG::INFO;
352  log.setColor( MSG::CYAN );
353  log << "Dumping properties for all AlgTools (" << m_algtoolmap.size() << ")" << endmsg;
354 
355  for ( auto& algtool : m_algtoolmap ) {
356  ON_DEBUG
357  debug() << " --> " << algtool.second->algtool_name() << endmsg;
358  listProperties( *algtool.first ).ignore();
359  }
360 
361  log << MSG::INFO;
362  log.setColor( MSG::CYAN );
363  log << "Dumping properties for all Services (" << m_svcmap.size() << ")" << endmsg;
364 
365  for ( auto& svc : m_svcmap ) { listProperties( *svc.first ).ignore(); }
366 
367  log << MSG::INFO;
368  log.setColor( MSG::CYAN );
369  log << "Dumping properties for Job";
370  log.resetColor();
371 
372  log << std::endl << *m_jobHistory << endmsg;
373 
374  return StatusCode( StatusCode::SUCCESS, true );
375 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
StatusCode listProperties() const override
Definition: HistorySvc.cpp:342
T endl(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
T size(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:94
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:98
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:102
StatusCode HistorySvc::listProperties ( const IService svc) const
override

Definition at line 538 of file HistorySvc.cpp.

538  {
539 
540  info() << "Dumping properties for " << svc.name() << endl;
541 
542  ServiceHistory* hist = getServiceHistory( svc );
543 
544  if ( !hist ) return StatusCode::FAILURE;
545 
546  info() << svc.name() << " --> " << endl << *hist << endmsg;
547 
548  return StatusCode( StatusCode::SUCCESS, true );
549 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T endl(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
constexpr static const auto FAILURE
Definition: StatusCode.h:86
ServiceHistory class definition.
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:523
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode HistorySvc::listProperties ( const Gaudi::Algorithm alg) const
override

Definition at line 300 of file HistorySvc.cpp.

300  {
301 
302  info() << "Dumping properties for " << alg.name() << endl;
303 
304  AlgorithmHistory* hist = getAlgHistory( alg );
305 
306  if ( !hist ) { return StatusCode::FAILURE; }
307 
308  info() << alg.name() << " --> " << endl << *hist << endmsg;
309 
310  return StatusCode( StatusCode::SUCCESS, true );
311 }
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:635
AlgorithmHistory class definition.
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:325
T endl(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode HistorySvc::listProperties ( const IAlgTool alg) const
override

Definition at line 604 of file HistorySvc.cpp.

604  {
605 
606  info() << "Dumping properties for " << alg.name() << endl;
607 
608  AlgToolHistory* hist = getAlgToolHistory( alg );
609 
610  if ( !hist ) return StatusCode::FAILURE;
611 
612  info() << alg.name() << " --> " << endl << *hist << endmsg;
613 
614  return StatusCode::SUCCESS;
615 }
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:629
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
T endl(T...args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
AlgToolHistory class definition.
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
virtual const std::string & name() const =0
Retrieve the name of the instance.
StatusCode HistorySvc::registerAlg ( const Gaudi::Algorithm alg)
override

Definition at line 276 of file HistorySvc.cpp.

276  {
277 
278  JobHistory* job = getJobHistory();
279  if ( m_algmap.find( &alg ) != m_algmap.end() ) {
280  warning() << "Algorithm " << alg.name() << " already registered with HistorySvc" << endmsg;
281  return StatusCode::SUCCESS;
282  }
283 
284  ( const_cast<Gaudi::Algorithm*>( &alg ) )->addRef();
285 
286  m_algmap[&alg] = new AlgorithmHistory( alg, job );
287 
288  ON_DEBUG {
289  auto& log = debug();
290  log << "Registering algorithm: ";
291  log.setColor( MSG::CYAN );
292  log << alg.name() << endmsg;
293  log.resetColor();
294  }
295 
296  return StatusCode( StatusCode::SUCCESS, true );
297 }
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:635
AlgorithmHistory class definition.
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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:396
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
T find(T...args)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:94
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg)
override

Definition at line 564 of file HistorySvc.cpp.

564  {
565 
566  if ( !m_isInitialized ) {
567  if ( !p_algCtxSvc ) {
568  if ( service( "AlgContextSvc", p_algCtxSvc, true ).isFailure() ) {
569  error() << "unable to get the AlgContextSvc" << endmsg;
570  return StatusCode::FAILURE;
571  }
572  }
573  m_ialgtools.insert( &ialg );
574  return StatusCode::SUCCESS;
575  }
576 
577  const AlgTool* alg = dynamic_cast<const AlgTool*>( &ialg );
578  if ( !alg ) {
579  error() << "Could not dcast IAlgTool \"" << ialg.name() << "\" to an AlgTool" << endmsg;
580  return StatusCode::FAILURE;
581  }
582 
583  if ( m_algtoolmap.find( alg ) != m_algtoolmap.end() ) {
584  warning() << "AlgTool " << ialg.name() << " already registered in HistorySvc" << endmsg;
585  return StatusCode::SUCCESS;
586  }
587 
588  const JobHistory* job = getJobHistory();
589  m_algtoolmap[alg] = new AlgToolHistory( *alg, job );
590 
591  ON_DEBUG {
592  auto& log = debug();
593  log << "Registering algtool: ";
594  log.setColor( MSG::CYAN );
595  log << alg->name() << endmsg;
596  log.resetColor();
597  }
598 
599  return StatusCode::SUCCESS;
600 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T...args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
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:90
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:396
#define ON_DEBUG
Definition: HistorySvc.cpp:40
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:92
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:58
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:47
constexpr static const auto FAILURE
Definition: StatusCode.h:86
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:83
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:96
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
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 435 of file HistorySvc.cpp.

435  {
436 
437  DHH dhh( id, key );
438 
439  auto boundaries = m_datMap.equal_range( dhh );
440  auto match = boundaries.second;
441 
442  if ( boundaries.first != boundaries.second ) {
443  // there is something in the map, let's look for the specific entry
444 
445  std::string algName;
446  IAlgorithm* ialg = getCurrentIAlg();
447  if ( ialg ) {
448  algName = ialg->name();
449  } else {
450  algName = "UNKNOWN";
451  }
452 
453  match = std::find_if( boundaries.first, boundaries.second,
454  [&algName]( decltype( boundaries )::first_type::reference p ) -> bool {
455  return p.second->algorithmHistory()->algorithm_name() == algName;
456  } );
457  }
458 
459  if ( match == boundaries.second ) { // not found, crete the entry
460  DataHistory* dh = createDataHistoryObj( id, key, storeName );
462  }
463 
464  return StatusCode::SUCCESS;
465 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:100
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:399
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:408
T equal_range(T...args)
StatusCode HistorySvc::registerJob ( )
override

Definition at line 339 of file HistorySvc.cpp.

339 { return StatusCode( StatusCode::SUCCESS, true ); }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
StatusCode HistorySvc::registerSvc ( const IService svc)
override

Definition at line 496 of file HistorySvc.cpp.

496  {
497 
498  if ( svc.name() == "HistoryStore" ) { return StatusCode( StatusCode::SUCCESS, true ); }
499 
500  JobHistory* job = getJobHistory();
501  const IService* psvc = &svc;
502  auto itr = m_svcmap.find( psvc );
503  if ( itr == m_svcmap.end() ) {
504 
505  ON_DEBUG {
506  auto& log = debug();
507  log << "Registering Service: ";
508  log.setColor( MSG::CYAN );
509  log << svc.name() << endmsg;
510  log.resetColor();
511  }
512 
513  m_svcmap[psvc] = new ServiceHistory( &svc, job );
514 
515  ( const_cast<IService*>( psvc ) )->addRef();
516  }
517 
518  return StatusCode( StatusCode::SUCCESS, true );
519 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T...args)
JobHistory class definition.
Definition: JobHistory.h:22
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:396
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:50
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:98
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
StatusCode HistorySvc::reinitialize ( )
override

Definition at line 77 of file HistorySvc.cpp.

77  {
78 
79  clearState();
81  return initialize();
82 }
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:153
StatusCode initialize() override
Definition: HistorySvc.cpp:111
void clearState()
Definition: HistorySvc.cpp:100
StatusCode HistorySvc::stop ( )
override

Definition at line 234 of file HistorySvc.cpp.

234  {
235 
236  if ( !m_activate ) return StatusCode::SUCCESS;
237 
238  if ( m_dump ) { listProperties().ignore(); }
239 
240  if ( !m_outputFile.empty() ) {
242  if ( !ofs ) {
243  error() << "Unable to open output file \"m_outputFile\"" << endmsg;
244  } else {
245  // dumpProperties(ofs);
246  dumpState( ofs );
247  }
248  }
249 
250  clearState();
251 
252  return StatusCode::SUCCESS;
253 }
StatusCode listProperties() const override
Definition: HistorySvc.cpp:342
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
STL class.
Gaudi::Property< bool > m_dump
Definition: HistorySvc.h:84
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:674
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
Gaudi::Property< std::string > m_outputFile
Definition: HistorySvc.h:86
void clearState()
Definition: HistorySvc.cpp:100
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
Gaudi::Property< bool > m_activate
Definition: HistorySvc.h:85

Member Data Documentation

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

Definition at line 85 of file HistorySvc.h.

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

Definition at line 94 of file HistorySvc.h.

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

Definition at line 97 of file HistorySvc.h.

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

Definition at line 100 of file HistorySvc.h.

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

Definition at line 84 of file HistorySvc.h.

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

Definition at line 96 of file HistorySvc.h.

IIncidentSvc* HistorySvc::m_incidentSvc = nullptr
private

Definition at line 116 of file HistorySvc.h.

bool HistorySvc::m_isInitialized = false
private

Definition at line 90 of file HistorySvc.h.

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

Definition at line 102 of file HistorySvc.h.

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

Definition at line 86 of file HistorySvc.h.

bool HistorySvc::m_outputFileTypeXML = false
private

Definition at line 119 of file HistorySvc.h.

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

Definition at line 98 of file HistorySvc.h.

SmartIF<IToolSvc> HistorySvc::m_toolSvc
private

Definition at line 117 of file HistorySvc.h.

IAlgContextSvc* HistorySvc::p_algCtxSvc = nullptr
private

Definition at line 92 of file HistorySvc.h.


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