All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HistorySvc Class Reference

HistorySvc class definition. More...

#include <src/HistorySvc.h>

Inheritance diagram for HistorySvc:
Collaboration diagram for HistorySvc:

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 JobHistorygetJobHistory () const
 
virtual StatusCode registerSvc (const IService &)
 
virtual StatusCode listProperties (const IService &) const
 
virtual ServiceHistorygetServiceHistory (const IService &) const
 
virtual void getServiceHistory (std::set< ServiceHistory * > &) const
 
virtual StatusCode registerAlg (const Algorithm &)
 
virtual StatusCode listProperties (const Algorithm &) const
 
virtual AlgorithmHistorygetAlgHistory (const Algorithm &) const
 
virtual void getAlgHistory (std::set< AlgorithmHistory * > &) const
 
virtual StatusCode registerAlgTool (const IAlgTool &)
 
virtual StatusCode listProperties (const IAlgTool &) const
 
virtual AlgToolHistorygetAlgToolHistory (const IAlgTool &) const
 
virtual void getAlgToolHistory (std::set< AlgToolHistory * > &) const
 
virtual DataHistorycreateDataHistoryObj (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 DataHistorygetDataHistory (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 ()
 
- Public Member Functions inherited from extends2< Service, IHistorySvc, IIncidentListener >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends2 (A1 a1)
 Templated constructor with 1 argument.
 
 extends2 ()
 Default constructor.
 
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends2 (A1 a1)
 Templated constructor with 1 argument.
 
 extends2 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual std::vector< std::string > getInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends2 ()
 Virtual destructor.
 
virtual ~extends2 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::string & name () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
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.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, 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.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::string & name () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
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.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, 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.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces2< I1, I2 >
virtual ~extend_interfaces2 ()
 Virtual destructor.
 
virtual ~extend_interfaces2 ()
 Virtual destructor.
 

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
 
IAlgorithmgetCurrentIAlg () const
 

Private Attributes

bool m_isInitialized
 
bool m_dump
 
bool m_activate
 
IAlgContextSvcp_algCtxSvc
 
std::set< const Algorithm * > m_algs
 
std::map< const Algorithm
*, AlgorithmHistory * > 
m_algmap
 
std::set< const IAlgTool * > m_ialgtools
 
std::set< const AlgTool * > m_algtools
 
std::map< const AlgTool
*, AlgToolHistory * > 
m_algtoolmap
 
std::set< const IService * > m_svcs
 
std::map< const IService
*, ServiceHistory * > 
m_svcmap
 
std::multimap< DHH, DataHistory * > m_datMap
 
JobHistorym_jobHistory
 
std::string m_outputFile
 
IIncidentSvcm_incidentSvc
 
SmartIF< IToolSvcm_toolSvc
 
MsgStream m_log
 
bool m_outputFileTypeXML
 

Additional Inherited Members

- Public Types inherited from extends2< Service, IHistorySvc, IIncidentListener >
typedef extends2 base_class
 Typedef to this class.
 
typedef extends2 base_class
 Typedef to this class.
 
typedef extend_interfaces2
< IHistorySvc,
IIncidentListener
extend_interfaces_base
 Typedef to the base of this class.
 
typedef extend_interfaces2
< IHistorySvc,
IIncidentListener
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

HistorySvc class definition.

Definition at line 43 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.

Definition at line 96 of file HistorySvc.h.

Constructor & Destructor Documentation

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

Definition at line 73 of file HistorySvc.cpp.

: base_class( name, svc ),
m_dump(false),
{
declareProperty("Activate", m_activate=true);
// hack to bring in environ
vector<string> envtmp = System::getEnv();
envtmp.size(); // prevent icc remark #177: X declared but never referenced
}
HistorySvc::~HistorySvc ( )
virtual

Definition at line 96 of file HistorySvc.cpp.

{
delete m_jobHistory;
}

Member Function Documentation

StatusCode HistorySvc::captureState ( )
virtual

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 201 of file HistorySvc.cpp.

{
if (m_jobHistory == 0) {
if (service("JobOptionsSvc",jo).isFailure()) {
<< "Could not get jobOptionsSvc - "
<< "not adding properties to JobHistory" << endmsg;
} else {
bool foundAppMgr(false);
for (auto& client: jo->getClients()) {
if (client == "ApplicationMgr") foundAppMgr = true;
for (auto prop: *jo->getProperties(client)) {
m_jobHistory->addProperty(client, prop);
}
}
if (!foundAppMgr) {
IProperty *ap;
if (service("ApplicationMgr", ap).isFailure()) {
m_log << MSG::ERROR << "could not get the ApplicationMgr" << endmsg;
} else {
for (auto prop: ap->getProperties()) {
m_jobHistory->addProperty("ApplicationMgr", prop);
}
}
}
}
}
IAlgManager* algMgr = 0;
pp_cast<void>(&algMgr) );
if (sc.isFailure()) {
m_log << MSG::ERROR << "Could not get AlgManager" << endmsg;
} else {
size_t count = 0;
for (auto ialg: algMgr->getAlgorithms()) {
Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
if (alg == 0) {
m_log << MSG::WARNING << "Algorithm " << ialg->name()
<< " does not inherit from Algorithm. Not registering it."
<< endmsg;
} else {
++count;
registerAlg( *alg ).ignore();
}
}
m_log << MSG::INFO << "Registered " << count << " Algorithms" << endmsg;
}
for (auto algtool: m_ialgtools) {
(const_cast<IAlgTool*>(algtool))->addRef();
registerAlgTool(*algtool).ignore();
}
m_log << MSG::INFO << "Registered " << m_algtools.size() << " AlgTools"
<< endmsg;
for (auto svc: Gaudi::svcLocator()->getServices()) {
svc->addRef();
}
m_log << "Registered " << Gaudi::svcLocator()->getServices().size() << " Services" << endmsg;
}
void HistorySvc::clearState ( )
private

Definition at line 127 of file HistorySvc.cpp.

{
m_algs.clear();
clear(m_algmap);
m_ialgtools.clear();
m_algtools.clear();
clear(m_algtoolmap);
m_svcs.clear();
clear(m_svcmap);
}
DataHistory * HistorySvc::createDataHistoryObj ( const CLID id,
const std::string &  key,
const std::string &  store 
)
virtual

Definition at line 565 of file HistorySvc.cpp.

{
if (!m_activate) return 0;
AlgorithmHistory *algHist;
if (ialg == 0) {
<< "Could not discover current Algorithm:" << endl
<< " object CLID: " << id << " key: \"" << key
<< "\"" << endmsg;
algHist = 0;
} else {
Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
if (alg != 0) {
algHist = getAlgHistory( *alg );
} else {
<< "Could not extract concrete Algorithm:"
<< endl
<< " object CLID: " << id << " key: \"" << key
<< "\"" << endmsg;
algHist = 0;
}
}
DataHistory *hist = new DataHistory(id, key, algHist);
return hist;
}
std::string HistorySvc::dumpProp ( const Property prop,
const bool  isXML = false,
int  indent = 0 
) const
private

Definition at line 913 of file HistorySvc.cpp.

{
std::ostringstream ost;
if (isXML) {
while (ind > 0) {
ost << " ";
ind --;
}
ost << "<PROPERTY name=\"" << prop->name()
<< "\" value=\"" << HistoryObj::convert_string(prop->toString())
<< "\" documentation=\"" << HistoryObj::convert_string(prop->documentation())
<< "\">";
} else {
prop->fillStream(ost);
}
return ost.str();
}
void HistorySvc::dumpProperties ( std::ofstream &  ofs) const
private

Definition at line 498 of file HistorySvc.cpp.

{
ofs << "GLOBAL" << std::endl;
JobHistory::PropertyPairList::const_iterator itrj;
for (itrj=props.begin(); itrj != props.end(); ++itrj) {
std::string client = itrj->first;
const Property* prp = itrj->second;
ofs << client << " " << dumpProp(prp) << std::endl;
}
ofs << std::endl << "SERVICES" << std::endl;
std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
for (itr_s=m_svcmap.begin(); itr_s != m_svcmap.end(); ++itr_s) {
const IService* svc = itr_s->first;
dumpProperties( *svc, ofs );
}
ofs << std::endl << "ALGORITHMS" << std::endl;
std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
for (itr=m_algmap.begin(); itr != m_algmap.end(); ++itr) {
const Algorithm* alg = itr->first;
dumpProperties( *alg, ofs );
}
ofs << std::endl << "ALGTOOLS" << std::endl;
std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
for (itr_a=m_algtoolmap.begin(); itr_a != m_algtoolmap.end(); ++itr_a) {
const AlgTool* alg = itr_a->first;
dumpProperties( *alg, ofs );
}
}
void HistorySvc::dumpProperties ( const IService svc,
std::ofstream &  ofs 
) const
private

Definition at line 766 of file HistorySvc.cpp.

{
if (hist == 0) {
return;
}
for (auto &prop: hist->properties()) {
ofs << svc.name() << " " << dumpProp(prop) << std::endl;
}
}
void HistorySvc::dumpProperties ( const Algorithm alg,
std::ofstream &  ofs 
) const
private

Definition at line 396 of file HistorySvc.cpp.

{
if (hist == 0) {
return;
}
PropertyList::const_iterator itr;
for (auto prop: hist->properties()) {
ofs << alg.name() << " " << dumpProp(prop) << std::endl;
}
}
void HistorySvc::dumpProperties ( const IAlgTool alg,
std::ofstream &  ofs 
) const
private

Definition at line 854 of file HistorySvc.cpp.

{
if (hist == 0) {
return;
}
for (auto& prop: hist->properties()) {
ofs << alg.name() << " " << dumpProp(prop) << std::endl;
}
}
void HistorySvc::dumpState ( std::ofstream &  ofs) const
private

Definition at line 933 of file HistorySvc.cpp.

{
//xml header
ofs << "<?xml version=\"1.0\" ?> " << std::endl;
ofs << "<!--Test-xml-->" << std::endl;
ofs << "<SETUP>" << std::endl;
ofs << " <GLOBAL>" << std::endl;
} else {
ofs << "GLOBAL" << std::endl;
}
std::string client_currently_open = "start";
for (auto& item: m_jobHistory->propertyPairs()) {
// client is the name of the component of the current property
const std::string& client = item.first;
const Property* prp = item.second;
if (client != client_currently_open) {
if(client_currently_open!="start") ofs << " </COMPONENT>" << endl;
ofs << " <COMPONENT name=\""
<< client << "\" class=\"undefined\">" << std::endl;
}
} else {
ofs << client << " ";
}
ofs << dumpProp(prp,m_outputFileTypeXML,6) << endl;
client_currently_open = client;
ofs << " </COMPONENT>" << endl;
}
ofs << "</GLOBAL>" << endl << "<SERVICES>" << endl;
} else {
ofs << "SERVICES" << std::endl;
}
for (auto& item: m_svcmap) {
const IService* svc = item.first;
dumpState(svc, ofs);
}
ofs << "</SERVICES>" << endl << "<ALGORITHMS> " << endl;
} else {
ofs << "ALGORITHMS" << std::endl;
}
for (auto& item: m_algmap) {
const Algorithm* alg = item.first;
dumpState(alg, ofs);
}
ofs << "</ALGORITHMS>" << endl << "<ALGTOOLS> " << endl;
} else {
ofs << "ALGTOOLS" << std::endl;
}
for (auto& item: m_algtoolmap) {
const AlgTool* algtool = item.first;
dumpState(algtool, ofs);
}
ofs << "</ALGTOOLS>" << endl << "</SETUP>" << endl;
}
}
void HistorySvc::dumpState ( const INamedInterface in,
std::ofstream &  ofs 
) const
private

