| # Gaudi Framework, version v20r3
Generated: 24 Nov 2008

# HistorySvc Class Reference

`#include <HistorySvc.h>`

Inheritance diagram for HistorySvc:

[legend]
Collaboration diagram for HistorySvc:

[legend]

List of all members.

## Detailed Description

Definition at line 45 of file HistorySvc.h.

## Public Member Functions
virtual StatusCode | initialize ()
| Initialization (from CONFIGURED to INITIALIZED).
virtual StatusCode | reinitialize ()
| Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).
virtual StatusCode | finalize ()
| Finalize (from INITIALIZED to CONFIGURED).
virtual StatusCode | captureState ()
virtual StatusCode | queryInterface (const InterfaceID &riid, void **ppvInterface)
| Query interfaces of Interface.
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)
| Inform that a new incident has occured.
virtual | ~HistorySvc ()
## Private Types
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 IService &, std::ofstream &) const
void | dumpState (const Algorithm &, std::ofstream &) const
void | dumpState (const IAlgTool &, std::ofstream &) const
std::string | dumpProp (const Property *) const
IAlgorithm * | getCurrentIAlg () const
## Private Attributes
bool | m_isInitialized
bool | m_dump
bool | m_activate
IAlgContextSvc * | p_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
JobHistory * | m_jobHistory
std::string | m_outputFile
IIncidentSvc * | m_incidentSvc
MsgStream | m_log
## Friends
class | SvcFactory< HistorySvc >

## Member Typedef Documentation

typedef std::multimap<DHH,DataHistory*> HistorySvc::DataHistMap`[private]`

Definition at line 105 of file HistorySvc.h.

typedef DataHistMap::iterator HistorySvc::DHMitr`[private]`

Definition at line 106 of file HistorySvc.h.

typedef DataHistMap::const_iterator HistorySvc::DHMCitr`[private]`

Definition at line 107 of file HistorySvc.h.

## Constructor & Destructor Documentation

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

Definition at line 69 of file HistorySvc.cpp.

    00070   : Service( name, svc ),
    00071     m_isInitialized(false),
    00072     m_dump(false),
    00073     p_algCtxSvc(0),
    00074     m_jobHistory(0),
    00075     m_outputFile(""),
    00076     m_incidentSvc(0),
    00077     m_log(msgSvc(), name )
    00078
    00079 {
    00080     declareProperty("Dump",m_dump);
    00081     declareProperty("Activate", m_activate=true);
    00082     declareProperty("OutputFile",m_outputFile);
    00083
    00084     // hack to bring in environ
    00085     vector<string> envtmp = System::getEnv();
    00086
    00087 }

HistorySvc::~HistorySvc | ( |  | ) | `[virtual]`

Definition at line 91 of file HistorySvc.cpp.

    00091                         {
    00092   delete m_jobHistory;
    00093 }

## Member Function Documentation

StatusCode HistorySvc::initialize | ( |  | ) | `[virtual]`

Initialization (from CONFIGURED to INITIALIZED).

Reimplemented from Service.

Definition at line 140 of file HistorySvc.cpp.

    00140                                   {
    00141
    00142   StatusCode status = Service::initialize();
    00143   m_log.setLevel( m_outputLevel.value() );
    00144
    00145   if (status.isFailure()) {
    00146 #ifndef NDEBUG
    00147     m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
    00148           << endreq;
    00149 #endif
    00150     return status;
    00151   }
    00152
    00153 #ifndef NDEBUG
    00154   m_log << MSG::DEBUG << "Initializing HistorySvc" << endreq;
    00155 #endif
    00156
    00157   if (!m_activate) return StatusCode::SUCCESS;
    00158
    00159   static const bool CREATEIF(true);
    00160
    00161   if ( service("AlgContextSvc",p_algCtxSvc,CREATEIF).isFailure() ) {
    00162     m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endreq;
    00163     return StatusCode::FAILURE;
    00164   }
    00165
    00166   if (service("IncidentSvc", m_incidentSvc, CREATEIF).isFailure()) {
    00167     m_log << MSG::ERROR << "unable to get the IncidentSvc" << endreq;
    00168     return StatusCode::FAILURE;
    00169   }
    00170
    00171   // create a weak dependency on the ToolSvc, so that it doesn't get deleted
    00172   // before we're done with it in finalize
    00173   if (ServiceHandle<IToolSvc>("ToolSvc/ToolSvc",name()).retrieve().isFailure()) {
    00174     m_log << MSG::ERROR << "could not retrieve the ToolSvc handle !"
    00175           << endreq;
    00176     return StatusCode::FAILURE;
    00177   }
    00178
    00179   // add listener to be triggered by first BeginEvent with low priority
    00180   // so it gets called first
    00181   const bool rethrow = false;
    00182   const bool oneShot = true; // make the listener called only once
    00183   m_incidentSvc->addListener(this,IncidentType::BeginEvent,
    00184                              std::numeric_limits<long>::min(),rethrow,oneShot);
    00185
    00186   m_isInitialized = true;
    00187
    00188   return StatusCode::SUCCESS;
    00189
    00190 }

StatusCode HistorySvc::reinitialize | ( |  | ) | `[virtual]`

Initialization (from INITIALIZED or RUNNING to INITIALIZED, via CONFIGURED).

Reimplemented from Service.

Definition at line 97 of file HistorySvc.cpp.

    00097                                     {
    00098
    00099   clearState();
    00100
    00101   m_state = Gaudi::StateMachine::OFFLINE;
    00102
    00103   return initialize();
    00104
    00105 }

StatusCode HistorySvc::finalize | ( |  | ) | `[virtual]`

Finalize (from INITIALIZED to CONFIGURED).

Reimplemented from Service.

Definition at line 297 of file HistorySvc.cpp.

    00297                                 {
    00298
    00299   if (!m_activate) return StatusCode::SUCCESS;
    00300
    00301   if (m_dump) {
    00302     listProperties().ignore();
    00303   }
    00304
    00305   if (m_outputFile != "") {
    00306     std::ofstream ofs;
    00307     ofs.open(m_outputFile.c_str());
    00308     if (!ofs) {
    00309       m_log << MSG::ERROR << "Unable to open output file \"m_outputFile\""
    00310             << endreq;
    00311     } else {
    00312
    00313       //      dumpProperties(ofs);
    00314       dumpState(ofs);
    00315
    00316       ofs.close();
    00317     }
    00318   }
    00319
    00320   clearState();
    00321
    00322   StatusCode status = Service::finalize();
    00323
    00324   if ( status.isSuccess() )
    00325     m_log << MSG::INFO << "Service finalised successfully" << endreq;
    00326
    00327   return status;
    00328
    00329 }

StatusCode HistorySvc::captureState | ( |  | ) | `[virtual]`

Get all the Algorithms

Get all the AlgTools

Get all the Services

Definition at line 193 of file HistorySvc.cpp.

    00193                                     {
    00194
    00195   if (m_jobHistory == 0) {
    00196     m_jobHistory = new JobHistory;
    00197     IJobOptionsSvc *jo;
    00198     if (service("JobOptionsSvc",jo).isFailure()) {
    00199        m_log << MSG::ERROR
    00200              << "Could not get jobOptionsSvc - "
    00201              << "not adding properties to JobHistory" << endreq;
    00202     } else {
    00203
    00204       bool foundAppMgr(false);
    00205
    00206       std::vector<std::string> clients = jo->getClients();
    00207       std::vector<std::string>::const_iterator it;
    00208       std::vector<const Property*>::const_iterator itr;
    00209       for (it=clients.begin(); it!=clients.end(); ++it) {
    00210         if (*it == "ApplicationMgr") {
    00211           foundAppMgr = true;
    00212         }
    00213         const std::vector<const Property*> *props = jo->getProperties(*it);
    00214         for (itr=props->begin(); itr != props->end(); ++itr) {
    00215           m_jobHistory->addProperty( *it, *itr );
    00216         }
    00217       }
    00218
    00219       if (!foundAppMgr) {
    00220         IProperty *ap;
    00221         if (service("ApplicationMgr",ap).isFailure()) {
    00222           m_log << MSG::ERROR << "could not get the ApplicationMgr" << endreq;
    00223         } else {
    00224           std::vector<Property*>::const_iterator itr2;
    00225           const std::vector<Property*> props = ap->getProperties();
    00226           for (itr2=props.begin(); itr2 != props.end(); ++itr2) {
    00227             m_jobHistory->addProperty( "ApplicationMgr", *itr2 );
    00228           }
    00229         }
    00230       }
    00231
    00232     }
    00233   }
    00234
    00236
    00237   StatusCode sc;
    00238   IAlgManager* algMgr = 0;
    00239   sc = Gaudi::svcLocator()->queryInterface( IID_IAlgManager,
    00240                                             pp_cast<void>(&algMgr) );
    00241   if (sc.isFailure()) {
    00242     m_log << MSG::ERROR << "Could not get AlgManager" << endreq;
    00243     return StatusCode::FAILURE;
    00244   } else {
    00245
    00246     std::list<IAlgorithm*> algs;
    00247     algs = algMgr->getAlgorithms();
    00248     std::list<IAlgorithm*>::const_iterator itr;
    00249     for (itr=algs.begin(); itr!=algs.end(); ++itr) {
    00250       Algorithm* alg = dynamic_cast<Algorithm*> (*itr);
    00251       if (alg == 0) {
    00252         m_log << MSG::WARNING << "Algorithm " << (*itr)->name()
    00253               << " does not inherit from Algorithm. Not registering it."
    00254               << endreq;
    00255       } else {
    00256         registerAlg( *alg ).ignore();
    00257       }
    00258     }
    00259
    00260     m_log << MSG::INFO;
    00261     m_log << "Registered " << algs.size() << " Algorithms" << endreq;
    00262
    00263   }
    00264
    00266
    00267   m_isInitialized = true;
    00268   std::set<const IAlgTool*>::const_iterator itra;
    00269   for (itra = m_ialgtools.begin(); itra != m_ialgtools.end(); ++itra) {
    00270     (const_cast<IAlgTool*>(*itra))->addRef();
    00271     registerAlgTool(**itra).ignore();
    00272   }
    00273
    00274   m_log << MSG::INFO << "Registered " << m_algtools.size() << " AlgTools"
    00275         << endreq;
    00276
    00278
    00279   std::list<IService*> svcs = Gaudi::svcLocator()->getServices();
    00280
    00281   std::list<IService*>::const_iterator itrs;
    00282   for (itrs=svcs.begin(); itrs!=svcs.end(); ++itrs) {
    00283     (*itrs)->addRef();
    00284     registerSvc(**itrs).ignore();
    00285   }
    00286
    00287   m_log << MSG::INFO;
    00288   m_log << "Registered " << svcs.size() << " Services" << endreq;
    00289
    00290   return StatusCode::SUCCESS;
    00291
    00292
    00293 }

