Gaudi Framework, version v20r2

Generated: 18 Jul 2008

AlgContextSvc Class Reference

#include <AlgContextSvc.h>

Inheritance diagram for AlgContextSvc:

Inheritance graph
[legend]
Collaboration diagram for AlgContextSvc:

Collaboration graph
[legend]
List of all members.

Detailed Description

Definition at line 41 of file AlgContextSvc.h.

Public Member Functions

virtual StatusCode setCurrentAlg (IAlgorithm *a)
 set the currently executing algorithm ("push_back")
virtual StatusCode unSetCurrentAlg (IAlgorithm *a)
 remove the algorithm ("pop_back")
virtual IAlgorithmcurrentAlg () const
 accessor to current algorithm:
virtual const IAlgContextSvc::Algorithmsalgorithms () const
 get the stack of executed algorithms
virtual StatusCode queryInterface (const InterfaceID &riid, void **ppvi)
 Gaudi_cast,.
virtual void handle (const Incident &)
 handle incident
virtual StatusCode initialize ()
 standard initialization of the service
virtual StatusCode finalize ()
 standard finalization of the service
 AlgContextSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~AlgContextSvc ()
 Standard Destructor.

Private Member Functions

 AlgContextSvc ()
 no default constructor
 AlgContextSvc (const AlgContextSvc &)
 no copy constructor
AlgContextSvcoperator= (const AlgContextSvc &)
 no assignement

Private Attributes

IAlgContextSvc::Algorithms m_algorithms
 the stack of currect algorithms
IIncidentSvcm_inc
 pointer to Incident Service
bool m_check

Friends

class SvcFactory< AlgContextSvc >
 friend factory for instantiations


Constructor & Destructor Documentation

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

Standard Constructor.

See also:
Service

Definition at line 44 of file AlgContextSvc.cpp.

00046   : Service ( name , svc  )
00047   , m_algorithms (  0   )
00048   , m_inc        (  0   ) 
00049   , m_check      ( true )
00050 {
00051   declareProperty ( "Check" , m_check , "Flag to perform more checks" );
00052 }

AlgContextSvc::~AlgContextSvc (  )  [virtual]

Standard Destructor.

Definition at line 56 of file AlgContextSvc.cpp.

00056 {}

AlgContextSvc::AlgContextSvc (  )  [private]

no default constructor

AlgContextSvc::AlgContextSvc ( const AlgContextSvc  )  [private]

no copy constructor


Member Function Documentation

StatusCode AlgContextSvc::setCurrentAlg ( IAlgorithm a  )  [virtual]

set the currently executing algorithm ("push_back")

See also:
IAlgContextSvc

Implements IAlgContextSvc.

Definition at line 142 of file AlgContextSvc.cpp.

References endreq(), m_algorithms, Service::msgSvc(), Service::name(), std::vector< _Tp, _Alloc >::push_back(), StatusCode::RECOVERABLE, StatusCode::SUCCESS, and MSG::WARNING.

00143 {
00144   if ( 0 == a ) 
00145   {
00146     MsgStream log ( msgSvc() , name() ) ;
00147     log << MSG::WARNING << "IAlgorithm* points to NULL" << endreq ;
00148     //
00149     return StatusCode::RECOVERABLE ;                              // RETURN
00150   }  
00151   m_algorithms.push_back ( a ) ; 
00152   //
00153   return StatusCode::SUCCESS ;                                    // RETURN
00154 }

StatusCode AlgContextSvc::unSetCurrentAlg ( IAlgorithm a  )  [virtual]

remove the algorithm ("pop_back")

See also:
IAlgContextSvc

Implements IAlgContextSvc.

Definition at line 158 of file AlgContextSvc.cpp.

References std::vector< _Tp, _Alloc >::back(), std::vector< _Tp, _Alloc >::empty(), endreq(), MSG::ERROR, StatusCode::FAILURE, m_algorithms, Service::msgSvc(), Service::name(), std::vector< _Tp, _Alloc >::pop_back(), StatusCode::RECOVERABLE, StatusCode::SUCCESS, and MSG::WARNING.

