| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
HistorySvc Class Reference

HistorySvc class definition. More...

`#include <src/HistorySvc.h>`

Inheritance diagram for HistorySvc:
[legend]
Collaboration diagram for HistorySvc:
[legend]

## Public Member Functions
virtual StatusCode | initialize ()
virtual StatusCode | reinitialize ()
virtual StatusCode | finalize ()
virtual StatusCode | stop ()
virtual StatusCode | captureState ()
virtual StatusCode | registerJob ()
virtual StatusCode | listProperties () const
virtual JobHistory * | getJobHistory () const
virtual StatusCode | registerSvc (const IService &)
virtual StatusCode | listProperties (const IService &) const
virtual ServiceHistory * | getServiceHistory (const IService &) const
virtual void | getServiceHistory (std::set< ServiceHistory * > &) const
virtual StatusCode | registerAlg (const Algorithm &)
virtual StatusCode | listProperties (const Algorithm &) const
virtual AlgorithmHistory * | getAlgHistory (const Algorithm &) const
virtual void | getAlgHistory (std::set< AlgorithmHistory * > &) const
virtual StatusCode | registerAlgTool (const IAlgTool &)
virtual StatusCode | listProperties (const IAlgTool &) const
virtual AlgToolHistory * | getAlgToolHistory (const IAlgTool &) const
virtual void | getAlgToolHistory (std::set< AlgToolHistory * > &) const
virtual DataHistory * | createDataHistoryObj (const CLID &id, const std::string &key, const std::string &store)
virtual StatusCode | registerDataHistory (const CLID &id, const std::string &key, const std::string &store)
virtual DataHistory * | getDataHistory (const CLID &id, const std::string &key, const std::string &store) const
virtual int | getDataHistory (const CLID &id, const std::string &key, const std::string &storeName, std::list< DataHistory * > &dhlist) const
| HistorySvc (const std::string &name, ISvcLocator *svc)
virtual void | handle (const Incident &inc)
virtual | ~HistorySvc ()=default
Public Member Functions inherited from extends< Service, IHistorySvc, IIncidentListener >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () 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...
StatusCode | setProperty (const Property &p) override
StatusCode | setProperty (const std::string &s) override
StatusCode | setProperty (const std::string &n, const std::string &v) override
StatusCode | getProperty (Property *p) const override
const Property & | getProperty (const std::string &name) const override
StatusCode | getProperty (const std::string &n, std::string &v) const override
const std::vector< Property * > & | getProperties () const override
bool | hasProperty (const std::string &name) const override
template<class TYPE >
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value 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 >
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const
| Declare the named property. More...
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
| Declare remote named properties. More...
template<class T >
StatusCode | declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Private tool. More...
template<class T >
StatusCode | declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
| Declare used Public 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 CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces...>
| ~extend_interfaces () override=default
| Virtual destructor. More...

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

## Private Member Functions
void | clearState ()
void | dumpProperties (std::ofstream &) const
void | dumpProperties (const IService &, std::ofstream &) const
void | dumpProperties (const Algorithm &, std::ofstream &) const
void | dumpProperties (const IAlgTool &, std::ofstream &) const
void | dumpState (std::ofstream &) const
void | dumpState (const INamedInterface *, std::ofstream &) const
std::string | dumpProp (const Property *, const bool isXML=false, int indent=0) const
IAlgorithm * | getCurrentIAlg () const

## Private Attributes
bool | m_isInitialized = false
bool | m_dump = false
bool | m_activate = true
IAlgContextSvc * | p_algCtxSvc = nullptr
std::map< const Algorithm *, AlgorithmHistory * > | m_algmap
std::set< const IAlgTool * > | m_ialgtools
std::map< const AlgTool *, AlgToolHistory * > | m_algtoolmap
std::map< const IService *, ServiceHistory * > | m_svcmap
std::multimap< DHH, DataHistory * > | m_datMap
std::unique_ptr< JobHistory > | m_jobHistory
std::string | m_outputFile
IIncidentSvc * | m_incidentSvc = nullptr
SmartIF< IToolSvc > | m_toolSvc
MsgStream | m_log
bool | m_outputFileTypeXML = false

## Additional Inherited Members
Public Types inherited from extends< Service, IHistorySvc, IIncidentListener >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces...>
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from 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 CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
IntegerProperty | m_outputLevel = MSG::NIL
| Service output level. More...
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...

## Detailed Description

HistorySvc class definition.

Definition at line 41 of file HistorySvc.h.

## Member Typedef Documentation

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

Definition at line 98 of file HistorySvc.h.

typedef DataHistMap::const_iterator HistorySvc::DHMCitr
| private

Definition at line 100 of file HistorySvc.h.

typedef DataHistMap::iterator HistorySvc::DHMitr
| private

Definition at line 99 of file HistorySvc.h.

typedef IVersHistoryObj::PropertyList HistorySvc::PropertyList
| private

Definition at line 96 of file HistorySvc.h.

## Constructor & Destructor Documentation

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

Definition at line 76 of file HistorySvc.cpp.

77 : base_class( name, svc ),
78 m_log(msgSvc(), name )
79 {
80 declareProperty("Dump",m_dump);
81 declareProperty("Activate", m_activate=true);
82 declareProperty("OutputFile",m_outputFile);
83
84 // hack to bring in environ
85 vector<string> envtmp = System::getEnv();
86 envtmp.size(); // prevent icc remark #177: X declared but never referenced
87 }
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:617
extends< Service, IHistorySvc, IIncidentListener >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:14
HistorySvc::m_outputFile
std::string m_outputFile
Definition: HistorySvc.h:122
HistorySvc::m_activate
bool m_activate
Definition: HistorySvc.h:106
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::vector::size
T size(T...args)
std::vector
STL class.
CommonMessagingBase::msgSvc
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
Definition: CommonMessaging.h:73
HistorySvc::m_dump
bool m_dump
Definition: HistorySvc.h:105
Service::declareProperty
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215

virtual HistorySvc::~HistorySvc | ( |  | ) |
| virtual default

## Member Function Documentation

StatusCode HistorySvc::captureState | ( |  | ) |
| virtual

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 184 of file HistorySvc.cpp.

184 {
185
186 if (!m_jobHistory ) {
187 m_jobHistory.reset( new JobHistory );
188 IJobOptionsSvc *jo;
189 if (service("JobOptionsSvc",jo).isFailure()) {
190 m_log << MSG::ERROR
191 << "Could not get jobOptionsSvc - "
192 << "not adding properties to JobHistory" << endmsg;
193 } else {
194
195 bool foundAppMgr(false);
196
197 for (auto& client: jo->getClients()) {
198 if (client == "ApplicationMgr") foundAppMgr = true;
199 for (auto prop: *jo->getProperties(client)) {
200 m_jobHistory->addProperty(client, prop);
201 }
202 }
203
204 if (!foundAppMgr) {
205 auto ap = service<IProperty>("ApplicationMgr");
206 if (!ap) {
207 m_log << MSG::ERROR << "could not get the ApplicationMgr" << endmsg;
208 } else {
209 for (auto prop: ap->getProperties()) {
210 m_jobHistory->addProperty("ApplicationMgr", prop);
211 }
212 }
213 }
214
215 }
216 }
217
219
220 auto algMgr = Gaudi::svcLocator()->as<IAlgManager>();
221 if ( !algMgr ) {
222 m_log << MSG::ERROR << "Could not get AlgManager" << endmsg;
223 return StatusCode::FAILURE;
224 }
225
226 size_t count = 0;
227 for (auto ialg: algMgr->getAlgorithms()) {
228 Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
229 if ( !alg ) {
230 m_log << MSG::WARNING << "Algorithm " << ialg->name()
231 << " does not inherit from Algorithm. Not registering it."
232 << endmsg;
233 } else {
234 ++count;
235 registerAlg( *alg ).ignore();
236 }
237 }
238
239 m_log << MSG::INFO << "Registered " << count << " Algorithms" << endmsg;
240
241
242
244
245 m_isInitialized = true;
246 for (auto algtool: m_ialgtools) {
247 (const_cast<IAlgTool*>(algtool))->addRef();
248 registerAlgTool(*algtool).ignore();
249 }
250
251 m_log << MSG::INFO << "Registered " << m_algtoolmap.size() << " AlgTools"
252 << endmsg;
253
255
256 for (auto svc: Gaudi::svcLocator()->getServices()) {
257 svc->addRef();
258 registerSvc(*svc).ignore();
259 }
260
261 m_log << MSG::INFO;
262 m_log << "Registered " << Gaudi::svcLocator()->getServices().size() << " Services" << endmsg;
263
264 return StatusCode::SUCCESS;
265
266
267 }
IJobOptionsSvc::getProperties
virtual const std::vector< const Property * > * getProperties(const std::string &client) const =0
Get the properties associated to a given client.
IAlgManager
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
IJobOptionsSvc::getClients
virtual std::vector< std::string > getClients() const =0
Get the list of clients.
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
JobHistory
JobHistory class definition.
Definition: JobHistory.h:24
IJobOptionsSvc
Main interface for the JobOptions service.
Definition: IJobOptionsSvc.h:20
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
HistorySvc::m_isInitialized
bool m_isInitialized
Definition: HistorySvc.h:104
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
HistorySvc::registerSvc
virtual StatusCode registerSvc(const IService &)
Definition: HistorySvc.cpp:600
HistorySvc::registerAlgTool
virtual StatusCode registerAlgTool(const IAlgTool &)
Definition: HistorySvc.cpp:684
HistorySvc::registerAlg
virtual StatusCode registerAlg(const Algorithm &)
Definition: HistorySvc.cpp:320
std::unique_ptr::reset
T reset(T...args)
JobHistory::addProperty
void addProperty(const std::string &, const Property *)
Definition: JobHistory.cpp:84
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::count
T count(T...args)
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
std::map::size
T size(T...args)
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
MSG::ERROR
Definition: IMessageSvc.h:21
Service::service
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:144
ISvcLocator::getServices
virtual const std::list< IService * > & getServices() const =0
Get a reference to a service and create it if it does not exists.
MSG::WARNING
Definition: IMessageSvc.h:20
HistorySvc::m_ialgtools
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:112
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:120

void HistorySvc::clearState | ( |  | ) |
| private

Definition at line 115 of file HistorySvc.cpp.

115 {
116 clear(m_algmap);
117
118 m_ialgtools.clear();
119 clear(m_algtoolmap);
120
121 clear(m_svcmap);
122 }
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
std::set::clear
T clear(T...args)
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110
HistorySvc::m_ialgtools
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:112
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114

DataHistory * HistorySvc::createDataHistoryObj | ( | const CLID & | id,
|  | const std::string & | key,
|  | const std::string & | store
| ) |  |
| virtual

Definition at line 495 of file HistorySvc.cpp.

496 {
497
498 if (!m_activate) return nullptr;
499
500
501 AlgorithmHistory *algHist = nullptr;
502
503 IAlgorithm* ialg = getCurrentIAlg();
504 if ( !ialg ) {
505 ON_DEBUG
506 m_log << MSG::DEBUG
507 << "Could not discover current Algorithm:" << endl
508 << " object CLID: " << id << " key: \"" << key
509 << "\"" << endmsg;
510 algHist = nullptr;
511 } else {
512 Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
513 if ( alg ) {
514 algHist = getAlgHistory( *alg );
515 } else {
516 m_log << MSG::WARNING
517 << "Could not extract concrete Algorithm:"
518 << endl
519 << " object CLID: " << id << " key: \"" << key
520 << "\"" << endmsg;
521 algHist = nullptr;
522 }
523 }
524 return new DataHistory(id, key, algHist);
525 }
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:27
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
HistorySvc::getCurrentIAlg
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:484
HistorySvc::m_activate
bool m_activate
Definition: HistorySvc.h:106
ON_DEBUG
#define ON_DEBUG
Definition: HistorySvc.cpp:40
DataHistory
DataHistory class definition.
Definition: DataHistory.h:23
HistorySvc::getAlgHistory
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:381
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
MSG::WARNING
Definition: IMessageSvc.h:20
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

std::string HistorySvc::dumpProp | ( | const Property * | prop,
|  | const bool | isXML = `false`,
|  | int | indent = `0`
| ) |  | const
| private

Definition at line 797 of file HistorySvc.cpp.

797 {
798 std::ostringstream ost;
799 if (isXML) {
800 while (ind > 0) {
801 ost << " ";
802 ind --;
803 }
804 ost << "<PROPERTY name=\"" << prop->name()
805 << "\" value=\"" << HistoryObj::convert_string(prop->toString())
806 << "\" documentation=\"" << HistoryObj::convert_string(prop->documentation())
807 << "\">";
808 } else {
809 prop->fillStream(ost);
810 }
811 return ost.str();
812 }
Property::toString
virtual std::string toString() const =0
value -> string
Property::name
const std::string & name() const
property name
Definition: Property.h:45
Property::documentation
const std::string & documentation() const
property documentation
Definition: Property.h:47
Property::fillStream
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
Definition: Property.cpp:111
std::ostringstream
STL class.
std::ostringstream::str
T str(T...args)
HistoryObj::convert_string
static std::string convert_string(const std::string &)
Definition: HistoryObj.cpp:21

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

Definition at line 456 of file HistorySvc.cpp.

456 {
457
458 ofs << "GLOBAL" << std::endl;
459 for (const auto & prop : m_jobHistory->propertyPairs() ) {
460 ofs << prop.first << " " << dumpProp(prop.second) << std::endl;
461 }
462
463 ofs << std::endl << "SERVICES" << std::endl;
464 for (const auto &s : m_svcmap ) dumpProperties( *s.first, ofs );
465
466 ofs << std::endl << "ALGORITHMS" << std::endl;
467 for (const auto & alg : m_algmap ) dumpProperties( *alg.first, ofs );
468
469 ofs << std::endl << "ALGTOOLS" << std::endl;
470 for (const auto& tool : m_algtoolmap ) dumpProperties( *tool.first, ofs );
471
472 }
std::endl
T endl(T...args)
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
JobHistory::propertyPairs
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:79
HistorySvc::dumpProp
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:797
HistorySvc::dumpProperties
void dumpProperties(std::ofstream &) const
Definition: HistorySvc.cpp:456
gaudirun.s
string s
Definition: gaudirun.py:245
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:120

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

Definition at line 669 of file HistorySvc.cpp.

669 {
670
671 ServiceHistory *hist = getServiceHistory( svc );
672
673 if ( !hist ) return;
674
675 for (auto &prop: hist->properties()) {
676 ofs << svc.name() << " " << dumpProp(prop) << std::endl;
677 }
678
679 }
HistorySvc::getServiceHistory
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:632
std::endl
T endl(T...args)
HistorySvc::dumpProp
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:797
ServiceHistory::properties
const PropertyList & properties() const
Definition: ServiceHistory.h:36
ServiceHistory
ServiceHistory class definition.
Definition: ServiceHistory.h:22

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

Definition at line 364 of file HistorySvc.cpp.

364 {
365
366 AlgorithmHistory *hist = getAlgHistory( alg );
367
368 if ( !hist ) {
369 return;
370 }
371
372 PropertyList::const_iterator itr;
373 for (auto prop: hist->properties()) {
374 ofs << alg.name() << " " << dumpProp(prop) << std::endl;
375 }
376
377 }
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:27
std::endl
T endl(T...args)
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
HistorySvc::getAlgHistory
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:381
HistorySvc::dumpProp
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:797
AlgorithmHistory::properties
const PropertyList & properties() const
Definition: AlgorithmHistory.h:88

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

Definition at line 744 of file HistorySvc.cpp.

744 {
745
746 AlgToolHistory *hist = getAlgToolHistory( alg );
747
748 if ( !hist ) return;
749
750 for (auto& prop: hist->properties()) {
751 ofs << alg.name() << " " << dumpProp(prop) << std::endl;
752 }
753
754 }
std::endl
T endl(T...args)
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
HistorySvc::getAlgToolHistory
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:759
AlgToolHistory::properties
const PropertyList & properties() const
Definition: AlgToolHistory.h:75
HistorySvc::dumpProp
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:797
AlgToolHistory
AlgToolHistory class definition.
Definition: AlgToolHistory.h:22

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

Definition at line 817 of file HistorySvc.cpp.

817 {
818
819
820 if(m_outputFileTypeXML) {
821 //xml header
822 ofs << "<?xml version=\"1.0\" ?> " << std::endl;
823 ofs << "<!--Test-xml-->" << std::endl;
824 ofs << "<SETUP>" << std::endl;
825 ofs << " <GLOBAL>" << std::endl;
826 } else {
827 ofs << "GLOBAL" << std::endl;
828 }
829
830 std::string client_currently_open = "start";
831 for (auto& item: m_jobHistory->propertyPairs()) {
832 // client is the name of the component of the current property
833 const std::string& client = item.first;
834 const Property* prp = item.second;
835
836 if (m_outputFileTypeXML) {
837
838 if (client != client_currently_open) {
839 if(client_currently_open!="start") ofs << " </COMPONENT>" << endl;
840 ofs << " <COMPONENT name=\""
841 << client << "\" class=\"undefined\">" << std::endl;
842 }
843 } else {
844 ofs << client << " ";
845 }
846
847 ofs << dumpProp(prp,m_outputFileTypeXML,6) << endl;
848
849 client_currently_open = client;
850
851 if (m_outputFileTypeXML)
852 ofs << " </COMPONENT>" << endl;
853 }
854
855
856 if(m_outputFileTypeXML) {
857 ofs << "</GLOBAL>" << endl << "<SERVICES>" << endl;
858 } else {
859 ofs << "SERVICES" << std::endl;
860 }
861
862 for (auto& item: m_svcmap) {
863 const IService* svc = item.first;
864 dumpState(svc, ofs);
865 }
866
867 if(m_outputFileTypeXML) {
868 ofs << "</SERVICES>" << endl << "<ALGORITHMS> " << endl;
869 } else {
870 ofs << "ALGORITHMS" << std::endl;
871 }
872
873 for (auto& item: m_algmap) {
874 const Algorithm* alg = item.first;
875 dumpState(alg, ofs);
876 }
877
878
879 if(m_outputFileTypeXML) {
880 ofs << "</ALGORITHMS>" << endl << "<ALGTOOLS> " << endl;
881 } else {
882 ofs << "ALGTOOLS" << std::endl;
883 }
884
885 for (auto& item: m_algtoolmap) {
886 const AlgTool* algtool = item.first;
887 dumpState(algtool, ofs);
888 }
889
890 if(m_outputFileTypeXML) {
891 ofs << "</ALGTOOLS>" << endl << "</SETUP>" << endl;
892 }
893
894 }
std::endl
T endl(T...args)
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
std::string
STL class.
IService
General service interface definition.
Definition: IService.h:18
HistorySvc::m_outputFileTypeXML
bool m_outputFileTypeXML
Definition: HistorySvc.h:141
JobHistory::propertyPairs
const PropertyPairList & propertyPairs() const
Definition: JobHistory.h:79
HistorySvc::dumpProp
std::string dumpProp(const Property *, const bool isXML=false, int indent=0) const
Definition: HistorySvc.cpp:797
HistorySvc::dumpState
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:817
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
Property
Property base class allowing Property* collections to be "homogeneous".
Definition: Property.h:38
AlgTool
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
ana.item
tuple item
print s1,s2
Definition: ana.py:146
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:120

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

Definition at line 899 of file HistorySvc.cpp.

899 {
900
901 HistoryObj *hist = nullptr;
902 IVersHistoryObj *vhist = nullptr;
903
904 const IService* is = nullptr;
905 const Algorithm* ia = nullptr;
906 const IAlgTool* it = nullptr;
907 if ( (is=dynamic_cast<const IService*>(in)) != nullptr) {
908 ON_VERBOSE
909 m_log << MSG::VERBOSE << in->name() << " is Service" << endmsg;
910 ServiceHistory* o = getServiceHistory( *is );
911 hist = dynamic_cast<HistoryObj*>( o );
912 vhist = dynamic_cast<IVersHistoryObj*>( o );
913 } else if ( (ia = dynamic_cast<const Algorithm*>(in)) != nullptr ) {
914 ON_VERBOSE
915 m_log << MSG::VERBOSE << in->name() << " is Alg" << endmsg;
916 AlgorithmHistory *o = getAlgHistory( *ia );
917 hist = dynamic_cast<HistoryObj*>( o );
918 vhist = dynamic_cast<IVersHistoryObj*>( o );
919 } else if ( (it = dynamic_cast<const IAlgTool*>(in)) != nullptr ) {
920 ON_VERBOSE
921 m_log << MSG::VERBOSE << in->name() << " is AlgTool" << endmsg;
922 AlgToolHistory *o = getAlgToolHistory( *it );
923 hist = dynamic_cast<HistoryObj*>( o );
924 vhist = dynamic_cast<IVersHistoryObj*>( o );
925 } else {
926 m_log << MSG::ERROR
927 << "Could not dcast interface to accepted History Obj type for "
928 << in->name() << endmsg;
929 return;
930 }
931
932 if ( !hist || !vhist ) {
933 m_log << MSG::ERROR << "Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
934 << endmsg;
935 return;
936 }
937
938 if (m_outputFileTypeXML) {
939 hist->dump(ofs,true);
940 } else {
941 ofs << ">> " << vhist->name() << endl << *hist << endl;
942 }
943
944 }
HistorySvc::getServiceHistory
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:632
HistoryObj::dump
virtual void dump(std::ostream &, const bool isXML=false, int indent=0) const =0
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:27
std::endl
T endl(T...args)
HistoryObj
Base class for History Objects.
Definition: HistoryObj.h:22
MSG::VERBOSE
Definition: IMessageSvc.h:17
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
HistorySvc::getAlgToolHistory
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:759
IService
General service interface definition.
Definition: IService.h:18
HistorySvc::m_outputFileTypeXML
bool m_outputFileTypeXML
Definition: HistorySvc.h:141
HistorySvc::getAlgHistory
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:381
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
AlgToolHistory
AlgToolHistory class definition.
Definition: AlgToolHistory.h:22
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
ServiceHistory
ServiceHistory class definition.
Definition: ServiceHistory.h:22
IVersHistoryObj::name
virtual const std::string & name() const =0
MSG::ERROR
Definition: IMessageSvc.h:21
ON_VERBOSE
#define ON_VERBOSE
Definition: HistorySvc.cpp:41
IVersHistoryObj
Interface for Versioned History Objects.
Definition: IVersHistoryObj.h:18
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode HistorySvc::finalize | ( |  | ) |
| virtual

Definition at line 298 of file HistorySvc.cpp.

298 {
299
300 ON_VERBOSE
301 m_log << MSG::VERBOSE << "HistorySvc::finalize()" << endmsg;
302
303 clearState();
304
305 StatusCode status = Service::finalize();
306
307 if ( status.isSuccess() )
308 m_log << MSG::INFO << "Service finalised successfully" << endmsg;
309
310 return status;
311
312 }
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:193
StatusCode::isSuccess
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
MSG::VERBOSE
Definition: IMessageSvc.h:17
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
ON_VERBOSE
#define ON_VERBOSE
Definition: HistorySvc.cpp:41
MSG::INFO
Definition: IMessageSvc.h:19
HistorySvc::clearState
void clearState()
Definition: HistorySvc.cpp:115
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

AlgorithmHistory * HistorySvc::getAlgHistory | ( | const Algorithm & | alg | ) | const
| virtual

Definition at line 381 of file HistorySvc.cpp.

381 {
382
383 auto itr = m_algmap.find( &alg );
384 if ( itr == m_algmap.end() ) {
385 m_log << MSG::WARNING << "Algorithm " << alg.name() << " not registered"
386 << endmsg;
387 return nullptr;
388 }
389 return itr->second;
390 }
std::map::end
T end(T...args)
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::map::find
T find(T...args)
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110
MSG::WARNING
Definition: IMessageSvc.h:20
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 394 of file HistorySvc.cpp.

394 {
395 map_to_set(m_algmap, algs);
396 }
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110

AlgToolHistory * HistorySvc::getAlgToolHistory | ( | const IAlgTool & | alg | ) | const
| virtual

Definition at line 759 of file HistorySvc.cpp.

759 {
760
761 const AlgTool *palg = dynamic_cast<const AlgTool*>(&alg);
762 auto itr = m_algtoolmap.find(palg);
763 if ( itr == m_algtoolmap.end() ) {
764 m_log << MSG::WARNING << "AlgTool " << alg.name() << " not registered"
765 << endmsg;
766 return nullptr;
767 }
768 return itr->second;
769
770 }
std::map::end
T end(T...args)
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::map::find
T find(T...args)
AlgTool
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
MSG::WARNING
Definition: IMessageSvc.h:20
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 775 of file HistorySvc.cpp.

