| # Gaudi Framework, version v21r8 |

Home |  | Generated: 17 Mar 2010

# AlgContextSvc Class Reference

`#include <AlgContextSvc.h>`

Inheritance diagram for AlgContextSvc:

[legend]
Collaboration diagram for AlgContextSvc:

[legend]

List of all members.

## 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 IAlgorithm * | currentAlg () const
| accessor to current algorithm:
virtual const IAlgContextSvc::Algorithms & | algorithms () const
| get the stack of executed algorithms
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
AlgContextSvc & | operator= (const AlgContextSvc &)
| no assignment
## Private Attributes
IAlgContextSvc::Algorithms | m_algorithms
| the stack of current algorithms
IIncidentSvc * | m_inc
| pointer to Incident Service
bool | m_check
## Friends
class | SvcFactory< AlgContextSvc >
| friend factory for instantiations

## Detailed Description

Definition at line 28 of file AlgContextSvc.h.

## Constructor & Destructor Documentation

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

Standard Constructor.

Instantiation of a static factory class used by clients to create instances of this service.

See also:
  Service

Definition at line 31 of file AlgContextSvc.cpp.

    00033   : base_class ( name , svc  )
    00034   , m_algorithms (  0   )
    00035   , m_inc        (  0   )
    00036   , m_check      ( true )
    00037 {
    00038   declareProperty ( "Check" , m_check , "Flag to perform more checks" );
    00039 }

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

Standard Destructor.

Definition at line 43 of file AlgContextSvc.cpp.

    00043 {}

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

Definition at line 112 of file AlgContextSvc.cpp.

    00113 {
    00114   if ( 0 == a )
    00115   {
    00116     MsgStream log ( msgSvc() , name() ) ;
    00117     log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
    00118     //
    00119     return StatusCode::RECOVERABLE ;                              // RETURN
    00120   }
    00121   m_algorithms.push_back ( a ) ;
    00122   //
    00123   return StatusCode::SUCCESS ;                                    // RETURN
    00124 }

StatusCode AlgContextSvc::unSetCurrentAlg | ( | IAlgorithm * | a | ) | `[virtual]`

remove the algorithm ("pop_back")

See also:
  IAlgContextSvc

Definition at line 128 of file AlgContextSvc.cpp.

    00129 {
    00130   if ( 0 == a )
    00131   {
    00132     MsgStream log ( msgSvc() , name() ) ;
    00133     log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
    00134     //
    00135     return StatusCode::RECOVERABLE ;                              // RETURN
    00136   }
    00137   if ( m_algorithms.empty() || m_algorithms.back() != a )
    00138   {
    00139     MsgStream log ( msgSvc() , name() ) ;
    00140     log << MSG::ERROR << "Algorithm stack is invalid" << endmsg ;
    00141     //
    00142     return StatusCode::FAILURE ;
    00143   }
    00144   //
    00145   m_algorithms.pop_back() ;                                      // POP_BACK
    00146   //
    00147   return StatusCode::SUCCESS ;
    00148 }

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

accessor to current algorithm:

See also:
  IAlgContextSvc

Definition at line 152 of file AlgContextSvc.cpp.

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

Definition at line 41 of file AlgContextSvc.h.

    00042   { return m_algorithms ; }

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

handle incident

See also:
  IIncidentListener

Definition at line 157 of file AlgContextSvc.cpp.

    00158 {
    00159   if ( !m_algorithms.empty() )
    00160   {
    00161     MsgStream log ( msgSvc() , name() ) ;
    00162     log << MSG::ERROR
    00163         << "Non-empty stack of algorithms #"
    00164         << m_algorithms.size() << endmsg ;
    00165   }
    00166 }

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

standard initialization of the service

See also:
  IService

Reimplemented from Service.

Definition at line 47 of file AlgContextSvc.cpp.

    00048 {
    00049   // Initialize the base class
    00050   StatusCode sc = Service::initialize () ;
    00051   if ( sc.isFailure () ) { return sc ; }
    00052   // Incident Service
    00053   if ( 0 != m_inc     )
    00054   {
    00055     m_inc -> removeListener ( this ) ;
    00056     m_inc -> release() ;
    00057     m_inc = 0 ;
    00058   }
    00059   // perform more checks?
    00060   if ( m_check )
    00061   {
    00062     sc = Service::service ( "IncidentSvc" , m_inc , true ) ;
    00063     if ( sc.isFailure() )
    00064     {
    00065       MsgStream log ( msgSvc() , name() )  ;
    00066       log << MSG::ERROR << "Could not locate 'IncidentSvc'" << sc << endmsg ;
    00067       return sc ;                                               // RETURN
    00068     }
    00069     if ( 0 == m_inc )
    00070     {
    00071       MsgStream log ( msgSvc() , name() ) ;
    00072       log << MSG::ERROR << "Invalid pointer to IIncindentSvc" << endmsg ;
    00073       return StatusCode::FAILURE ;                               // RETURN
    00074     }
    00075     m_inc -> addListener ( this , IncidentType::BeginEvent ) ;
    00076     m_inc -> addListener ( this , IncidentType::EndEvent   ) ;
    00077   }
    00078   if ( !m_algorithms.empty() )
    00079   {
    00080     MsgStream log ( msgSvc() , name() ) ;
    00081     log << MSG::WARNING
    00082         << "Non-empty stack of algorithms #"
    00083         << m_algorithms.size() << endmsg ;
    00084   }
    00085   return StatusCode::SUCCESS ;
    00086 }

StatusCode AlgContextSvc::finalize | ( | void |  | ) | `[virtual]`

standard finalization of the service

See also:
  IService

Reimplemented from Service.

Definition at line 90 of file AlgContextSvc.cpp.

    00091 {
    00092   if ( !m_algorithms.empty() )
    00093   {
    00094     MsgStream log ( msgSvc() , name() ) ;
    00095     log << MSG::WARNING
    00096         << "Non-empty stack of algorithms #"
    00097         << m_algorithms.size() << endmsg ;
    00098   }
    00099   // Incident Service
    00100   if ( 0 != m_inc     )
    00101   {
    00102     m_inc -> removeListener ( this ) ;
    00103     m_inc -> release() ;
    00104     m_inc = 0 ;
    00105   }
    00106   // finalize the base class
    00107   return Service::finalize () ;
    00108 }

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

no assignment

## Friends And Related Function Documentation

friend class SvcFactory< AlgContextSvc >`[friend]`

friend factory for instantiations

Definition at line 32 of file AlgContextSvc.h.

## Member Data Documentation

IAlgContextSvc::Algorithms AlgContextSvc::m_algorithms`[private]`

the stack of current algorithms

Definition at line 67 of file AlgContextSvc.h.

IIncidentSvc* AlgContextSvc::m_inc`[private]`

pointer to Incident Service

Definition at line 69 of file AlgContextSvc.h.

bool AlgContextSvc::m_check`[private]`

Definition at line 71 of file AlgContextSvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiSvc/src/AlgContextSvc/AlgContextSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r8/GaudiSvc/src/AlgContextSvc/AlgContextSvc.cpp