Gaudi Framework, version v22r2

Home   Generated: Tue May 10 2011
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends

HistorySvc Class Reference

HistorySvc class definition. More...

#include <HistorySvc.h>

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

List of all members.

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

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

Friends

class SvcFactory< HistorySvc >

Detailed Description

HistorySvc class definition.

Definition at line 45 of file HistorySvc.h.


Member Typedef Documentation

Definition at line 98 of file HistorySvc.h.

Definition at line 100 of file HistorySvc.h.

Definition at line 99 of file HistorySvc.h.


Constructor & Destructor Documentation

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

Definition at line 69 of file HistorySvc.cpp.

  : base_class( name, svc ),
    m_isInitialized(false),
    m_dump(false),
    p_algCtxSvc(0),
    m_jobHistory(0),
    m_outputFile(""),
    m_incidentSvc(0),
    m_log(msgSvc(), name )

{
    declareProperty("Dump",m_dump);
    declareProperty("Activate", m_activate=true);
    declareProperty("OutputFile",m_outputFile);

    // 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 91 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 194 of file HistorySvc.cpp.

                                    {

  if (m_jobHistory == 0) {
    m_jobHistory = new JobHistory;
    IJobOptionsSvc *jo;
    if (service("JobOptionsSvc",jo).isFailure()) {
       m_log << MSG::ERROR
             << "Could not get jobOptionsSvc - "
             << "not adding properties to JobHistory" << endmsg;
    } else {

      bool foundAppMgr(false);

      std::vector<std::string> clients = jo->getClients();
      std::vector<std::string>::const_iterator it;
      std::vector<const Property*>::const_iterator itr;
      for (it=clients.begin(); it!=clients.end(); ++it) {
        if (*it == "ApplicationMgr") {
          foundAppMgr = true;
        }
        const std::vector<const Property*> *props = jo->getProperties(*it);
        for (itr=props->begin(); itr != props->end(); ++itr) {
          m_jobHistory->addProperty( *it, *itr );
        }
      }

      if (!foundAppMgr) {
        IProperty *ap;
        if (service("ApplicationMgr",ap).isFailure()) {
          m_log << MSG::ERROR << "could not get the ApplicationMgr" << endmsg;
        } else {
          std::vector<Property*>::const_iterator itr2;
          const std::vector<Property*> props = ap->getProperties();
          for (itr2=props.begin(); itr2 != props.end(); ++itr2) {
            m_jobHistory->addProperty( "ApplicationMgr", *itr2 );
          }
        }
      }

    }
  }


  StatusCode sc;
  IAlgManager* algMgr = 0;
  sc = Gaudi::svcLocator()->queryInterface( IAlgManager::interfaceID(),
                                            pp_cast<void>(&algMgr) );
  if (sc.isFailure()) {
    m_log << MSG::ERROR << "Could not get AlgManager" << endmsg;
    return StatusCode::FAILURE;
  } else {

    std::list<IAlgorithm*> algs;
    algs = algMgr->getAlgorithms();
    std::list<IAlgorithm*>::const_iterator itr;
    for (itr=algs.begin(); itr!=algs.end(); ++itr) {
      Algorithm* alg = dynamic_cast<Algorithm*> (*itr);
      if (alg == 0) {
        m_log << MSG::WARNING << "Algorithm " << (*itr)->name()
              << " does not inherit from Algorithm. Not registering it."
              << endmsg;
      } else {
        registerAlg( *alg ).ignore();
      }
    }

    m_log << MSG::INFO;
    m_log << "Registered " << algs.size() << " Algorithms" << endmsg;

  }


  m_isInitialized = true;
  std::set<const IAlgTool*>::const_iterator itra;
  for (itra = m_ialgtools.begin(); itra != m_ialgtools.end(); ++itra) {
    (const_cast<IAlgTool*>(*itra))->addRef();
    registerAlgTool(**itra).ignore();
  }

  m_log << MSG::INFO << "Registered " << m_algtools.size() << " AlgTools"
        << endmsg;


  std::list<IService*> svcs = Gaudi::svcLocator()->getServices();

  std::list<IService*>::const_iterator itrs;
  for (itrs=svcs.begin(); itrs!=svcs.end(); ++itrs) {
    (*itrs)->addRef();
    registerSvc(**itrs).ignore();
  }

  m_log << MSG::INFO;
  m_log << "Registered " << svcs.size() << " Services" << endmsg;

  return StatusCode::SUCCESS;


}
void HistorySvc::clearState (  ) [private]

Definition at line 109 of file HistorySvc.cpp.

                            {
  m_algs.clear();
  std::map<const Algorithm*, AlgorithmHistory*>::iterator algitr;
  for (algitr = m_algmap.begin(); algitr != m_algmap.end(); ++algitr) {
    AlgorithmHistory* h = algitr->second;
    (const_cast<Algorithm*> (algitr->first))->release();
    delete h;
  }
  m_algmap.clear();

  m_ialgtools.clear();
  m_algtools.clear();
  std::map<const AlgTool*, AlgToolHistory*>::iterator atitr;
  for (atitr=m_algtoolmap.begin(); atitr != m_algtoolmap.end(); ++atitr) {
    (const_cast<AlgTool*> (atitr->first))->release();
    delete atitr->second;
  }
  m_algtoolmap.clear();

  m_svcs.clear();
  std::map<const IService*, ServiceHistory*>::iterator svitr;
  for (svitr = m_svcmap.begin(); svitr != m_svcmap.end(); ++svitr) {
    (const_cast<IService*> (svitr->first))->release();
    delete svitr->second;
  }
  m_svcmap.clear();
}
DataHistory * HistorySvc::createDataHistoryObj ( const CLID id,
const std::string key,
const std::string store 
) [virtual]

Definition at line 588 of file HistorySvc.cpp.

                                                                   {

  if (!m_activate) return 0;


  AlgorithmHistory *algHist;

  IAlgorithm* ialg = getCurrentIAlg();
  if (ialg == 0) {
#ifndef NDEBUG
    m_log << MSG::DEBUG
          << "Could not discover current Algorithm:" << endl
          << "          object CLID: " << id << "  key: \"" << key
          << "\"" << endmsg;
#endif
    algHist = 0;
  } else {
    Algorithm* alg = dynamic_cast<Algorithm*>(ialg);
    if (alg != 0) {
      algHist = getAlgHistory( *alg );
    } else {
      m_log << MSG::WARNING
            << "Could not extract concerete 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 [private]

Definition at line 960 of file HistorySvc.cpp.

                                               {
  std::ostringstream ost;
  prop->fillStream(ost);
  return ost.str();
}
void HistorySvc::dumpProperties ( std::ofstream ofs ) const [private]

Definition at line 521 of file HistorySvc.cpp.

                                                 {


  ofs << "GLOBAL" << std::endl;
  const JobHistory::PropertyList props = m_jobHistory->properties();
  JobHistory::PropertyList::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 804 of file HistorySvc.cpp.

                                                                      {

  ServiceHistory *hist = getServiceHistory( svc );

  if (hist == 0) {
    return;
  }

  ServiceHistory::PropertyList::const_iterator itr;
  for (itr=hist->properties().begin(); itr != hist->properties().end();++itr) {
    ofs << svc.name() << "  " << dumpProp(*itr) << std::endl;
  }

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

Definition at line 401 of file HistorySvc.cpp.

                                                                       {

  AlgorithmHistory *hist = getAlgHistory( alg );

  if (hist == 0) {
    return;
  }

  AlgorithmHistory::PropertyList::const_iterator itr;
  for (itr=hist->properties().begin(); itr!=hist->properties().end(); ++itr) {
    ofs << alg.name() << "  " << dumpProp(*itr) << std::endl;
  }

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

Definition at line 893 of file HistorySvc.cpp.

                                                                      {

  AlgToolHistory *hist = getAlgToolHistory( alg );

  if (hist == 0) {
    return;
  }

  AlgToolHistory::PropertyList::const_iterator itr;
  for (itr=hist->properties().begin(); itr!=hist->properties().end(); ++itr) {
    ofs << alg.name() << "  " << dumpProp(*itr) << std::endl;
  }

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

Definition at line 1045 of file HistorySvc.cpp.

                                                                 {

  AlgToolHistory *hist = getAlgToolHistory( alg );

  if (hist == 0) {
    return;
  }

  ofs << ">> " << alg.name() << endl << *hist << endl;

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

Definition at line 1030 of file HistorySvc.cpp.

                                                                 {

  ServiceHistory *hist = getServiceHistory( svc );

  if (hist == 0) {
    return;
  }

  ofs << ">> " << svc.name() << endl << *hist << endl;

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

Definition at line 1015 of file HistorySvc.cpp.

                                                                  {

  AlgorithmHistory *hist = getAlgHistory( alg );

  if (hist == 0) {
    return;
  }

  ofs << ">> " << alg.name() << endl << *hist << endl;

}
void HistorySvc::dumpState ( std::ofstream ofs ) const [private]

Definition at line 969 of file HistorySvc.cpp.

                                            {


  ofs << "GLOBAL" << std::endl;
  const JobHistory::PropertyList props = m_jobHistory->properties();
  JobHistory::PropertyList::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 << "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;

    dumpState( *svc, ofs );

  }

  ofs << "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;

    dumpState( *alg, ofs );

  }


  ofs << "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;

    dumpState( *alg, ofs );

  }

}
StatusCode HistorySvc::finalize ( void   ) [virtual]

Reimplemented from Service.

Definition at line 329 of file HistorySvc.cpp.

                                {

 
  clearState();

  StatusCode status = Service::finalize();

  if ( status.isSuccess() )
    m_log << MSG::INFO << "Service finalised successfully" << endmsg;

  return status;

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

Definition at line 437 of file HistorySvc.cpp.

                                                               {

  set<const Algorithm*>::const_iterator itr;
  for (itr=m_algs.begin(); itr!=m_algs.end(); ++itr) {
    AlgorithmHistory *ah = m_algmap.find(*itr)->second;

    algs.insert(ah);
  }

}
AlgorithmHistory * HistorySvc::getAlgHistory ( const Algorithm alg ) const [virtual]

Definition at line 418 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 );

}
AlgToolHistory * HistorySvc::getAlgToolHistory ( const IAlgTool alg ) const [virtual]

Definition at line 911 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 931 of file HistorySvc.cpp.

                                                                 {

  set<const AlgTool*>::const_iterator itr;
  for (itr=m_algtools.begin(); itr!=m_algtools.end(); ++itr) {
    AlgToolHistory *ah = m_algtoolmap.find(*itr)->second;

    algs.insert(ah);
  }

}
IAlgorithm * HistorySvc::getCurrentIAlg (  ) const [private]

Definition at line 573 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 {
    return p_algCtxSvc->currentAlg();
  }
}
DataHistory * HistorySvc::getDataHistory ( const CLID id,
const std::string key,
const std::string store 
) const [virtual]

Definition at line 671 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 689 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 565 of file HistorySvc.cpp.

                                {

  return m_jobHistory;

}
ServiceHistory * HistorySvc::getServiceHistory ( const IService svc ) const [virtual]

Definition at line 747 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 764 of file HistorySvc.cpp.

                                                                 {

  set<const IService*>::const_iterator itr;
  for (itr=m_svcs.begin(); itr!=m_svcs.end(); ++itr) {
    ServiceHistory *sh = m_svcmap.find( *itr )->second;

    svcs.insert(sh);
  }

}
void HistorySvc::handle ( const Incident inc ) [virtual]

Definition at line 945 of file HistorySvc.cpp.

                                           {

  if (incident.type() == IncidentType::BeginEvent) {
    if (captureState().isFailure()) {
      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 140 of file HistorySvc.cpp.

                                  {

  StatusCode status = Service::initialize();
  m_log.setLevel( m_outputLevel.value() );

  if (status.isFailure()) {
#ifndef NDEBUG
    m_log << MSG::DEBUG << "Failed to initialize the base class (Service)"
          << endmsg;
#endif
    return status;
  }

#ifndef NDEBUG
  m_log << MSG::DEBUG << "Initializing HistorySvc" << endmsg;
#endif

  if (!m_activate) return StatusCode::SUCCESS;

  static const bool CREATEIF(true);

  if ( service("AlgContextSvc",p_algCtxSvc,CREATEIF).isFailure() ) {
    m_log << MSG::ERROR << "unable to get the AlgContextSvc" << endmsg;
    return StatusCode::FAILURE;
  }

  if (service("IncidentSvc", m_incidentSvc, CREATEIF).isFailure()) {
    m_log << MSG::ERROR << "unable to get the IncidentSvc" << endmsg;
    return StatusCode::FAILURE;
  }

  // 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;
    return StatusCode::FAILURE;
  }

  // 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
  m_incidentSvc->addListener(this,IncidentType::BeginEvent,
                             std::numeric_limits<long>::min(),rethrow,oneShot);

  m_isInitialized = true;

  return StatusCode::SUCCESS;

}
StatusCode HistorySvc::listProperties ( const Algorithm alg ) const [virtual]

Definition at line 378 of file HistorySvc.cpp.

                                                     {

  m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;

  AlgorithmHistory *hist = getAlgHistory( alg );

  if (hist == 0) {
    return StatusCode::FAILURE;
  }

  ostringstream ost;
  ost << *hist;

  std::string str = ost.str();

  m_log << MSG::INFO << alg.name() << " --> " << endl << str << endmsg;

  return StatusCode(StatusCode::SUCCESS,true);

}
StatusCode HistorySvc::listProperties ( const IAlgTool alg ) const [virtual]

Definition at line 870 of file HistorySvc.cpp.

                                                    {

  m_log << MSG::INFO << "Dumping properties for " << alg.name() << endl;

  AlgToolHistory *hist = getAlgToolHistory( alg );

  if (hist == 0) {
    return StatusCode::FAILURE;
  }

  ostringstream ost;
  ost << *hist;

  std::string str = ost.str();

  m_log << MSG::INFO << alg.name() << " --> " << endl << str << endmsg;

  return StatusCode::SUCCESS;

}
StatusCode HistorySvc::listProperties ( const IService svc ) const [virtual]

Definition at line 778 of file HistorySvc.cpp.

                                                    {

  m_log << MSG::INFO << "Dumping properties for " << svc.name() << endl;

  ServiceHistory *hist = getServiceHistory( svc );

  if (hist == 0) {
    return StatusCode::FAILURE;
  }

  ostringstream ost;
  ost << *hist;

  std::string str = ost.str();

  m_log << MSG::INFO << svc.name() << " --> " << endl << str << endmsg;



  return StatusCode(StatusCode::SUCCESS,true);

}
StatusCode HistorySvc::listProperties (  ) const [virtual]

Definition at line 462 of file HistorySvc.cpp.

                                 {

  m_log << MSG::INFO;
  m_log.setColor(MSG::CYAN);
  m_log << "Dumping properties for all Algorithms (" << m_algmap.size() 
        << ")" << endmsg;

  std::map<const Algorithm*, AlgorithmHistory*>::const_iterator itr;
  for (itr=m_algmap.begin(); itr != m_algmap.end(); ++itr) {
    const Algorithm* alg = itr->first;

    listProperties( *alg ).ignore();

  }

  m_log << MSG::INFO;
  m_log.setColor(MSG::CYAN);
  m_log << "Dumping properties for all AlgTools (" << m_algtoolmap.size()
        << ")" << endmsg;

  std::map<const AlgTool*, AlgToolHistory*>::const_iterator itr_a;
  for (itr_a=m_algtoolmap.begin(); itr_a != m_algtoolmap.end(); ++itr_a) {
    m_log << MSG::DEBUG << " --> " << itr_a->second->algtool_name() << endmsg;
    const AlgTool* alg = itr_a->first;

    listProperties( *alg ).ignore();

  }

  m_log << MSG::INFO;
  m_log.setColor(MSG::CYAN);
  m_log << "Dumping properties for all Services (" << m_svcmap.size()
        << ")" << endmsg;

  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;

    listProperties( *svc ).ignore();

  }

  m_log << MSG::INFO;
  m_log.setColor(MSG::CYAN);
  m_log << "Dumping properties for Job";
  m_log.resetColor();

  ostringstream ost;
  ost << *m_jobHistory;
  std::string str = ost.str();

  m_log << std::endl << str << endmsg;

  return StatusCode(StatusCode::SUCCESS,true);

}
StatusCode HistorySvc::registerAlg ( const Algorithm alg ) [virtual]

Definition at line 349 of file HistorySvc.cpp.

                                            {

  JobHistory *job = getJobHistory();
  if (m_algmap.find(&alg) != m_algmap.end()) {
    m_log << MSG::WARNING << "Algorithm " << alg.name()
          << " already registered with HistorySvc" << endmsg;
    return StatusCode::SUCCESS;
  }

  (const_cast<Algorithm*>(&alg))->addRef();

  m_algs.insert(&alg);

  AlgorithmHistory *algHist = new AlgorithmHistory(alg, job);
  m_algmap[&alg] = algHist;

#ifndef NDEBUG
  m_log << MSG::DEBUG << "Registering algorithm: ";
  m_log.setColor(MSG::CYAN);
  m_log << alg.name() << endmsg;
  m_log.resetColor();
#endif

  return StatusCode(StatusCode::SUCCESS,true);

}
StatusCode HistorySvc::registerAlgTool ( const IAlgTool ialg ) [virtual]

Definition at line 822 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;
        return StatusCode::FAILURE;
      }
    }

    m_ialgtools.insert(&ialg);
    return StatusCode::SUCCESS;
  }

  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;
    return StatusCode::FAILURE;
  }

  if (m_algtools.find(alg) != m_algtools.end()) {
    m_log << MSG::WARNING << "AlgTool " << ialg.name()
          << " already registered in HistorySvc" << endmsg;
    return StatusCode::SUCCESS;
  }

  m_algtools.insert(alg);
  (const_cast<AlgTool*>(alg))->addRef();

  const JobHistory *job = getJobHistory();
  AlgToolHistory *algHist = new AlgToolHistory(*alg, job);
  m_algtoolmap[alg] = algHist;

#ifndef NDEBUG
  m_log << MSG::DEBUG << "Registering algtool: ";
  m_log.setColor(MSG::CYAN);
  m_log << alg->name() << endmsg;
  m_log.resetColor();
#endif

  return StatusCode::SUCCESS;

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

Definition at line 627 of file HistorySvc.cpp.

                                                            {

  DHH dhh(id,key);

  pair<DHMitr,DHMitr> mitr = m_datMap.equal_range(dhh);

  if (mitr.first == mitr.second) {
    // not in the map
    DataHistory *dh = createDataHistoryObj(id,key,storeName);
    m_datMap.insert(pair<DHH,DataHistory*>(dhh,dh));
  } else {
    // found at least one
    bool match(false);

    std::string algName;
    IAlgorithm *ialg = getCurrentIAlg();
    if (ialg != 0) {
      algName = ialg->name();
    } else {
      algName = "UNKNOWN";
    }

    for (DHMitr itr = mitr.first; itr != mitr.second; ++itr) {
      DataHistory *dh = itr->second;
      if (dh->algorithmHistory()->algorithm_name() == algName) {
        match = true;
        break;
      }
    }

    if (! match) {
      DataHistory *dh = createDataHistoryObj(id,key,storeName);
      m_datMap.insert(pair<DHH,DataHistory*>(dhh,dh));
    }
  }

  return StatusCode::SUCCESS;

}
StatusCode HistorySvc::registerJob (  ) [virtual]

Definition at line 451 of file HistorySvc.cpp.

                        {


  return StatusCode(StatusCode::SUCCESS,true);


}
StatusCode HistorySvc::registerSvc ( const IService svc ) [virtual]

Definition at line 711 of file HistorySvc.cpp.

                                           {

  if ( svc.name() == "HistoryStore" ) {
    //    m_log << MSG::WARNING << "not registering store" << endmsg;
    return StatusCode(StatusCode::SUCCESS,true);
  }

  JobHistory *job = getJobHistory();
  const IService* psvc = &svc;
  map<const IService*, ServiceHistory*>::const_iterator itr =
    m_svcmap.find(psvc);
  if (itr == m_svcmap.end()) {

#ifndef NDEBUG
    m_log << MSG::DEBUG << "Registering Service: ";
    m_log.setColor(MSG::CYAN);
    m_log << svc.name() << endmsg;
#endif

    m_svcs.insert(psvc);

    ServiceHistory *svcHist = new ServiceHistory(&svc, job);
    m_svcmap[psvc] = svcHist;

    (const_cast<IService*>(psvc))->addRef();

  }

  m_log.resetColor();
  return StatusCode(StatusCode::SUCCESS,true);

}
StatusCode HistorySvc::reinitialize (  ) [virtual]

Reimplemented from Service.

Definition at line 97 of file HistorySvc.cpp.

StatusCode HistorySvc::stop (  ) [virtual]

Reimplemented from Service.

Definition at line 298 of file HistorySvc.cpp.

                            {

  if (!m_activate) return StatusCode::SUCCESS;

  if (m_dump) {
    listProperties().ignore();
  }

  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();
    }
  }

  clearState();

  return StatusCode::SUCCESS;

}

Friends And Related Function Documentation

friend class SvcFactory< HistorySvc > [friend]

Definition at line 105 of file HistorySvc.h.


Member Data Documentation

bool HistorySvc::m_activate [private]

Definition at line 109 of file HistorySvc.h.

Definition at line 114 of file HistorySvc.h.

Definition at line 113 of file HistorySvc.h.

Definition at line 118 of file HistorySvc.h.

Definition at line 117 of file HistorySvc.h.

Definition at line 123 of file HistorySvc.h.

bool HistorySvc::m_dump [private]

Definition at line 108 of file HistorySvc.h.

Definition at line 116 of file HistorySvc.h.

Definition at line 145 of file HistorySvc.h.

Definition at line 107 of file HistorySvc.h.

Definition at line 127 of file HistorySvc.h.

MsgStream HistorySvc::m_log [mutable, private]

Definition at line 148 of file HistorySvc.h.

Definition at line 129 of file HistorySvc.h.

Definition at line 121 of file HistorySvc.h.

Definition at line 120 of file HistorySvc.h.

Definition at line 146 of file HistorySvc.h.

Definition at line 111 of file HistorySvc.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Tue May 10 2011 18:54:49 for Gaudi Framework, version v22r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004