StatusCode HistorySvc::queryInterface | ( | const InterfaceID & | riid,
|  | void ** | ppvUnknown |
| ) |  |  | `[virtual]`

Query interfaces of Interface.

Parameters:

  | riid | ID of Interface to be retrieved
  | ppvUnknown | Pointer to Location for interface pointer

Reimplemented from Service.

Definition at line 333 of file HistorySvc.cpp.

    00335 {
    00336   StatusCode sc = StatusCode::FAILURE;
    00337   if ( ppvInterface ) {
    00338     *ppvInterface = 0;
    00339
    00340     if ( IHistorySvc::interfaceID().versionMatch(riid) )    {
    00341       *ppvInterface = static_cast<IHistorySvc*>(this);
    00342       sc = StatusCode::SUCCESS;
    00343       addRef();
    00344     }
    00345     else
    00346       sc = Service::queryInterface( riid, ppvInterface );
    00347   }
    00348   return sc;
    00349 }

StatusCode HistorySvc::registerJob | ( |  | ) | `[virtual]`

Implements IHistorySvc.

Definition at line 459 of file HistorySvc.cpp.

    00459                         {
    00460
    00461
    00462   return StatusCode(StatusCode::SUCCESS,true);
    00463
    00464
    00465 }

StatusCode HistorySvc::listProperties | ( |  | ) | const`[virtual]`

Implements IHistorySvc.

Definition at line 470 of file HistorySvc.cpp.

    00470                                  {
    00471
    00472   m_log << MSG::INFO;
    00473   m_log.setColor(MSG::CYAN);
    00474   m_log << "Dumping properties for all Algorithms" << endreq;
    00475
    00476   std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
    00477   for (itr=m_algmap.begin(); itr != m_algmap.end(); ++itr) {
    00478     const Algorithm* alg = itr->first;
    00479
    00480     listProperties( *alg ).ignore();
    00481
    00482   }
    00483
    00484   m_log << MSG::INFO;
    00485   m_log.setColor(MSG::CYAN);
    00486   m_log << "Dumping properties for all AlgTools" << endreq;
    00487
    00488   std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
    00489   for (itr_a=m_algtoolmap.begin(); itr_a != m_algtoolmap.end(); ++itr_a) {
    00490     const AlgTool* alg = itr_a->first;
    00491
    00492     listProperties( *alg ).ignore();
    00493
    00494   }
    00495
    00496   m_log << MSG::INFO;
    00497   m_log.setColor(MSG::CYAN);
    00498   m_log << "Dumping properties for all Services" << endreq;
    00499
    00500   std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
    00501   for (itr_s=m_svcmap.begin(); itr_s != m_svcmap.end(); ++itr_s) {
    00502     const IService* svc = itr_s->first;
    00503
    00504     listProperties( *svc ).ignore();
    00505
    00506   }
    00507
    00508   m_log << MSG::INFO;
    00509   m_log.setColor(MSG::CYAN);
    00510   m_log << "Dumping properties for Job";
    00511   m_log.resetColor();
    00512
    00513   ostringstream ost;
    00514   ost << *m_jobHistory;
    00515   std::string str = ost.str();
    00516
    00517   m_log << std::endl << str << endreq;
    00518
    00519   return StatusCode(StatusCode::SUCCESS,true);
    00520
    00521 }

JobHistory * HistorySvc::getJobHistory | ( |  | ) | const`[virtual]`

Implements IHistorySvc.

Definition at line 569 of file HistorySvc.cpp.

    00569                                 {
    00570
    00571   return m_jobHistory;
    00572
    00573 }

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

Implements IHistorySvc.

Definition at line 715 of file HistorySvc.cpp.

    00715                                            {
    00716
    00717   if ( svc.name() == "HistoryStore" ) {
    00718     //    m_log << MSG::WARNING << "not registering store" << endreq;
    00719     return StatusCode(StatusCode::SUCCESS,true);
    00720   }
    00721
    00722   JobHistory *job = getJobHistory();
    00723   const IService* psvc = &svc;
    00724   map<const IService*, ServiceHistory*>::const_iterator itr =
    00725     m_svcmap.find(psvc);
    00726   if (itr == m_svcmap.end()) {
    00727
    00728 #ifndef NDEBUG
    00729     m_log << MSG::DEBUG << "Registering Service: ";
    00730     m_log.setColor(MSG::CYAN);
    00731     m_log << svc.name() << endreq;
    00732 #endif
    00733
    00734     m_svcs.insert(psvc);
    00735
    00736     ServiceHistory *svcHist = new ServiceHistory(&svc, job);
    00737     m_svcmap[psvc] = svcHist;
    00738
    00739     (const_cast<IService*>(psvc))->addRef();
    00740
    00741   }
    00742
    00743   m_log.resetColor();
    00744   return StatusCode(StatusCode::SUCCESS,true);
    00745
    00746 }

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

Implements IHistorySvc.

Definition at line 782 of file HistorySvc.cpp.

    00782                                                     {
    00783
    00784   m_log << MSG::INFO << "Dumping properties for " << svc.name() << endl;
    00785
    00786   ServiceHistory *hist = getServiceHistory( svc );
    00787
    00788   if (hist == 0) {
    00789     return StatusCode::FAILURE;
    00790   }
    00791
    00792   ostringstream ost;
    00793   ost << *hist;
    00794
    00795   std::string str = ost.str();
    00796
    00797   m_log << MSG::INFO << svc.name() << " --> " << endl << str << endreq;
    00798
    00799
    00800
    00801   return StatusCode(StatusCode::SUCCESS,true);
    00802
    00803 }

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

Implements IHistorySvc.

Definition at line 751 of file HistorySvc.cpp.

    00751                                                        {
    00752
    00753   const IService *psvc = &svc;
    00754   map<const IService*, ServiceHistory*>::const_iterator itr =
    00755     m_svcmap.find(psvc);
    00756   if ( itr == m_svcmap.end() ) {
    00757     m_log << MSG::WARNING << "Service " << svc.name() << " not registered"
    00758           << endreq;
    00759     return 0;
    00760   }
    00761
    00762   return ( itr->second );
    00763
    00764 }

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

Implements IHistorySvc.

Definition at line 768 of file HistorySvc.cpp.

    00768                                                                  {
    00769
    00770   set<const IService*>::const_iterator itr;
    00771   for (itr=m_svcs.begin(); itr!=m_svcs.end(); ++itr) {
    00772     ServiceHistory *sh = m_svcmap.find( *itr )->second;
    00773
    00774     svcs.insert(sh);
    00775   }
    00776
    00777 }

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

Implements IHistorySvc.

Definition at line 357 of file HistorySvc.cpp.

    00357                                             {
    00358
    00359   JobHistory *job = getJobHistory();
    00360   if (m_algmap.find(&alg) != m_algmap.end()) {
    00361     m_log << MSG::WARNING << "Algorithm " << alg.name()
    00362           << " already registered with HistorySvc" << endreq;
    00363     return StatusCode::SUCCESS;
    00364   }
    00365
    00366   (const_cast<Algorithm*>(&alg))->addRef();
    00367
    00368   m_algs.insert(&alg);
    00369
    00370   AlgorithmHistory *algHist = new AlgorithmHistory(alg, job);
    00371   m_algmap[&alg] = algHist;
    00372
    00373 #ifndef NDEBUG
    00374   m_log << MSG::DEBUG << "Registering algorithm: ";
    00375   m_log.setColor(MSG::CYAN);
    00376   m_log << alg.name() << endreq;
    00377   m_log.resetColor();
    00378 #endif
    00379
    00380   return StatusCode(StatusCode::SUCCESS,true);
    00381
    00382 }

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

Implements IHistorySvc.

Definition at line 386 of file HistorySvc.cpp.

    00386                                                      {
    00387
    00388   m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
    00389
    00390   AlgorithmHistory *hist = getAlgHistory( alg );
    00391
    00392   if (hist == 0) {
    00393     return StatusCode::FAILURE;
    00394   }
    00395
    00396   ostringstream ost;
    00397   ost << *hist;
    00398
    00399   std::string str = ost.str();
    00400
    00401   m_log << MSG::INFO << alg.name() << " --> " << endl << str << endreq;
    00402
    00403   return StatusCode(StatusCode::SUCCESS,true);
    00404
    00405 }

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

Implements IHistorySvc.

Definition at line 426 of file HistorySvc.cpp.

    00426                                                     {
    00427
    00428   const Algorithm *palg = &alg;
    00429   set<const Algorithm*>::const_iterator itr = m_algs.find(palg);
    00430   if ( itr == m_algs.end() ) {
    00431     m_log << MSG::WARNING << "Algorithm " << alg.name() << " not registered"
    00432           << endreq;
    00433     return 0;
    00434   }
    00435
    00436   map<const Algorithm*, AlgorithmHistory*>::const_iterator itr2;
    00437   itr2 = m_algmap.find( *itr );
    00438
    00439   return ( itr2->second );
    00440
    00441 }

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

Implements IHistorySvc.

Definition at line 445 of file HistorySvc.cpp.

    00445                                                                {
    00446
    00447   set<const Algorithm*>::const_iterator itr;
    00448   for (itr=m_algs.begin(); itr!=m_algs.end(); ++itr) {
    00449     AlgorithmHistory *ah = m_algmap.find(*itr)->second;
    00450
    00451     algs.insert(ah);
    00452   }
    00453
    00454 }

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

Implements IHistorySvc.

Definition at line 826 of file HistorySvc.cpp.

    00826                                                 {
    00827
    00828   if (! m_isInitialized) {
    00829     if (p_algCtxSvc == 0) {
    00830       if ( service("AlgContextSvc",p_algCtxSvc,true).isFailure() ) {
    00831         m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endreq;
    00832         return StatusCode::FAILURE;
    00833       }
    00834     }
    00835
    00836     m_ialgtools.insert(&ialg);
    00837     return StatusCode::SUCCESS;
    00838   }
    00839
    00840   const AlgTool *alg = dynamic_cast<const AlgTool*>( &ialg );
    00841   if ( alg == 0 ) {
    00842     m_log << MSG::ERROR << "Could not dcast IAlgTool \"" << ialg.name()
    00843           << "\" to an AlgTool" << endreq;
    00844     return StatusCode::FAILURE;
    00845   }
    00846
    00847   if (m_algtools.find(alg) != m_algtools.end()) {
    00848     m_log << MSG::WARNING << "AlgTool " << ialg.name()
    00849           << " already registered in HistorySvc" << endreq;
    00850     return StatusCode::SUCCESS;
    00851   }
    00852
    00853   m_algtools.insert(alg);
    00854   (const_cast<AlgTool*>(alg))->addRef();
    00855
    00856   const JobHistory *job = getJobHistory();
    00857   AlgToolHistory *algHist = new AlgToolHistory(*alg, job);
    00858   m_algtoolmap[alg] = algHist;
    00859
    00860 #ifndef NDEBUG
    00861   m_log << MSG::DEBUG << "Registering algtool: ";
    00862   m_log.setColor(MSG::CYAN);
    00863   m_log << alg->name() << endreq;
    00864   m_log.resetColor();
    00865 #endif
    00866
    00867   return StatusCode::SUCCESS;
    00868
    00869 }

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

Implements IHistorySvc.

Definition at line 874 of file HistorySvc.cpp.

    00874                                                     {
    00875
    00876   m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;
    00877
    00878   AlgToolHistory *hist = getAlgToolHistory( alg );
    00879
    00880   if (hist == 0) {
    00881     return StatusCode::FAILURE;
    00882   }
    00883
    00884   ostringstream ost;
    00885   ost << *hist;
    00886
    00887   std::string str = ost.str();
    00888
    00889   m_log << MSG::INFO << alg.name() << " --> " << endl << str << endreq;
    00890
    00891   return StatusCode::SUCCESS;
    00892
    00893 }

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

Implements IHistorySvc.

Definition at line 915 of file HistorySvc.cpp.

    00915                                                        {
    00916
    00917   const AlgTool *palg = dynamic_cast<const AlgTool*>(&alg);
    00918   set<const AlgTool*>::const_iterator itr = m_algtools.find(palg);
    00919   if ( itr == m_algtools.end() ) {
    00920     m_log << MSG::WARNING << "AlgTool " << alg.name() << " not registered"
    00921           << endreq;
    00922     return 0;
    00923   }
    00924
    00925   map<const AlgTool*, AlgToolHistory*>::const_iterator itr2;
    00926   itr2 = m_algtoolmap.find( *itr );
    00927
    00928   return ( itr2->second );
    00929
    00930 }

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

Implements IHistorySvc.

Definition at line 935 of file HistorySvc.cpp.

    00935                                                                  {
    00936
    00937   set<const AlgTool*>::const_iterator itr;
    00938   for (itr=m_algtools.begin(); itr!=m_algtools.end(); ++itr) {
    00939     AlgToolHistory *ah = m_algtoolmap.find(*itr)->second;
    00940
    00941     algs.insert(ah);
    00942   }
    00943
    00944 }

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

Implements IHistorySvc.

Definition at line 592 of file HistorySvc.cpp.

    00593                                                                    {
    00594
    00595   if (!m_activate) return 0;
    00596
    00597
    00598   AlgorithmHistory *algHist;
    00599
    00600   IAlgorithm* ialg = getCurrentIAlg();
    00601   if (ialg == 0) {
    00602 #ifndef NDEBUG
    00603     m_log << MSG::DEBUG
    00604           << "Could not discover current Algorithm:" << endl
    00605           << "          object CLID: " << id << "  key: \"" << key
    00606           << "\"" << endreq;
    00607 #endif
    00608     algHist = 0;
    00609   } else {
    00610     Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
    00611     if (alg != 0) {
    00612       algHist = getAlgHistory( *alg );
    00613     } else {
    00614       m_log << MSG::WARNING
    00615             << "Could not extract concerete Algorithm:"
    00616             << endl
    00617             << "          object CLID: " << id << "  key: \"" << key
    00618             << "\"" << endreq;
    00619       algHist = 0;
    00620     }
    00621   }
    00622
    00623   DataHistory *hist = new DataHistory(id, key, algHist);
    00624
    00625   return hist;
    00626
    00627 }

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

Definition at line 631 of file HistorySvc.cpp.

    00632                                                             {
    00633
    00634   DHH dhh(id,key);
    00635
    00636   pair<DHMitr,DHMitr> mitr = m_datMap.equal_range(dhh);
    00637
    00638   if (mitr.first == mitr.second) {
    00639     // not in the map
    00640     DataHistory *dh = createDataHistoryObj(id,key,storeName);
    00641     m_datMap.insert(pair<DHH,DataHistory*>(dhh,dh));
    00642   } else {
    00643     // found at least one
    00644     bool match(false);
    00645
    00646     std::string algName;
    00647     IAlgorithm *ialg = getCurrentIAlg();
    00648     if (ialg != 0) {
    00649       algName = ialg->name();
    00650     } else {
    00651       algName = "UNKNOWN";
    00652     }
    00653
    00654     for (DHMitr itr = mitr.first; itr != mitr.second; ++itr) {
    00655       DataHistory *dh = itr->second;
    00656       if (dh->algorithmHistory()->algorithm_name() == algName) {
    00657         match = true;
    00658         break;
    00659       }
    00660     }
    00661
    00662     if (! match) {
    00663       DataHistory *dh = createDataHistoryObj(id,key,storeName);
    00664       m_datMap.insert(pair<DHH,DataHistory*>(dhh,dh));
    00665     }
    00666   }
    00667
    00668   return StatusCode::SUCCESS;
    00669
    00670 }

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

Implements IHistorySvc.

Definition at line 675 of file HistorySvc.cpp.

    00676                                                                  {
    00677
    00678   DHH dhh(id,key);
    00679
    00680   pair<DHMCitr,DHMCitr> mitr = m_datMap.equal_range(dhh);
    00681
    00682   if(mitr.first == mitr.second) {
    00683     return 0;
    00684   }
    00685
    00686   return mitr.first->second;
    00687
    00688 }

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

Definition at line 693 of file HistorySvc.cpp.

    00695                                                                 {
    00696
    00697   DHH dhh(id,key);
    00698
    00699   int n(0);
    00700
    00701   pair<DHMCitr,DHMCitr> mitr = m_datMap.equal_range(dhh);
    00702
    00703   for (DHMCitr itr=mitr.first; itr != mitr.second; ++itr) {
    00704     dhlist.push_back(itr->second);
    00705     n++;
    00706   }
    00707
    00708   return n;
    00709
    00710 }

void HistorySvc::handle | ( | const Incident & |  | ) | `[virtual]`

Inform that a new incident has occured.

Implements IIncidentListener.

Definition at line 949 of file HistorySvc.cpp.

    00949                                            {
    00950
    00951   if (incident.type() == IncidentType::BeginEvent) {
    00952     if (captureState().isFailure()) {
    00953       m_log << MSG::WARNING << "Error capturing state." << endl
    00954             << "Will try again at next BeginEvent incident" << endreq;
    00955     }
    00956   }
    00957
    00958 }

void HistorySvc::clearState | ( |  | ) | `[private]`

Definition at line 109 of file HistorySvc.cpp.

    00109                             {
    00110   m_algs.clear();
    00111   std::map<const Algorithm*, AlgorithmHistory*>::iterator algitr;
    00112   for (algitr = m_algmap.begin(); algitr != m_algmap.end(); ++algitr) {
    00113     AlgorithmHistory* h = algitr->second;
    00114     (const_cast<Algorithm*> (algitr->first))->release();
    00115     delete h;
    00116   }
    00117   m_algmap.clear();
    00118
    00119   m_ialgtools.clear();
    00120   m_algtools.clear();
    00121   std::map<const AlgTool*, AlgToolHistory*>::iterator atitr;
    00122   for (atitr=m_algtoolmap.begin(); atitr != m_algtoolmap.end(); ++atitr) {
    00123     (const_cast<AlgTool*> (atitr->first))->release();
    00124     delete atitr->second;
    00125   }
    00126   m_algtoolmap.clear();
    00127
    00128   m_svcs.clear();
    00129   std::map<const IService*, ServiceHistory*>::iterator svitr;
    00130   for (svitr = m_svcmap.begin(); svitr != m_svcmap.end(); ++svitr) {
    00131     (const_cast<IService*> (svitr->first))->release();
    00132     delete svitr->second;
    00133   }
    00134   m_svcmap.clear();
    00135 }

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

