The Gaudi Framework  v32r2 (46d42edc)
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 36 of file HistorySvc.h.

Member Typedef Documentation

◆ DataHistMap

Definition at line 80 of file HistorySvc.h.

◆ DHMCitr

typedef DataHistMap::const_iterator HistorySvc::DHMCitr
private

Definition at line 82 of file HistorySvc.h.

◆ DHMitr

typedef DataHistMap::iterator HistorySvc::DHMitr
private

Definition at line 81 of file HistorySvc.h.

◆ PropertyList

Definition at line 78 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 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:495
StatusCode registerAlgTool(const IAlgTool &) override
Definition: HistorySvc.cpp:563
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:27
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:85
virtual std::vector< std::string > getClients() const =0
Get the list of clients.
SmartIF< IFace > as()
Definition: ISvcLocator.h:103
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
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.
GAUDI_API ISvcLocator * svcLocator()
bool m_isInitialized
Definition: HistorySvc.h:90
T reset(T... args)
T count(T... args)
T size(T... args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
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't already exist.
Definition: Service.h:83
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: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

◆ clearState()

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

◆ createDataHistoryObj()

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

Definition at line 407 of file HistorySvc.cpp.

408  {
409 
410  if ( !m_activate ) return nullptr;
411 
412  AlgorithmHistory* algHist = nullptr;
413 
414  IAlgorithm* ialg = getCurrentIAlg();
415  if ( !ialg ) {
416  ON_DEBUG
417  debug() << "Could not discover current Algorithm:" << endl
418  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
419  algHist = nullptr;
420  } else {
421  Gaudi::Algorithm* alg = dynamic_cast<Gaudi::Algorithm*>( ialg );
422  if ( alg ) {
423  algHist = getAlgHistory( *alg );
424  } else {
425  warning() << "Could not extract concrete Algorithm:" << endl
426  << " object CLID: " << id << " key: \"" << key << "\"" << endmsg;
427  algHist = nullptr;
428  }
429  }
430  return new DataHistory( id, key, algHist );
431 }
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:398
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:324
#define ON_DEBUG
Definition: HistorySvc.cpp:40
DataHistory class definition.
Definition: DataHistory.h:23
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h: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

◆ dumpProp()

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

Definition at line 656 of file HistorySvc.cpp.

656  {
657  std::ostringstream ost;
658  if ( isXML ) {
659  while ( ind > 0 ) {
660  ost << " ";
661  ind--;
662  }
663  ost << "<PROPERTY name=\"" << prop->name() << "\" value=\"" << HistoryObj::convert_string( prop->toString() )
664  << "\" documentation=\"" << HistoryObj::convert_string( prop->documentation() ) << "\">";
665  } else {
666  prop->fillStream( ost );
667  }
668  return ost.str();
669 }
const std::string name() const
property name
Definition: Property.h:36
T str(T... args)
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
virtual std::string toString() const =0
value -> string
std::string documentation() const
property documentation
Definition: Property.h:38

◆ dumpProperties() [1/4]

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

Definition at line 377 of file HistorySvc.cpp.

377  {
378 
379  ofs << "GLOBAL" << std::endl;
380  for ( const auto& prop : m_jobHistory->propertyPairs() ) {
381  ofs << prop.first << " " << dumpProp( prop.second ) << std::endl;
382  }
383 
384  ofs << std::endl << "SERVICES" << std::endl;
385  for ( const auto& s : m_svcmap ) dumpProperties( *s.first, ofs );
386 
387  ofs << std::endl << "ALGORITHMS" << std::endl;
388  for ( const auto& alg : m_algmap ) dumpProperties( *alg.first, ofs );
389 
390  ofs << std::endl << "ALGTOOLS" << std::endl;
391  for ( const auto& tool : m_algtoolmap ) dumpProperties( *tool.first, ofs );
392 }
T endl(T... args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:377
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:656
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:71
string s
Definition: gaudirun.py:318
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

◆ dumpProperties() [2/4]

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

Definition at line 552 of file HistorySvc.cpp.

552  {
553 
554  ServiceHistory* hist = getServiceHistory( svc );
555 
556  if ( !hist ) return;
557 
558  for ( auto& prop : hist->properties() ) { ofs << svc.name() << " " << dumpProp( prop ) << std::endl; }
559 }
T endl(T... args)
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:656
ServiceHistory * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:522
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 314 of file HistorySvc.cpp.

314  {
315 
317 
318  if ( !hist ) { return; }
319 
320  for ( auto prop : hist->properties() ) { ofs << alg.name() << " " << dumpProp( prop ) << std::endl; }
321 }
AlgorithmHistory class definition.
T endl(T... args)
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:324
const PropertyList & properties() const override
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:656

◆ dumpProperties() [4/4]

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

Definition at line 617 of file HistorySvc.cpp.

617  {
618 
620 
621  if ( !hist ) return;
622 
623  for ( auto& prop : hist->properties() ) { ofs << alg.name() << " " << dumpProp( prop ) << std::endl; }
624 }
const PropertyList & properties() const override
T endl(T... args)
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:628
AlgToolHistory class definition.
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:656

◆ dumpState() [1/2]

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

Definition at line 673 of file HistorySvc.cpp.

673  {
674 
675  if ( m_outputFileTypeXML ) {
676  // xml header
677  ofs << "<?xml version=\"1.0\" ?> " << std::endl;
678  ofs << "<!--Test-xml-->" << std::endl;
679  ofs << "<SETUP>" << std::endl;
680  ofs << " <GLOBAL>" << std::endl;
681  } else {
682  ofs << "GLOBAL" << std::endl;
683  }
684 
685  std::string client_currently_open = "start";
686  for ( auto& item : m_jobHistory->propertyPairs() ) {
687  // client is the name of the component of the current property
688  const std::string& client = item.first;
689  const Gaudi::Details::PropertyBase* prp = item.second;
690 
691  if ( m_outputFileTypeXML ) {
692 
693  if ( client != client_currently_open ) {
694  if ( client_currently_open != "start" ) ofs << " </COMPONENT>" << endl;
695  ofs << " <COMPONENT name=\"" << client << "\" class=\"undefined\">" << std::endl;
696  }
697  } else {
698  ofs << client << " ";
699  }
700 
701  ofs << dumpProp( prp, m_outputFileTypeXML, 6 ) << endl;
702 
703  client_currently_open = client;
704 
705  if ( m_outputFileTypeXML ) ofs << " </COMPONENT>" << endl;
706  }
707 
708  if ( m_outputFileTypeXML ) {
709  ofs << "</GLOBAL>" << endl << "<SERVICES>" << endl;
710  } else {
711  ofs << "SERVICES" << std::endl;
712  }
713 
714  // helper to dump monitored components sorted by name
715  auto sortedDump = [&ofs, this]( const auto& map ) {
717  for ( const auto& item : map ) sorted[item.first->name()] = item.first;
718  for ( const auto& item : sorted ) dumpState( item.second, ofs );
719  };
720 
721  sortedDump( m_svcmap );
722 
723  if ( m_outputFileTypeXML ) {
724  ofs << "</SERVICES>" << endl << "<ALGORITHMS> " << endl;
725  } else {
726  ofs << "ALGORITHMS" << std::endl;
727  }
728 
729  sortedDump( m_algmap );
730 
731  if ( m_outputFileTypeXML ) {
732  ofs << "</ALGORITHMS>" << endl << "<ALGTOOLS> " << endl;
733  } else {
734  ofs << "ALGTOOLS" << std::endl;
735  }
736 
737  sortedDump( m_algtoolmap );
738 
739  if ( m_outputFileTypeXML ) { ofs << "</ALGTOOLS>" << endl << "</SETUP>" << endl; }
740 }
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:673
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
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:656
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:71
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

◆ dumpState() [2/2]

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

Definition at line 744 of file HistorySvc.cpp.

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

◆ finalize()

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)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
bool isSuccess() const
Definition: StatusCode.h:267
#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

◆ getAlgHistory() [1/2]

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

Definition at line 324 of file HistorySvc.cpp.

324  {
325 
326  auto itr = m_algmap.find( &alg );
327  if ( itr == m_algmap.end() ) {
328  warning() << "Algorithm " << alg.name() << " not registered" << endmsg;
329  return nullptr;
330  }
331  return itr->second;
332 }
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:94
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ getAlgHistory() [2/2]

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

Definition at line 335 of file HistorySvc.cpp.

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

◆ getAlgToolHistory() [1/2]

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

Definition at line 628 of file HistorySvc.cpp.

628  {
629 
630  const AlgTool* palg = dynamic_cast<const AlgTool*>( &alg );
631  auto itr = m_algtoolmap.find( palg );
632  if ( itr == m_algtoolmap.end() ) {
633  warning() << "AlgTool " << alg.name() << " not registered" << endmsg;
634  return nullptr;
635  }
636  return itr->second;
637 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T end(T... args)
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:97
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

◆ getAlgToolHistory() [2/2]

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

Definition at line 641 of file HistorySvc.cpp.

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

◆ getCurrentIAlg()

IAlgorithm * HistorySvc::getCurrentIAlg ( ) const
private

Definition at line 398 of file HistorySvc.cpp.

398  {
399  if ( p_algCtxSvc ) return p_algCtxSvc->currentAlg();
400  warning() << "trying to create DataHistoryObj before "
401  << "HistorySvc has been initialized" << endmsg;
402  return nullptr;
403 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:92
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:192

◆ getDataHistory() [1/2]

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

Definition at line 467 of file HistorySvc.cpp.

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

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

◆ getJobHistory()

JobHistory * HistorySvc::getJobHistory ( ) const
override

Definition at line 395 of file HistorySvc.cpp.

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

◆ getServiceHistory() [1/2]

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

Definition at line 522 of file HistorySvc.cpp.

522  {
523 
524  const IService* psvc = &svc;
525  auto itr = m_svcmap.find( psvc );
526  if ( itr != m_svcmap.end() ) return itr->second;
527 
528  warning() << "Service " << svc.name() << " not registered" << endmsg;
529  return nullptr;
530 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T end(T... args)
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

◆ getServiceHistory() [2/2]

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

Definition at line 533 of file HistorySvc.cpp.

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

◆ handle()

void HistorySvc::handle ( const Incident inc)
override

Definition at line 645 of file HistorySvc.cpp.

645  {
646 
647  if ( incident.type() == IncidentType::BeginEvent ) {
648  if ( captureState().isFailure() ) {
649  warning() << "Error capturing state." << endl << "Will try again at next BeginEvent incident" << endmsg;
650  }
651  }
652 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
T endl(T... args)
bool isFailure() const
Definition: StatusCode.h:130
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

◆ initialize()

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< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:277
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:117
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
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
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
IIncidentSvc * m_incidentSvc
Definition: HistorySvc.h:116
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't already exist.
Definition: Service.h:83
bool isFailure() const
Definition: StatusCode.h:130
Gaudi::Property< std::string > m_outputFile
Definition: HistorySvc.h:86
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

◆ listProperties() [1/4]

StatusCode HistorySvc::listProperties ( ) const
override

Definition at line 341 of file HistorySvc.cpp.

341  {
342 
343  auto& log = info();
344 
345  log.setColor( MSG::CYAN );
346  log << "Dumping properties for all Algorithms (" << m_algmap.size() << ")" << endmsg;
347 
348  for ( auto& alg : m_algmap ) { listProperties( *alg.first ).ignore(); }
349 
350  log << MSG::INFO;
351  log.setColor( MSG::CYAN );
352  log << "Dumping properties for all AlgTools (" << m_algtoolmap.size() << ")" << endmsg;
353 
354  for ( auto& algtool : m_algtoolmap ) {
355  ON_DEBUG
356  debug() << " --> " << algtool.second->algtool_name() << endmsg;
357  listProperties( *algtool.first ).ignore();
358  }
359 
360  log << MSG::INFO;
361  log.setColor( MSG::CYAN );
362  log << "Dumping properties for all Services (" << m_svcmap.size() << ")" << endmsg;
363 
364  for ( auto& svc : m_svcmap ) { listProperties( *svc.first ).ignore(); }
365 
366  log << MSG::INFO;
367  log.setColor( MSG::CYAN );
368  log << "Dumping properties for Job";
369  log.resetColor();
370 
371  log << std::endl << *m_jobHistory << endmsg;
372 
373  return StatusCode( StatusCode::SUCCESS, true );
374 }
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
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
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
T size(T... args)
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:94
StatusCode listProperties() const override
Definition: HistorySvc.cpp:341
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

◆ listProperties() [2/4]

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

Definition at line 537 of file HistorySvc.cpp.

537  {
538 
539  info() << "Dumping properties for " << svc.name() << endl;
540 
541  ServiceHistory* hist = getServiceHistory( svc );
542 
543  if ( !hist ) return StatusCode::FAILURE;
544 
545  info() << svc.name() << " --> " << endl << *hist << endmsg;
546 
547  return StatusCode( StatusCode::SUCCESS, true );
548 }
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
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 * getServiceHistory(const IService &) const override
Definition: HistorySvc.cpp:522
ServiceHistory class definition.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ listProperties() [3/4]

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 
305 
306  if ( !hist ) { return StatusCode::FAILURE; }
307 
308  info() << alg.name() << " --> " << endl << *hist << endmsg;
309 
310  return StatusCode( StatusCode::SUCCESS, true );
311 }
AlgorithmHistory class definition.
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
Definition: HistorySvc.cpp:324
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
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

◆ listProperties() [4/4]

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

Definition at line 603 of file HistorySvc.cpp.

603  {
604 
605  info() << "Dumping properties for " << alg.name() << endl;
606 
608 
609  if ( !hist ) return StatusCode::FAILURE;
610 
611  info() << alg.name() << " --> " << endl << *hist << endmsg;
612 
613  return StatusCode::SUCCESS;
614 }
T endl(T... args)
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
Definition: HistorySvc.cpp:628
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

◆ registerAlg()

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 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
AlgorithmHistory class definition.
JobHistory * getJobHistory() const override
Definition: HistorySvc.cpp:395
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
T end(T... args)
JobHistory class definition.
Definition: JobHistory.h:22
#define ON_DEBUG
Definition: HistorySvc.cpp:40
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
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:94
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192

◆ registerAlgTool()

StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg)
override

Definition at line 563 of file HistorySvc.cpp.

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

◆ registerDataHistory()

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

Definition at line 434 of file HistorySvc.cpp.

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

◆ registerJob()

StatusCode HistorySvc::registerJob ( )
override

Definition at line 338 of file HistorySvc.cpp.

338 { 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

◆ registerSvc()

StatusCode HistorySvc::registerSvc ( const IService svc)
override

Definition at line 495 of file HistorySvc.cpp.

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

◆ reinitialize()

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

◆ stop()

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 }
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:673
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Gaudi::Property< bool > m_dump
Definition: HistorySvc.h:84
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
StatusCode listProperties() const override
Definition: HistorySvc.cpp:341
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

◆ m_activate

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

Definition at line 85 of file HistorySvc.h.

◆ m_algmap

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

Definition at line 94 of file HistorySvc.h.

◆ m_algtoolmap

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

Definition at line 97 of file HistorySvc.h.

◆ m_datMap

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

Definition at line 100 of file HistorySvc.h.

◆ m_dump

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

Definition at line 84 of file HistorySvc.h.

◆ m_ialgtools

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

Definition at line 96 of file HistorySvc.h.

◆ m_incidentSvc

IIncidentSvc* HistorySvc::m_incidentSvc = nullptr
private

Definition at line 116 of file HistorySvc.h.

◆ m_isInitialized

bool HistorySvc::m_isInitialized = false
private

Definition at line 90 of file HistorySvc.h.

◆ m_jobHistory

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

Definition at line 102 of file HistorySvc.h.

◆ m_outputFile

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

Definition at line 86 of file HistorySvc.h.

◆ m_outputFileTypeXML

bool HistorySvc::m_outputFileTypeXML = false
private

Definition at line 119 of file HistorySvc.h.

◆ m_svcmap

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

Definition at line 98 of file HistorySvc.h.

◆ m_toolSvc

SmartIF<IToolSvc> HistorySvc::m_toolSvc
private

Definition at line 117 of file HistorySvc.h.

◆ p_algCtxSvc

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: