BesTimerSvc Class Reference

#include <BesTimerSvc.h>

Inheritance diagram for BesTimerSvc:

IBesTimerSvc List of all members.

Public Member Functions

 BesTimerSvc (const std::string &name, ISvcLocator *svcloc)
 ~BesTimerSvc ()
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvUnknown)
virtual StatusCode initialize ()
virtual StatusCode finalize ()
virtual BesTimeraddItem (const std::string &name)
virtual std::vector< BesTimer
* >::iterator 
begin (void)
virtual std::vector< BesTimer
* >::iterator 
end (void)
virtual void print ()

Static Public Member Functions

static const InterfaceID & interfaceID ()

Private Attributes

std::vector< BesTimer * > m_itemList

Detailed Description

Definition at line 16 of file BesTimerSvc.h.


Constructor & Destructor Documentation

BesTimerSvc::BesTimerSvc ( const std::string name,
ISvcLocator *  svcloc 
)

Definition at line 16 of file BesTimerSvc.cxx.

00016 : Service(name, svcloc) {}

BesTimerSvc::~BesTimerSvc (  ) 

Definition at line 18 of file BesTimerSvc.cxx.

References m_itemList.

00018                           {
00019   std::vector < BesTimer* >::iterator it =  m_itemList.begin();
00020   for (; it != m_itemList.end(); it++) {
00021     delete (*it);
00022   }  
00023 }


Member Function Documentation

BesTimer * BesTimerSvc::addItem ( const std::string name  )  [virtual]

Implements IBesTimerSvc.

Definition at line 56 of file BesTimerSvc.cxx.

References Bes_Common::DEBUG, and m_itemList.

00056                                                         {
00057 
00058   // Create a BesTimer and return a pointer to it
00059   // If an item of that name already exists, flag error
00060   // by returning NULL
00061   
00062   MsgStream log(messageService(), name());
00063   log << MSG::DEBUG << name() << " adding " << itemName  << endreq;
00064   
00065   BesTimer* item = new BesTimer(itemName);
00066   m_itemList.push_back(item);
00067   return item;
00068 }

std::vector< BesTimer * >::iterator BesTimerSvc::begin ( void   )  [virtual]

Implements IBesTimerSvc.

Definition at line 114 of file BesTimerSvc.cxx.

References m_itemList.

00114                                                          {
00115   return m_itemList.begin();
00116 }

std::vector< BesTimer * >::iterator BesTimerSvc::end ( void   )  [virtual]

Implements IBesTimerSvc.

Definition at line 117 of file BesTimerSvc.cxx.

References m_itemList.

00117                                                       {
00118   return m_itemList.end();
00119 }

StatusCode BesTimerSvc::finalize (  )  [virtual]

Definition at line 47 of file BesTimerSvc.cxx.

References Bes_Common::INFO, and print().

00047                                    {
00048   MsgStream log(messageService(), name());
00049   log << MSG::INFO << name() << ": End of Run Statistics" << endreq;
00050   this->print();
00051   return StatusCode::SUCCESS;
00052 }

StatusCode BesTimerSvc::initialize (  )  [virtual]

Definition at line 34 of file BesTimerSvc.cxx.

References Bes_Common::INFO.

00034                                      {
00035   MsgStream log(messageService(), name());
00036   log << MSG::INFO << name() << ": Start of run initialisation" << endreq;
00037 
00038   StatusCode sc = Service::initialize();
00039   if ( sc.isFailure() ) return sc;
00040   // Set my own properties
00041   setProperties();  
00042   
00043   return StatusCode::SUCCESS;
00044 }

static const InterfaceID& IBesTimerSvc::interfaceID (  )  [inline, static, inherited]

Definition at line 20 of file IBesTimerSvc.h.

References IID_IBesTimerSvc().

00020 { return IID_IBesTimerSvc; }

void BesTimerSvc::print (  )  [virtual]

Implements IBesTimerSvc.

Definition at line 70 of file BesTimerSvc.cxx.

References genRecEmupikp::i, Bes_Common::INFO, m_itemList, and deljobs::string.

Referenced by finalize().

00070                          {
00071   MsgStream log(messageService(), name());
00072 
00073   log << MSG::INFO << "==============================BesTimerSvc::Print===============================" << endreq;
00074   unsigned int maxname=0;
00075   std::vector < BesTimer* >::iterator it =  m_itemList.begin();
00076   for (; it != m_itemList.end(); it++) {
00077     if ((*it)->name().length() > maxname) maxname = static_cast<int>((*it)->name().length());
00078     if (!(*it)->propName().empty()) {
00079       if ((*it)->propName().length() > maxname) maxname = static_cast<int>((*it)->propName().length());
00080     }
00081   }
00082 
00083   it =  m_itemList.begin();
00084   for (; it != m_itemList.end(); it++) {
00085     std::string nam = (*it)->name();
00086     for (unsigned int i = static_cast<int>(nam.length()); i<maxname; i++) nam.insert(i," ");
00087     log << MSG::INFO << nam << "  mean(t) : " << std::setw(12) << (*it)->mean()<< 
00088       " ms      rms : " << std::setw(12) << (*it)->rms() << " ms " << endreq;
00089   }
00090   log << MSG::INFO << "------------------------------------------------------------------------------" << endreq;
00091   it =  m_itemList.begin();
00092   for (; it != m_itemList.end(); it++) {
00093     if (!(*it)->propName().empty()) {
00094       std::string nam = (*it)->name();
00095       for (unsigned int i = static_cast<int>(nam.length()); i<maxname; i++) nam.insert(i," ");
00096       log << MSG::INFO << nam << "  mean(t) : " << std::setw(12) << (*it)->mean()<< 
00097         " ms      rms : " << std::setw(12) << (*it)->rms() << " ms " << endreq;
00098 
00099       nam = (*it)->propName();
00100       for (unsigned int i = static_cast<int>(nam.length()); i<maxname; i++) nam.insert(i," ");
00101       if ((*it)->meanPropVal() == 0) {
00102         log << MSG::INFO << nam << "  mean(N) : " << std::setw(12) << endreq;
00103       } else {
00104         log << MSG::INFO << nam << "  mean(N) : " << std::setw(12) << (*it)->meanPropVal() << 
00105           "   mean(t/N) : " 
00106             << 1000.*(*it)->meanTimePerObject() << " us " << endreq; 
00107       }
00108     }
00109   }
00110 
00111   log << MSG::INFO << "==============================BesTimerSvc::Print===============================" << endreq;
00112   }

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

Definition at line 25 of file BesTimerSvc.cxx.

References IID_IBesTimerSvc().

00025                                                                                      {
00026 
00027   if ( IID_IBesTimerSvc.versionMatch(riid) ) { 
00028     *ppvInterface = static_cast<IBesTimerSvc*> (this); 
00029   } else { 
00030     return Service::queryInterface(riid, ppvInterface) ; 
00031   }
00032   return StatusCode::SUCCESS;
00033 }


Member Data Documentation

std::vector< BesTimer* > BesTimerSvc::m_itemList [private]

Definition at line 33 of file BesTimerSvc.h.

Referenced by addItem(), begin(), end(), print(), and ~BesTimerSvc().


Generated on Tue Nov 29 23:17:35 2016 for BOSS_7.0.2 by  doxygen 1.4.7