Definition at line 525 of file HistorySvc.cpp.

    00525                                                  {
    00526
    00527
    00528   ofs << "GLOBAL" << std::endl;
    00529   const JobHistory::PropertyList props = m_jobHistory->properties();
    00530   JobHistory::PropertyList::const_iterator itrj;
    00531   for (itrj=props.begin(); itrj != props.end(); ++itrj) {
    00532     std::string client = itrj->first;
    00533     const Property* prp = itrj->second;
    00534     ofs << client << "  " << dumpProp(prp) << std::endl;
    00535   }
    00536
    00537   ofs << std::endl << "SERVICES" << std::endl;
    00538   std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
    00539   for (itr_s=m_svcmap.begin(); itr_s != m_svcmap.end(); ++itr_s) {
    00540     const IService* svc = itr_s->first;
    00541
    00542     dumpProperties( *svc, ofs );
    00543
    00544   }
    00545
    00546   ofs << std::endl << "ALGORITHMS" << std::endl;
    00547   std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
    00548   for (itr=m_algmap.begin(); itr != m_algmap.end(); ++itr) {
    00549     const Algorithm* alg = itr->first;
    00550
    00551     dumpProperties( *alg, ofs );
    00552
    00553   }
    00554
    00555   ofs << std::endl << "ALGTOOLS" << std::endl;
    00556   std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
    00557   for (itr_a=m_algtoolmap.begin(); itr_a != m_algtoolmap.end(); ++itr_a) {
    00558     const AlgTool* alg = itr_a->first;
    00559
    00560     dumpProperties( *alg, ofs );
    00561
    00562   }
    00563
    00564
    00565 }

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

Definition at line 808 of file HistorySvc.cpp.

    00808                                                                       {
    00809
    00810   ServiceHistory *hist = getServiceHistory( svc );
    00811
    00812   if (hist == 0) {
    00813     return;
    00814   }
    00815
    00816   ServiceHistory::PropertyList::const_iterator itr;
    00817   for (itr=hist->properties().begin(); itr != hist->properties().end();++itr) {
    00818     ofs << svc.name() << "  " << dumpProp(*itr) << std::endl;
    00819   }
    00820
    00821 }

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

Definition at line 409 of file HistorySvc.cpp.

    00409                                                                        {
    00410
    00411   AlgorithmHistory *hist = getAlgHistory( alg );
    00412
    00413   if (hist == 0) {
    00414     return;
    00415   }
    00416
    00417   AlgorithmHistory::PropertyList::const_iterator itr;
    00418   for (itr=hist->properties().begin(); itr!=hist->properties().end(); ++itr) {
    00419     ofs << alg.name() << "  " << dumpProp(*itr) << std::endl;
    00420   }
    00421
    00422 }

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

Definition at line 897 of file HistorySvc.cpp.

    00897                                                                       {
    00898
    00899   AlgToolHistory *hist = getAlgToolHistory( alg );
    00900
    00901   if (hist == 0) {
    00902     return;
    00903   }
    00904
    00905   AlgToolHistory::PropertyList::const_iterator itr;
    00906   for (itr=hist->properties().begin(); itr!=hist->properties().end(); ++itr) {
    00907     ofs << alg.name() << "  " << dumpProp(*itr) << std::endl;
    00908   }
    00909
    00910 }

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

Definition at line 973 of file HistorySvc.cpp.

    00973                                             {
    00974
    00975
    00976   ofs << "GLOBAL" << std::endl;
    00977   const JobHistory::PropertyList props = m_jobHistory->properties();
    00978   JobHistory::PropertyList::const_iterator itrj;
    00979   for (itrj=props.begin(); itrj != props.end(); ++itrj) {
    00980     std::string client = itrj->first;
    00981     const Property* prp = itrj->second;
    00982     ofs << client << "  " << dumpProp(prp) << std::endl;
    00983   }
    00984
    00985
    00986   ofs << "SERVICES" << std::endl;
    00987   std::map<const IService*, ServiceHistory*>::const_iterator itr_s;
    00988   for (itr_s=m_svcmap.begin(); itr_s != m_svcmap.end(); ++itr_s) {
    00989     const IService* svc = itr_s->first;
    00990
    00991     dumpState( *svc, ofs );
    00992
    00993   }
    00994
    00995   ofs << "ALGORITHMS" << std::endl;
    00996   std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
    00997   for (itr=m_algmap.begin(); itr != m_algmap.end(); ++itr) {
    00998     const Algorithm* alg = itr->first;
    00999
    01000     dumpState( *alg, ofs );
    01001
    01002   }
    01003
    01004
    01005   ofs << "ALGTOOLS" << std::endl;
    01006   std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
    01007   for (itr_a=m_algtoolmap.begin(); itr_a != m_algtoolmap.end(); ++itr_a) {
    01008     const AlgTool* alg = itr_a->first;
    01009
    01010     dumpState( *alg, ofs );
    01011
    01012   }
    01013
    01014 }