775 {
776 map_to_set(m_algtoolmap, algs);
777 }
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113

IAlgorithm * HistorySvc::getCurrentIAlg | ( |  | ) | const
| private

Definition at line 484 of file HistorySvc.cpp.

484 {
485 if ( p_algCtxSvc ) return p_algCtxSvc->currentAlg();
486 m_log << MSG::WARNING << "trying to create DataHistoryObj before "
487 << "HistorySvc has been initialized" << endmsg;
488 return nullptr;
489 }
HistorySvc::p_algCtxSvc
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
MSG::WARNING
Definition: IMessageSvc.h:20
IAlgContextSvc::currentAlg
virtual IAlgorithm * currentAlg() const =0
accessor to current algorithm:
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

DataHistory * HistorySvc::getDataHistory | ( | const CLID & | id,
|  | const std::string & | key,
|  | const std::string & | store
| ) |  | const
| virtual

Definition at line 566 of file HistorySvc.cpp.

567 {
568
569 DHH dhh(id,key);
570
571 auto mitr = m_datMap.equal_range(dhh);
572 return (mitr.first != mitr.second) ? mitr.first->second
573 : nullptr ;
574
575 }
DHH
Definition: HistorySvc.cpp:61
HistorySvc::m_datMap
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:116
std::multimap::equal_range
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 580 of file HistorySvc.cpp.

582 {
583
584 DHH dhh(id,key);
585
586 int n(0);
587
588 auto mitr = m_datMap.equal_range(dhh);
589 for (auto itr=mitr.first; itr != mitr.second; ++itr) {
590 dhlist.push_back(itr->second);
591 ++n;
592 }
593 return n;
594
595 }
DHH
Definition: HistorySvc.cpp:61
HistorySvc::m_datMap
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:116
GaudiPluginService.cpluginsvc.n
list n
Definition: cpluginsvc.py:217
std::list::push_back
T push_back(T...args)
std::multimap::equal_range
T equal_range(T...args)

JobHistory * HistorySvc::getJobHistory | ( |  | ) | const
| virtual

Definition at line 476 of file HistorySvc.cpp.

476 {
477
478 return m_jobHistory.get();
479
480 }
std::unique_ptr::get
T get(T...args)
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:120

ServiceHistory * HistorySvc::getServiceHistory | ( | const IService & | svc | ) | const
| virtual

Definition at line 632 of file HistorySvc.cpp.

632 {
633
634 const IService *psvc = &svc;
635 auto itr = m_svcmap.find(psvc);
636 if ( itr != m_svcmap.end() ) return itr->second;
637
638 m_log << MSG::WARNING << "Service " << svc.name() << " not registered"
639 << endmsg;
640 return nullptr;
641 }
std::map::end
T end(T...args)
IService
General service interface definition.
Definition: IService.h:18
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::map::find
T find(T...args)
MSG::WARNING
Definition: IMessageSvc.h:20
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

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

Definition at line 645 of file HistorySvc.cpp.

645 {
646 map_to_set(m_svcmap, svcs);
647 }
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114

void HistorySvc::handle | ( | const Incident & | inc | ) |
| virtual

Definition at line 782 of file HistorySvc.cpp.

782 {
783
784 if (incident.type() == IncidentType::BeginEvent) {
785 if (captureState().isFailure()) {
786 m_log << MSG::WARNING << "Error capturing state." << endl
787 << "Will try again at next BeginEvent incident" << endmsg;
788 }
789 }
790
791 }
std::endl
T endl(T...args)
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
MSG::WARNING
Definition: IMessageSvc.h:20
HistorySvc::captureState
virtual StatusCode captureState()
Definition: HistorySvc.cpp:184
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode HistorySvc::initialize | ( |  | ) |
| virtual

Definition at line 127 of file HistorySvc.cpp.

127 {
128
129 StatusCode status = Service::initialize();
130 m_log.setLevel( m_outputLevel.value() );
131
132 if (status.isFailure()) {
133
134 ON_DEBUG
135 m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
136 << endmsg;
137 return status;
138 }
139
140 ON_DEBUG
141 m_log << MSG::DEBUG << "Initializing HistorySvc" << endmsg;
142
143 if (!m_activate) return StatusCode::SUCCESS;
144
145 static const bool CREATEIF(true);
146
147 if ( service("AlgContextSvc",p_algCtxSvc,CREATEIF).isFailure() ) {
148 m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
149 return StatusCode::FAILURE;
150 }
151
152 if (service("IncidentSvc", m_incidentSvc, CREATEIF).isFailure()) {
153 m_log << MSG::ERROR << "unable to get the IncidentSvc" << endmsg;
154 return StatusCode::FAILURE;
155 }
156
157 // create a weak dependency on the ToolSvc, so that it doesn't get deleted
158 // before we're done with it in finalize
159 m_toolSvc = serviceLocator()->service("ToolSvc");
160 if (! m_toolSvc) {
161 m_log << MSG::ERROR << "could not retrieve the ToolSvc handle !"
162 << endmsg;
163 return StatusCode::FAILURE;
164 }
165
166 // add listener to be triggered by first BeginEvent with low priority
167 // so it gets called first
168 const bool rethrow = false;
169 const bool oneShot = true; // make the listener called only once
170 m_incidentSvc->addListener(this,IncidentType::BeginEvent,
171 std::numeric_limits<long>::min(),rethrow,oneShot);
172
173 m_outputFileTypeXML = ba::iends_with( m_outputFile, ".xml");
174 ON_DEBUG if (m_outputFileTypeXML ) {
175 m_log << MSG::DEBUG << "output format is XML" << endmsg;
176 }
177
178 m_isInitialized = true;
179
180 return StatusCode::SUCCESS;
181 }
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:68
Service::m_outputLevel
IntegerProperty m_outputLevel
Service output level.
Definition: Service.h:309
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
HistorySvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Definition: HistorySvc.h:138
MSG::DEBUG
Definition: IMessageSvc.h:18
HistorySvc::m_outputFile
std::string m_outputFile
Definition: HistorySvc.h:122
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
HistorySvc::m_activate
bool m_activate
Definition: HistorySvc.h:106
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
HistorySvc::m_isInitialized
bool m_isInitialized
Definition: HistorySvc.h:104
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
ON_DEBUG
#define ON_DEBUG
Definition: HistorySvc.cpp:40
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::m_outputFileTypeXML
bool m_outputFileTypeXML
Definition: HistorySvc.h:141
HistorySvc::p_algCtxSvc
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
PropertyWithValue::value
const TYPE & value() const
explicit conversion
Definition: Property.h:341
HistorySvc::m_incidentSvc
IIncidentSvc * m_incidentSvc
Definition: HistorySvc.h:137
IIncidentSvc::addListener
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
MsgStream::setLevel
void setLevel(int level)
Update outputlevel.
Definition: MsgStream.h:106
MSG::ERROR
Definition: IMessageSvc.h:21
Service::service
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:144
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
std::numeric_limits