00159 {
00160   if ( 0 == a ) 
00161   {
00162     MsgStream log ( msgSvc() , name() ) ;
00163     log << MSG::WARNING << "IAlgorithm* points to NULL" << endreq ;
00164     //
00165     return StatusCode::RECOVERABLE ;                              // RETURN
00166   }  
00167   if ( m_algorithms.empty() || m_algorithms.back() != a ) 
00168   {
00169     MsgStream log ( msgSvc() , name() ) ;
00170     log << MSG::ERROR << "Algorithm stack is invalid" << endreq ;  
00171     //
00172     return StatusCode::FAILURE ;
00173   }
00174   //
00175   m_algorithms.pop_back() ;                                      // POP_BACK
00176   //
00177   return StatusCode::SUCCESS ;
00178 } 

IAlgorithm * AlgContextSvc::currentAlg (  )  const [virtual]

accessor to current algorithm:

See also:
IAlgContextSvc

Implements IAlgContextSvc.

Definition at line 182 of file AlgContextSvc.cpp.

References std::vector< _Tp, _Alloc >::back(), std::vector< _Tp, _Alloc >::empty(), and m_algorithms.

00183 { return m_algorithms.empty() ? 0 : m_algorithms.back() ; }

virtual const IAlgContextSvc::Algorithms& AlgContextSvc::algorithms (  )  const [inline, virtual]

get the stack of executed algorithms

See also:
IAlgContextSvc

Implements IAlgContextSvc.

Definition at line 57 of file AlgContextSvc.h.

References m_algorithms.

00058   { return m_algorithms ; }

StatusCode AlgContextSvc::queryInterface ( const InterfaceID riid,
void **  ppvi 
) [virtual]

Gaudi_cast,.

See also:
IInterface

< increment the reference count!

Reimplemented from Service.

Definition at line 61 of file AlgContextSvc.cpp.

References StatusCode::FAILURE, IIncidentListener::interfaceID(), IAlgContextSvc::interfaceID(), Service::queryInterface(), and StatusCode::SUCCESS.

00063 {
00064   if      ( 0 == ppvi ) { return StatusCode::FAILURE   ; }         // RETURN 
00065   else if ( IAlgContextSvc    ::interfaceID() == riid )    
00066   { *ppvi = static_cast<IAlgContextSvc*>    ( this ) ; }
00067   else if ( IIncidentListener ::interfaceID() == riid )    
00068   { *ppvi = static_cast<IIncidentListener*> ( this ) ; }
00069   else { return Service::queryInterface ( riid , ppvi ) ; }         // RETURN 
00070   // increment the reference count!
00071   addRef();                          
00072   return StatusCode::SUCCESS ;
00073 }

void AlgContextSvc::handle ( const Incident  )  [virtual]

handle incident

See also:
IIncidentListener

Implements IIncidentListener.

Definition at line 187 of file AlgContextSvc.cpp.

References std::vector< _Tp, _Alloc >::empty(), endreq(), MSG::ERROR, m_algorithms, Service::msgSvc(), Service::name(), and std::vector< _Tp, _Alloc >::size().

00188 {
00189   if ( !m_algorithms.empty() )
00190   {
00191     MsgStream log ( msgSvc() , name() ) ;
00192     log << MSG::ERROR
00193         << "Non-empty stack of algorihtms #"
00194         << m_algorithms.size() << endreq ;
00195   }
00196 }

StatusCode AlgContextSvc::initialize (  )  [virtual]

standard initialization of the service

See also:
IService

Reimplemented from Service.

Definition at line 77 of file AlgContextSvc.cpp.