void HistorySvc::dumpState | ( | const IService & | svc,
|  | std::ofstream & | ofs |
| ) |  |  | const`[private]`

Definition at line 1034 of file HistorySvc.cpp.

    01034                                                                  {
    01035
    01036   ServiceHistory *hist = getServiceHistory( svc );
    01037
    01038   if (hist == 0) {
    01039     return;
    01040   }
    01041
    01042   ofs << ">> " << svc.name() << endl << *hist << endl;
    01043
    01044 }

void HistorySvc::dumpState | ( | const Algorithm & | alg,
|  | std::ofstream & | ofs |
| ) |  |  | const`[private]`

Definition at line 1019 of file HistorySvc.cpp.

    01019                                                                   {
    01020
    01021   AlgorithmHistory *hist = getAlgHistory( alg );
    01022
    01023   if (hist == 0) {
    01024     return;
    01025   }
    01026
    01027   ofs << ">> " << alg.name() << endl << *hist << endl;
    01028
    01029 }

void HistorySvc::dumpState | ( | const IAlgTool & | alg,
|  | std::ofstream & | ofs |
| ) |  |  | const`[private]`

Definition at line 1049 of file HistorySvc.cpp.

    01049                                                                  {
    01050
    01051   AlgToolHistory *hist = getAlgToolHistory( alg );
    01052
    01053   if (hist == 0) {
    01054     return;
    01055   }
    01056
    01057   ofs << ">> " << alg.name() << endl << *hist << endl;
    01058
    01059 }

std::string HistorySvc::dumpProp | ( | const Property * | prop | ) | const`[private]`

Definition at line 964 of file HistorySvc.cpp.

    00964                                                {
    00965   std::ostringstream ost;
    00966   prop->fillStream(ost);
    00967   return ost.str();
    00968 }

IAlgorithm * HistorySvc::getCurrentIAlg | ( |  | ) | const`[private]`

Definition at line 577 of file HistorySvc.cpp.

    00577                                  {
    00578   if (p_algCtxSvc == 0) {
    00579     m_log << MSG::WARNING << "trying to create DataHistoryObj before "
    00580           << "HistorySvc has been initialized" << endreq;
    00581     return 0;
    00582
    00583   } else {
    00584     return p_algCtxSvc->currentAlg();
    00585   }
    00586 }

## Friends And Related Function Documentation

friend class SvcFactory< HistorySvc >`[friend]`

Definition at line 112 of file HistorySvc.h.

## Member Data Documentation

bool HistorySvc::m_isInitialized`[private]`

Definition at line 114 of file HistorySvc.h.

bool HistorySvc::m_dump`[private]`

Definition at line 115 of file HistorySvc.h.

bool HistorySvc::m_activate`[private]`

Definition at line 116 of file HistorySvc.h.

IAlgContextSvc* HistorySvc::p_algCtxSvc`[private]`

Definition at line 118 of file HistorySvc.h.

std::set<const Algorithm*> HistorySvc::m_algs`[private]`

Definition at line 120 of file HistorySvc.h.

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

Definition at line 121 of file HistorySvc.h.

std::set<const IAlgTool*> HistorySvc::m_ialgtools`[private]`

Definition at line 123 of file HistorySvc.h.

std::set<const AlgTool*> HistorySvc::m_algtools`[private]`

Definition at line 124 of file HistorySvc.h.

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

Definition at line 125 of file HistorySvc.h.

std::set<const IService*> HistorySvc::m_svcs`[private]`

Definition at line 127 of file HistorySvc.h.

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

Definition at line 128 of file HistorySvc.h.

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

Definition at line 130 of file HistorySvc.h.

JobHistory* HistorySvc::m_jobHistory`[private]`

Definition at line 134 of file HistorySvc.h.

std::string HistorySvc::m_outputFile`[private]`

Definition at line 136 of file HistorySvc.h.

IIncidentSvc* HistorySvc::m_incidentSvc`[private]`

Definition at line 152 of file HistorySvc.h.

MsgStream HistorySvc::m_log`[mutable, private]`

Definition at line 154 of file HistorySvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiSvc/src/HistorySvc/HistorySvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r3/GaudiSvc/src/HistorySvc/HistorySvc.cpp