StatusCode HistorySvc::listProperties | ( |  | ) | const
| virtual

Definition at line 412 of file HistorySvc.cpp.

412 {
413
414 m_log << MSG::INFO;
415 m_log.setColor(MSG::CYAN);
416 m_log << "Dumping properties for all Algorithms (" << m_algmap.size()
417 << ")" << endmsg;
418
419 for (auto& alg: m_algmap) {
420 listProperties(*alg.first).ignore();
421 }
422
423 m_log << MSG::INFO;
424 m_log.setColor(MSG::CYAN);
425 m_log << "Dumping properties for all AlgTools (" << m_algtoolmap.size()
426 << ")" << endmsg;
427
428 for (auto& algtool: m_algtoolmap) {
429 ON_DEBUG
430 m_log << MSG::DEBUG << " --> " << algtool.second->algtool_name() << endmsg;
431 listProperties(*algtool.first).ignore();
432 }
433
434 m_log << MSG::INFO;
435 m_log.setColor(MSG::CYAN);
436 m_log << "Dumping properties for all Services (" << m_svcmap.size()
437 << ")" << endmsg;
438
439 for (auto& svc: m_svcmap) {
440 listProperties(*svc.first).ignore();
441 }
442
443 m_log << MSG::INFO;
444 m_log.setColor(MSG::CYAN);
445 m_log << "Dumping properties for Job";
446 m_log.resetColor();
447
448 m_log << std::endl << *m_jobHistory << endmsg;
449
450 return StatusCode(StatusCode::SUCCESS,true);
451
452 }
MsgStream::resetColor
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:108
MSG::CYAN
Definition: IMessageSvc.h:33
MSG::DEBUG
Definition: IMessageSvc.h:18
std::endl
T endl(T...args)
HistorySvc::listProperties
virtual StatusCode listProperties() const
Definition: HistorySvc.cpp:412
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
MsgStream::setColor
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:81
StatusCode::SUCCESS
Definition: StatusCode.h:30
ON_DEBUG
#define ON_DEBUG
Definition: HistorySvc.cpp:40
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::map::size
T size(T...args)
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
MSG::INFO
Definition: IMessageSvc.h:19
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
HistorySvc::m_jobHistory
std::unique_ptr< JobHistory > m_jobHistory
Definition: HistorySvc.h:120

StatusCode HistorySvc::listProperties | ( | const IService & | svc | ) | const
| virtual

Definition at line 652 of file HistorySvc.cpp.

652 {
653
654 m_log << MSG::INFO << "Dumping properties for " << svc.name() << endl;
655
656 ServiceHistory *hist = getServiceHistory( svc );
657
658 if ( !hist ) return StatusCode::FAILURE;
659
660 m_log << MSG::INFO << svc.name() << " --> " << endl << *hist << endmsg;
661
662 return StatusCode(StatusCode::SUCCESS,true);
663
664 }
HistorySvc::getServiceHistory
virtual ServiceHistory * getServiceHistory(const IService &) const
Definition: HistorySvc.cpp:632
std::endl
T endl(T...args)
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
ServiceHistory
ServiceHistory class definition.
Definition: ServiceHistory.h:22
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode HistorySvc::listProperties | ( | const Algorithm & | alg | ) | const
| virtual

Definition at line 346 of file HistorySvc.cpp.

346 {
347
348 m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
349
350 AlgorithmHistory *hist = getAlgHistory( alg );
351
352 if ( !hist ) {
353 return StatusCode::FAILURE;
354 }
355
356 m_log << MSG::INFO << alg.name() << " --> " << endl << *hist << endmsg;
357
358 return StatusCode(StatusCode::SUCCESS,true);
359
360 }
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:27
std::endl
T endl(T...args)
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::getAlgHistory
virtual AlgorithmHistory * getAlgHistory(const Algorithm &) const
Definition: HistorySvc.cpp:381
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode HistorySvc::listProperties | ( | const IAlgTool & | alg | ) | const
| virtual

Definition at line 727 of file HistorySvc.cpp.

727 {
728
729 m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
730
731 AlgToolHistory *hist = getAlgToolHistory( alg );
732
733 if ( !hist ) return StatusCode::FAILURE;
734
735
736 m_log << MSG::INFO << alg.name() << " --> " << endl << *hist << endmsg;
737
738 return StatusCode::SUCCESS;
739
740 }
std::endl
T endl(T...args)
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
HistorySvc::getAlgToolHistory
virtual AlgToolHistory * getAlgToolHistory(const IAlgTool &) const
Definition: HistorySvc.cpp:759
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
AlgToolHistory
AlgToolHistory class definition.
Definition: AlgToolHistory.h:22
MSG::INFO
Definition: IMessageSvc.h:19
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

StatusCode HistorySvc::registerAlg | ( | const Algorithm & | alg | ) |
| virtual

Definition at line 320 of file HistorySvc.cpp.