Definition at line 1015 of file HistorySvc.cpp.

{
HistoryObj *hist(0);
IVersHistoryObj *vhist(0);
const IService* is(0);
const Algorithm* ia(0);
const IAlgTool* it(0);
if ( (is=dynamic_cast<const IService*>(in)) != 0) {
m_log << MSG::VERBOSE << in->name() << " is Service" << endmsg;
hist = dynamic_cast<HistoryObj*>( o );
vhist = dynamic_cast<IVersHistoryObj*>( o );
} else if ( (ia = dynamic_cast<const Algorithm*>(in)) != 0 ) {
m_log << MSG::VERBOSE << in->name() << " is Alg" << endmsg;
hist = dynamic_cast<HistoryObj*>( o );
vhist = dynamic_cast<IVersHistoryObj*>( o );
} else if ( (it = dynamic_cast<const IAlgTool*>(in)) != 0 ) {
m_log << MSG::VERBOSE << in->name() << " is AlgTool" << endmsg;
hist = dynamic_cast<HistoryObj*>( o );
vhist = dynamic_cast<IVersHistoryObj*>( o );
} else {
<< "Could not dcast interface to accepted History Obj type for "
<< in->name() << endmsg;
return;
}
if (hist == 0 || vhist == 0) {
m_log << MSG::ERROR << "Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen."
<< endmsg;
return;
}
hist->dump(ofs,true);
} else {
ofs << ">> " << vhist->name() << endl << *hist << endl;
}
}
StatusCode HistorySvc::finalize ( )
virtual

Reimplemented from Service.

Definition at line 321 of file HistorySvc.cpp.

{
m_log << MSG::VERBOSE << "HistorySvc::finalize()" << endmsg;
if ( status.isSuccess() )
m_log << MSG::INFO << "Service finalised successfully" << endmsg;
return status;
}
AlgorithmHistory * HistorySvc::getAlgHistory ( const Algorithm alg) const
virtual

Definition at line 413 of file HistorySvc.cpp.

{
const Algorithm *palg = &alg;
set<const Algorithm*>::const_iterator itr = m_algs.find(palg);
if ( itr == m_algs.end() ) {
m_log << MSG::WARNING << "Algorithm " << alg.name() << " not registered"
<< endmsg;
return 0;
}
map<const Algorithm*, AlgorithmHistory*>::const_iterator itr2;
itr2 = m_algmap.find( *itr );
return ( itr2->second );
}
void HistorySvc::getAlgHistory ( std::set< AlgorithmHistory * > &  algs) const
virtual

Definition at line 432 of file HistorySvc.cpp.

{
map_to_set(m_algmap, algs);
}
AlgToolHistory * HistorySvc::getAlgToolHistory ( const IAlgTool alg) const
virtual

Definition at line 871 of file HistorySvc.cpp.

{
const AlgTool *palg = dynamic_cast<const AlgTool*>(&alg);
set<const AlgTool*>::const_iterator itr = m_algtools.find(palg);
if ( itr == m_algtools.end() ) {
m_log << MSG::WARNING << "AlgTool " << alg.name() << " not registered"
<< endmsg;
return 0;
}
map<const AlgTool*, AlgToolHistory*>::const_iterator itr2;
itr2 = m_algtoolmap.find( *itr );
return ( itr2->second );
}
void HistorySvc::getAlgToolHistory ( std::set< AlgToolHistory * > &  algs) const
virtual

Definition at line 891 of file HistorySvc.cpp.

{
map_to_set(m_algtoolmap, algs);
}
IAlgorithm * HistorySvc::getCurrentIAlg ( ) const
private

Definition at line 550 of file HistorySvc.cpp.

{
if (p_algCtxSvc == 0) {
m_log << MSG::WARNING << "trying to create DataHistoryObj before "
<< "HistorySvc has been initialized" << endmsg;
return 0;
} else {
}
}
DataHistory * HistorySvc::getDataHistory ( const CLID id,
const std::string &  key,
const std::string &  store 
) const
virtual

Definition at line 640 of file HistorySvc.cpp.

{
DHH dhh(id,key);
pair<DHMCitr,DHMCitr> mitr = m_datMap.equal_range(dhh);
if(mitr.first == mitr.second) {
return 0;
}
return mitr.first->second;
}
int HistorySvc::getDataHistory ( const CLID id,
const std::string &  key,
const std::string &  storeName,
std::list< DataHistory * > &  dhlist 
) const
virtual

Definition at line 658 of file HistorySvc.cpp.

{
DHH dhh(id,key);
int n(0);
pair<DHMCitr,DHMCitr> mitr = m_datMap.equal_range(dhh);
for (DHMCitr itr=mitr.first; itr != mitr.second; ++itr) {
dhlist.push_back(itr->second);
n++;
}
return n;
}
JobHistory * HistorySvc::getJobHistory ( ) const
virtual

Definition at line 542 of file HistorySvc.cpp.

{
return m_jobHistory;
}
ServiceHistory * HistorySvc::getServiceHistory ( const IService svc) const
virtual

Definition at line 716 of file HistorySvc.cpp.

{
const IService *psvc = &svc;
map<const IService*, ServiceHistory*>::const_iterator itr =
m_svcmap.find(psvc);
if ( itr == m_svcmap.end() ) {
m_log << MSG::WARNING << "Service " << svc.name() << " not registered"
<< endmsg;
return 0;
}
return ( itr->second );
}
void HistorySvc::getServiceHistory ( std::set< ServiceHistory * > &  svcs) const
virtual

Definition at line 733 of file HistorySvc.cpp.

{
map_to_set(m_svcmap, svcs);
}
void HistorySvc::handle ( const Incident inc)
virtual

Definition at line 898 of file HistorySvc.cpp.

{
if (incident.type() == IncidentType::BeginEvent) {
m_log << MSG::WARNING << "Error capturing state." << endl
<< "Will try again at next BeginEvent incident" << endmsg;
}
}
}
StatusCode HistorySvc::initialize ( )
virtual

Reimplemented from Service.

Definition at line 142 of file HistorySvc.cpp.

{
if (status.isFailure()) {
m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
<< endmsg;
return status;
}
m_log << MSG::DEBUG << "Initializing HistorySvc" << endmsg;
static const bool CREATEIF(true);
if ( service("AlgContextSvc",p_algCtxSvc,CREATEIF).isFailure() ) {
m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
}
if (service("IncidentSvc", m_incidentSvc, CREATEIF).isFailure()) {
m_log << MSG::ERROR << "unable to get the IncidentSvc" << endmsg;
}
// create a weak dependency on the ToolSvc, so that it doesn't get deleted
// before we're done with it in finalize
m_toolSvc = serviceLocator()->service("ToolSvc");
if (! m_toolSvc) {
m_log << MSG::ERROR << "could not retrieve the ToolSvc handle !"
<< endmsg;
}
// add listener to be triggered by first BeginEvent with low priority
// so it gets called first
const bool rethrow = false;
const bool oneShot = true; // make the listener called only once
std::numeric_limits<long>::min(),rethrow,oneShot);
if (m_outputFile.find(".XML") != string::npos || m_outputFile.find(".xml") != string::npos) {
m_log << MSG::DEBUG << "output format is XML" << endmsg;
}
}
StatusCode HistorySvc::listProperties ( ) const
virtual

Definition at line 450 of file HistorySvc.cpp.

{
m_log << "Dumping properties for all Algorithms (" << m_algmap.size()
<< ")" << endmsg;
for (auto& alg: m_algmap) {
listProperties(*alg.first).ignore();
}
m_log << "Dumping properties for all AlgTools (" << m_algtoolmap.size()
<< ")" << endmsg;
for (auto& algtool: m_algtoolmap) {
m_log << MSG::DEBUG << " --> " << algtool.second->algtool_name() << endmsg;
listProperties(*algtool.first).ignore();
}
m_log << "Dumping properties for all Services (" << m_svcmap.size()
<< ")" << endmsg;
for (auto& svc: m_svcmap) {
listProperties(*svc.first).ignore();
}
m_log << "Dumping properties for Job";
ostringstream ost;
ost << *m_jobHistory;
std::string str = ost.str();
m_log << std::endl << str << endmsg;
}
StatusCode HistorySvc::listProperties ( const IService svc) const
virtual

Definition at line 740 of file HistorySvc.cpp.

{
m_log << MSG::INFO << "Dumping properties for " << svc.name() << endl;
if (hist == 0) {
}
ostringstream ost;
ost << *hist;
std::string str = ost.str();
m_log << MSG::INFO << svc.name() << " --> " << endl << str << endmsg;
}
StatusCode HistorySvc::listProperties ( const Algorithm alg) const
virtual

Definition at line 373 of file HistorySvc.cpp.

{
m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
if (hist == 0) {
}
ostringstream ost;
ost << *hist;
std::string str = ost.str();
m_log << MSG::INFO << alg.name() << " --> " << endl << str << endmsg;
}
StatusCode HistorySvc::listProperties ( const IAlgTool alg) const
virtual

Definition at line 831 of file HistorySvc.cpp.

{
m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
if (hist == 0) {
}
ostringstream ost;
ost << *hist;
std::string str = ost.str();
m_log << MSG::INFO << alg.name() << " --> " << endl << str << endmsg;
}
StatusCode HistorySvc::registerAlg ( const Algorithm alg)
virtual

Definition at line 344 of file HistorySvc.cpp.

{
if (m_algmap.find(&alg) != m_algmap.end()) {
m_log << MSG::WARNING << "Algorithm " << alg.name()
<< " already registered with HistorySvc" << endmsg;
}
(const_cast<Algorithm*>(&alg))->addRef();
m_algs.insert(&alg);
AlgorithmHistory *algHist = new AlgorithmHistory(alg, job);
m_algmap[&alg] = algHist;
m_log << MSG::DEBUG << "Registering algorithm: ";
m_log << alg.name() << endmsg;
}
}
StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg)
virtual

Definition at line 783 of file HistorySvc.cpp.

{
if (! m_isInitialized) {
if (p_algCtxSvc == 0) {
if ( service("AlgContextSvc",p_algCtxSvc,true).isFailure() ) {
m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
}
}
m_ialgtools.insert(&ialg);
}
const AlgTool *alg = dynamic_cast<const AlgTool*>( &ialg );
if ( alg == 0 ) {
m_log << MSG::ERROR << "Could not dcast IAlgTool \"" << ialg.name()
<< "\" to an AlgTool" << endmsg;
}
if (m_algtools.find(alg) != m_algtools.end()) {
m_log << MSG::WARNING << "AlgTool " << ialg.name()
<< " already registered in HistorySvc" << endmsg;
}
m_algtools.insert(alg);
(const_cast<AlgTool*>(alg))->addRef();
const JobHistory *job = getJobHistory();
AlgToolHistory *algHist = new AlgToolHistory(*alg, job);
m_algtoolmap[alg] = algHist;
if (m_log.level() <= MSG::DEBUG) {
m_log << MSG::DEBUG << "Registering algtool: ";
m_log << alg->name() << endmsg;
}
}
StatusCode HistorySvc::registerDataHistory ( const CLID id,
const std::string &  key,
const std::string &  store 
)
virtual

Definition at line 603 of file HistorySvc.cpp.