References IncidentType::BeginEvent, std::vector< _Tp, _Alloc >::empty(), IncidentType::EndEvent, endreq(), MSG::ERROR, StatusCode::FAILURE, Service::initialize(), StatusCode::isFailure(), m_algorithms, m_check, m_inc, Service::msgSvc(), Service::name(), Service::release(), Service::service(), std::vector< _Tp, _Alloc >::size(), StatusCode::SUCCESS, and MSG::WARNING.

00078 {
00079   // intialize the base class 
00080   StatusCode sc = Service::initialize () ;
00081   if ( sc.isFailure () ) { return sc ; }
00082   // Incindent Service 
00083   if ( 0 != m_inc     ) 
00084   {
00085     m_inc -> removeListener ( this ) ;
00086     m_inc -> release() ;
00087     m_inc = 0 ;
00088   }
00089   // perform more checks?
00090   if ( m_check ) 
00091   { 
00092     sc = Service::service ( "IncidentSvc" , m_inc , true ) ;
00093     if ( sc.isFailure() )
00094     {
00095       MsgStream log ( msgSvc() , name() )  ;
00096       log << MSG::ERROR << "Could not locate 'IncidentSvc'" << sc << endreq ;
00097       return sc ;                                               // RETURN
00098     }
00099     if ( 0 == m_inc ) 
00100     {
00101       MsgStream log ( msgSvc() , name() ) ;
00102       log << MSG::ERROR << "Invalid pointer to IIncindentSvc" << endreq ;
00103       return StatusCode::FAILURE ;                               // RETURN 
00104     }    
00105     m_inc -> addListener ( this , IncidentType::BeginEvent ) ;
00106     m_inc -> addListener ( this , IncidentType::EndEvent   ) ;
00107   }  
00108   if ( !m_algorithms.empty() )
00109   {
00110     MsgStream log ( msgSvc() , name() ) ;
00111     log << MSG::WARNING
00112         << "Non-empty stack of algorihtms #"
00113         << m_algorithms.size() << endreq ;
00114   }
00115   return StatusCode::SUCCESS ;
00116 }

StatusCode AlgContextSvc::finalize (  )  [virtual]

standard finalization of the service

See also:
IService

Reimplemented from Service.

Definition at line 120 of file AlgContextSvc.cpp.

References std::vector< _Tp, _Alloc >::empty(), endreq(), Service::finalize(), m_algorithms, m_inc, Service::msgSvc(), Service::name(), Service::release(), std::vector< _Tp, _Alloc >::size(), and MSG::WARNING.

00121 {
00122   if ( !m_algorithms.empty() )
00123   {
00124     MsgStream log ( msgSvc() , name() ) ;
00125     log << MSG::WARNING
00126         << "Non-empty stack of algorihtms #"
00127         << m_algorithms.size() << endreq ;
00128   }
00129   // Incindent Service 
00130   if ( 0 != m_inc     ) 
00131   {
00132     m_inc -> removeListener ( this ) ;
00133     m_inc -> release() ;
00134     m_inc = 0 ;
00135   }
00136   // finalize the base class 
00137   return Service::finalize () ;
00138 }

AlgContextSvc& AlgContextSvc::operator= ( const AlgContextSvc  )  [private]

no assignement


Friends And Related Function Documentation

friend class SvcFactory< AlgContextSvc > [friend]

friend factory for instantiations

Definition at line 48 of file AlgContextSvc.h.


Member Data Documentation

IAlgContextSvc::Algorithms AlgContextSvc::m_algorithms [private]

the stack of currect algorithms

Definition at line 88 of file AlgContextSvc.h.

Referenced by algorithms(), currentAlg(), finalize(), handle(), initialize(), setCurrentAlg(), and unSetCurrentAlg().

IIncidentSvc* AlgContextSvc::m_inc [private]

pointer to Incident Service

Definition at line 90 of file AlgContextSvc.h.

Referenced by finalize(), and initialize().

bool AlgContextSvc::m_check [private]

Definition at line 92 of file AlgContextSvc.h.

Referenced by initialize().


The documentation for this class was generated from the following files:
Generated at Fri Jul 18 12:06:42 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004