320 {
321
322 JobHistory *job = getJobHistory();
323 if (m_algmap.find(&alg) != m_algmap.end()) {
324 m_log << MSG::WARNING << "Algorithm " << alg.name()
325 << " already registered with HistorySvc" << endmsg;
326 return StatusCode::SUCCESS;
327 }
328
329 (const_cast<Algorithm*>(&alg))->addRef();
330
331 m_algmap[&alg] = new AlgorithmHistory(alg, job);
332
333 ON_DEBUG {
334 m_log << MSG::DEBUG << "Registering algorithm: ";
335 m_log.setColor(MSG::CYAN);
336 m_log << alg.name() << endmsg;
337 m_log.resetColor();
338 }
339
340 return StatusCode(StatusCode::SUCCESS,true);
341
342 }
MsgStream::resetColor
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:108
MSG::CYAN
Definition: IMessageSvc.h:33
AlgorithmHistory
AlgorithmHistory class definition.
Definition: AlgorithmHistory.h:27
MSG::DEBUG
Definition: IMessageSvc.h:18
std::map::end
T end(T...args)
JobHistory
JobHistory class definition.
Definition: JobHistory.h:24
Algorithm::name
const std::string & name() const override
The identifying name of the algorithm object.
Definition: Algorithm.cpp:820
MsgStream::setColor
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:81
StatusCode::SUCCESS
Definition: StatusCode.h:30
ON_DEBUG
#define ON_DEBUG
Definition: HistorySvc.cpp:40
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
std::map::find
T find(T...args)
HistorySvc::m_algmap
std::map< const Algorithm *, AlgorithmHistory * > m_algmap
Definition: HistorySvc.h:110
MSG::WARNING
Definition: IMessageSvc.h:20
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
HistorySvc::getJobHistory
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:476

StatusCode HistorySvc::registerAlgTool | ( | const IAlgTool & | ialg | ) |
| virtual

Definition at line 684 of file HistorySvc.cpp.

684 {
685
686 if (! m_isInitialized) {
687 if ( !p_algCtxSvc ) {
688 if ( service("AlgContextSvc",p_algCtxSvc,true).isFailure() ) {
689 m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
690 return StatusCode::FAILURE;
691 }
692 }
693 m_ialgtools.insert(&ialg);
694 return StatusCode::SUCCESS;
695 }
696
697 const AlgTool *alg = dynamic_cast<const AlgTool*>( &ialg );
698 if ( !alg ) {
699 m_log << MSG::ERROR << "Could not dcast IAlgTool \"" << ialg.name()
700 << "\" to an AlgTool" << endmsg;
701 return StatusCode::FAILURE;
702 }
703
704 if (m_algtoolmap.find(alg) != m_algtoolmap.end()) {
705 m_log << MSG::WARNING << "AlgTool " << ialg.name()
706 << " already registered in HistorySvc" << endmsg;
707 return StatusCode::SUCCESS;
708 }
709
710 const JobHistory *job = getJobHistory();
711 m_algtoolmap[alg] = new AlgToolHistory(*alg, job);
712
713 if (m_log.level() <= MSG::DEBUG) {
714 m_log << MSG::DEBUG << "Registering algtool: ";
715 m_log.setColor(MSG::CYAN);
716 m_log << alg->name() << endmsg;
717 m_log.resetColor();
718 }
719
720 return StatusCode::SUCCESS;
721
722 }
MsgStream::resetColor
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:108
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
MSG::CYAN
Definition: IMessageSvc.h:33
MSG::DEBUG
Definition: IMessageSvc.h:18
std::map::end
T end(T...args)
HistorySvc::m_algtoolmap
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
Definition: HistorySvc.h:113
JobHistory
JobHistory class definition.
Definition: JobHistory.h:24
INamedInterface::name
virtual const std::string & name() const =0
Retrieve the name of the instance.
MsgStream::setColor
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:81
HistorySvc::m_isInitialized
bool m_isInitialized
Definition: HistorySvc.h:104
StatusCode::FAILURE
Definition: StatusCode.h:29
StatusCode::SUCCESS
Definition: StatusCode.h:30
HistorySvc::p_algCtxSvc
IAlgContextSvc * p_algCtxSvc
Definition: HistorySvc.h:108
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
AlgToolHistory
AlgToolHistory class definition.
Definition: AlgToolHistory.h:22
std::set::insert
T insert(T...args)
std::map::find
T find(T...args)
AlgTool
Base class from which all the concrete tool classes should be derived.
Definition: AlgTool.h:45
MSG::ERROR
Definition: IMessageSvc.h:21
Service::service
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:144
MSG::WARNING
Definition: IMessageSvc.h:20
HistorySvc::m_ialgtools
std::set< const IAlgTool * > m_ialgtools
Definition: HistorySvc.h:112
AlgTool::name
const std::string & name() const override
Retrieve full identifying name of the concrete tool object.
Definition: AlgTool.cpp:65
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
HistorySvc::getJobHistory
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:476

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

Definition at line 529 of file HistorySvc.cpp.

530 {
531
532 DHH dhh(id,key);
533
534 auto boundaries = m_datMap.equal_range(dhh);
535 auto match = boundaries.second;
536
537 if (boundaries.first != boundaries.second) {
538 // there is something in the map, let's look for the specific entry
539
540 std::string algName;
541 IAlgorithm *ialg = getCurrentIAlg();
542 if (ialg) {
543 algName = ialg->name();
544 } else {
545 algName = "UNKNOWN";
546 }
547
548 match = std::find_if(boundaries.first, boundaries.second,
549 [&algName](decltype(boundaries)::first_type::reference p) -> bool {
550 return p.second->algorithmHistory()->algorithm_name() == algName;
551 });
552 }
553
554 if (match == boundaries.second) { // not found, crete the entry
555 DataHistory *dh = createDataHistoryObj(id, key, storeName);
556 m_datMap.insert(pair<DHH, DataHistory*>(dhh,dh));
557 }
558
559 return StatusCode::SUCCESS;
560
561 }
DHH
Definition: HistorySvc.cpp:61
HistorySvc::m_datMap
std::multimap< DHH, DataHistory * > m_datMap
Definition: HistorySvc.h:116
HistorySvc::getCurrentIAlg
IAlgorithm * getCurrentIAlg() const
Definition: HistorySvc.cpp:484
std::string
STL class.
StatusCode::SUCCESS
Definition: StatusCode.h:30
DataHistory
DataHistory class definition.
Definition: DataHistory.h:23
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
std::pair
std::multimap::insert
T insert(T...args)
HistorySvc::createDataHistoryObj
virtual DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store)
Definition: HistorySvc.cpp:495
std::find_if
T find_if(T...args)
Objects::reference
TO * reference(FROM *from)
Definition: KeyedObject.cpp:20
std::multimap::equal_range
T equal_range(T...args)