{
DHH dhh(id,key);
auto boundaries = m_datMap.equal_range(dhh);
auto match = boundaries.second;
if (boundaries.first != boundaries.second) {
// there is something in the map, let's look for the specific entry
std::string algName;
if (ialg) {
algName = ialg->name();
} else {
algName = "UNKNOWN";
}
match = std::find_if(boundaries.first, boundaries.second,
[&algName](decltype(boundaries)::first_type::reference p) -> bool {
return p.second->algorithmHistory()->algorithm_name() == algName;
});
}
if (match == boundaries.second) { // not found, crete the entry
DataHistory *dh = createDataHistoryObj(id, key, storeName);
m_datMap.insert(pair<DHH, DataHistory*>(dhh,dh));
}
}
StatusCode HistorySvc::registerJob ( )
virtual

Definition at line 439 of file HistorySvc.cpp.

{
}
StatusCode HistorySvc::registerSvc ( const IService svc)
virtual

Definition at line 680 of file HistorySvc.cpp.

{
if ( svc.name() == "HistoryStore" ) {
// m_log << MSG::WARNING << "not registering store" << endmsg;
}
const IService* psvc = &svc;
map<const IService*, ServiceHistory*>::const_iterator itr =
m_svcmap.find(psvc);
if (itr == m_svcmap.end()) {
if (m_log.level() <= MSG::DEBUG) {
m_log << MSG::DEBUG << "Registering Service: ";
m_log << svc.name() << endmsg;
}
m_svcs.insert(psvc);
ServiceHistory *svcHist = new ServiceHistory(&svc, job);
m_svcmap[psvc] = svcHist;
(const_cast<IService*>(psvc))->addRef();
}
}
StatusCode HistorySvc::reinitialize ( )
virtual

Reimplemented from Service.

Definition at line 102 of file HistorySvc.cpp.

StatusCode HistorySvc::stop ( )
virtual

Reimplemented from Service.

Definition at line 290 of file HistorySvc.cpp.

{
if (m_dump) {
}
if (m_outputFile != "") {
std::ofstream ofs;
ofs.open(m_outputFile.c_str());
if (!ofs) {
m_log << MSG::ERROR << "Unable to open output file \"m_outputFile\""
<< endmsg;
} else {
// dumpProperties(ofs);
dumpState(ofs);
ofs.close();
}
}
}

Member Data Documentation

bool HistorySvc::m_activate
private

Definition at line 106 of file HistorySvc.h.

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

Definition at line 111 of file HistorySvc.h.

std::set<const Algorithm*> HistorySvc::m_algs
private

Definition at line 110 of file HistorySvc.h.

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

Definition at line 115 of file HistorySvc.h.

std::set<const AlgTool*> HistorySvc::m_algtools
private

Definition at line 114 of file HistorySvc.h.

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

Definition at line 120 of file HistorySvc.h.

bool HistorySvc::m_dump
private

Definition at line 105 of file HistorySvc.h.

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

Definition at line 113 of file HistorySvc.h.

IIncidentSvc* HistorySvc::m_incidentSvc
private

Definition at line 141 of file HistorySvc.h.

bool HistorySvc::m_isInitialized
private

Definition at line 104 of file HistorySvc.h.

JobHistory* HistorySvc::m_jobHistory
private

Definition at line 124 of file HistorySvc.h.

MsgStream HistorySvc::m_log
mutableprivate

Definition at line 144 of file HistorySvc.h.

std::string HistorySvc::m_outputFile
private

Definition at line 126 of file HistorySvc.h.

bool HistorySvc::m_outputFileTypeXML
private

Definition at line 145 of file HistorySvc.h.

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

Definition at line 118 of file HistorySvc.h.

std::set<const IService*> HistorySvc::m_svcs
private

Definition at line 117 of file HistorySvc.h.

SmartIF<IToolSvc> HistorySvc::m_toolSvc
private

Definition at line 142 of file HistorySvc.h.

IAlgContextSvc* HistorySvc::p_algCtxSvc
private

Definition at line 108 of file HistorySvc.h.


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