StatusCode HistorySvc::registerJob | ( |  | ) |
| virtual

Definition at line 401 of file HistorySvc.cpp.

401 {
402
403
404 return StatusCode(StatusCode::SUCCESS,true);
405
406
407 }
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26

StatusCode HistorySvc::registerSvc | ( | const IService & | svc | ) |
| virtual

Definition at line 600 of file HistorySvc.cpp.

600 {
601
602 if ( svc.name() == "HistoryStore" ) {
603 // m_log << MSG::WARNING << "not registering store" << endmsg;
604 return StatusCode(StatusCode::SUCCESS,true);
605 }
606
607 JobHistory *job = getJobHistory();
608 const IService* psvc = &svc;
609 auto itr = m_svcmap.find(psvc);
610 if (itr == m_svcmap.end()) {
611
612 if (m_log.level() <= MSG::DEBUG) {
613 m_log << MSG::DEBUG << "Registering Service: ";
614 m_log.setColor(MSG::CYAN);
615 m_log << svc.name() << endmsg;
616 }
617
618 m_svcmap[psvc] = new ServiceHistory(&svc, job);
619
620 (const_cast<IService*>(psvc))->addRef();
621
622 }
623
624 m_log.resetColor();
625 return StatusCode(StatusCode::SUCCESS,true);
626
627 }
MsgStream::resetColor
GAUDI_API void resetColor()
Reset the colors to defaults.
Definition: MsgStream.cpp:108
MsgStream::level
MSG::Level level()
Retrieve output level.
Definition: MsgStream.h:112
MSG::CYAN
Definition: IMessageSvc.h:33
MSG::DEBUG
Definition: IMessageSvc.h:18
std::map::end
T end(T...args)
JobHistory
JobHistory class definition.
Definition: JobHistory.h:24
MsgStream::setColor
GAUDI_API void setColor(MSG::Color col)
Set the text color.
Definition: MsgStream.cpp:81
IService
General service interface definition.
Definition: IService.h:18
StatusCode::SUCCESS
Definition: StatusCode.h:30
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
std::map::find
T find(T...args)
ServiceHistory
ServiceHistory class definition.
Definition: ServiceHistory.h:22
HistorySvc::m_svcmap
std::map< const IService *, ServiceHistory * > m_svcmap
Definition: HistorySvc.h:114
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
HistorySvc::getJobHistory
virtual JobHistory * getJobHistory() const
Definition: HistorySvc.cpp:476

StatusCode HistorySvc::reinitialize | ( |  | ) |
| virtual

Definition at line 91 of file HistorySvc.cpp.

91 {
92
93 clearState();
94 m_state = Gaudi::StateMachine::OFFLINE;
95 return initialize();
96
97 }
Service::m_state
Gaudi::StateMachine::State m_state
Service state.
Definition: Service.h:311
HistorySvc::initialize
virtual StatusCode initialize()
Definition: HistorySvc.cpp:127
Gaudi::StateMachine::OFFLINE
Definition: StateMachine.h:13
HistorySvc::clearState
void clearState()
Definition: HistorySvc.cpp:115

StatusCode HistorySvc::stop | ( |  | ) |
| virtual

Definition at line 271 of file HistorySvc.cpp.

271 {
272
273 if (!m_activate) return StatusCode::SUCCESS;
274
275 if (m_dump) {
276 listProperties().ignore();
277 }
278
279 if (!m_outputFile.empty()) {
280 std::ofstream ofs(m_outputFile);
281 if (!ofs) {
282 m_log << MSG::ERROR << "Unable to open output file \"m_outputFile\""
283 << endmsg;
284 } else {
285 // dumpProperties(ofs);
286 dumpState(ofs);
287 }
288 }
289
290 clearState();
291
292 return StatusCode::SUCCESS;
293
294 }
std::string::empty
T empty(T...args)
HistorySvc::listProperties
virtual StatusCode listProperties() const
Definition: HistorySvc.cpp:412
HistorySvc::m_outputFile
std::string m_outputFile
Definition: HistorySvc.h:122
HistorySvc::m_activate
bool m_activate
Definition: HistorySvc.h:106
std::ofstream
STL class.
StatusCode::SUCCESS
Definition: StatusCode.h:30
HistorySvc::m_log
MsgStream m_log
Definition: HistorySvc.h:140
HistorySvc::dumpState
void dumpState(std::ofstream &) const
Definition: HistorySvc.cpp:817
MSG::ERROR
Definition: IMessageSvc.h:21
HistorySvc::m_dump
bool m_dump
Definition: HistorySvc.h:105
StatusCode::ignore
void ignore() const
Definition: StatusCode.h:108
HistorySvc::clearState
void clearState()
Definition: HistorySvc.cpp:115
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244

## Member Data Documentation

bool HistorySvc::m_activate = true
| private

Definition at line 106 of file HistorySvc.h.

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

Definition at line 110 of file HistorySvc.h.

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

Definition at line 113 of file HistorySvc.h.

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

Definition at line 116 of file HistorySvc.h.

bool HistorySvc::m_dump = false
| private

Definition at line 105 of file HistorySvc.h.

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

Definition at line 112 of file HistorySvc.h.

IIncidentSvc* HistorySvc::m_incidentSvc = nullptr
| private

Definition at line 137 of file HistorySvc.h.

bool HistorySvc::m_isInitialized = false
| private

Definition at line 104 of file HistorySvc.h.

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

Definition at line 120 of file HistorySvc.h.

MsgStream HistorySvc::m_log
| mutable private

Definition at line 140 of file HistorySvc.h.

std::string HistorySvc::m_outputFile
| private

Definition at line 122 of file HistorySvc.h.

bool HistorySvc::m_outputFileTypeXML = false
| private

Definition at line 141 of file HistorySvc.h.

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

Definition at line 114 of file HistorySvc.h.

SmartIF<IToolSvc> HistorySvc::m_toolSvc
| private

Definition at line 138 of file HistorySvc.h.

IAlgContextSvc* HistorySvc::p_algCtxSvc = nullptr
| private

Definition at line 108 of file HistorySvc.h.

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

- GaudiMonitor/src/HistorySvc.h
- GaudiMonitor/src/HistorySvc.cpp