Gaudi Framework, version v23r0

Home   Generated: Mon Jan 30 2012
Public Member Functions | Private Member Functions | Private Attributes | Friends

AlgContextSvc Class Reference

#include <AlgContextSvc.h>

Inheritance diagram for AlgContextSvc:
Inheritance graph
[legend]
Collaboration diagram for AlgContextSvc:
Collaboration graph
[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 IAlgorithmcurrentAlg () 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
AlgContextSvcoperator= (const AlgContextSvc &)
 no assignment

Private Attributes

IAlgContextSvc::Algorithms m_algorithms
 the stack of current algorithms
IIncidentSvcm_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.

  : base_class ( name , svc  )
  , m_algorithms (  0   )
  , m_inc        (  0   )
  , m_check      ( true )
{
  declareProperty ( "Check" , m_check , "Flag to perform more checks" );
}
AlgContextSvc::~AlgContextSvc (  ) [virtual]

Standard Destructor.

Definition at line 43 of file AlgContextSvc.cpp.

{}
AlgContextSvc::AlgContextSvc (  ) [private]

no default constructor

AlgContextSvc::AlgContextSvc ( const AlgContextSvc  ) [private]

no copy constructor


Member Function Documentation

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.

  { return m_algorithms ; }
IAlgorithm * AlgContextSvc::currentAlg (  ) const [virtual]

accessor to current algorithm:

See also:
IAlgContextSvc

Definition at line 152 of file AlgContextSvc.cpp.

{ return m_algorithms.empty() ? 0 : m_algorithms.back() ; }
StatusCode AlgContextSvc::finalize (  ) [virtual]

standard finalization of the service

See also:
IService

Reimplemented from Service.

Definition at line 90 of file AlgContextSvc.cpp.

{
  if ( !m_algorithms.empty() )
  {
    MsgStream log ( msgSvc() , name() ) ;
    log << MSG::WARNING
        << "Non-empty stack of algorithms #"
        << m_algorithms.size() << endmsg ;
  }
  // Incident Service
  if ( 0 != m_inc     )
  {
    m_inc -> removeListener ( this ) ;
    m_inc -> release() ;
    m_inc = 0 ;
  }
  // finalize the base class
  return Service::finalize () ;
}
void AlgContextSvc::handle ( const Incident  ) [virtual]

handle incident

See also:
IIncidentListener

Definition at line 157 of file AlgContextSvc.cpp.

{
  if ( !m_algorithms.empty() )
  {
    MsgStream log ( msgSvc() , name() ) ;
    log << MSG::ERROR
        << "Non-empty stack of algorithms #"
        << m_algorithms.size() << endmsg ;
  }
}
StatusCode AlgContextSvc::initialize (  ) [virtual]

standard initialization of the service

See also:
IService

Reimplemented from Service.

Definition at line 47 of file AlgContextSvc.cpp.

{
  // Initialize the base class
  StatusCode sc = Service::initialize () ;
  if ( sc.isFailure () ) { return sc ; }
  // Incident Service
  if ( 0 != m_inc     )
  {
    m_inc -> removeListener ( this ) ;
    m_inc -> release() ;
    m_inc = 0 ;
  }
  // perform more checks?
  if ( m_check )
  {
    sc = Service::service ( "IncidentSvc" , m_inc , true ) ;
    if ( sc.isFailure() )
    {
      MsgStream log ( msgSvc() , name() )  ;
      log << MSG::ERROR << "Could not locate 'IncidentSvc'" << sc << endmsg ;
      return sc ;                                               // RETURN
    }
    if ( 0 == m_inc )
    {
      MsgStream log ( msgSvc() , name() ) ;
      log << MSG::ERROR << "Invalid pointer to IIncindentSvc" << endmsg ;
      return StatusCode::FAILURE ;                               // RETURN
    }
    m_inc -> addListener ( this , IncidentType::BeginEvent ) ;
    m_inc -> addListener ( this , IncidentType::EndEvent   ) ;
  }
  if ( !m_algorithms.empty() )
  {
    MsgStream log ( msgSvc() , name() ) ;
    log << MSG::WARNING
        << "Non-empty stack of algorithms #"
        << m_algorithms.size() << endmsg ;
  }
  return StatusCode::SUCCESS ;
}
AlgContextSvc& AlgContextSvc::operator= ( const AlgContextSvc  ) [private]

no assignment

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

set the currently executing algorithm ("push_back")

See also:
IAlgContextSvc

Definition at line 112 of file AlgContextSvc.cpp.

{
  if ( 0 == a )
  {
    MsgStream log ( msgSvc() , name() ) ;
    log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
    //
    return StatusCode::RECOVERABLE ;                              // RETURN
  }
  m_algorithms.push_back ( a ) ;
  //
  return StatusCode::SUCCESS ;                                    // RETURN
}
StatusCode AlgContextSvc::unSetCurrentAlg ( IAlgorithm a ) [virtual]

remove the algorithm ("pop_back")

See also:
IAlgContextSvc

Definition at line 128 of file AlgContextSvc.cpp.

{
  if ( 0 == a )
  {
    MsgStream log ( msgSvc() , name() ) ;
    log << MSG::WARNING << "IAlgorithm* points to NULL" << endmsg ;
    //
    return StatusCode::RECOVERABLE ;                              // RETURN
  }
  if ( m_algorithms.empty() || m_algorithms.back() != a )
  {
    MsgStream log ( msgSvc() , name() ) ;
    log << MSG::ERROR << "Algorithm stack is invalid" << endmsg ;
    //
    return StatusCode::FAILURE ;
  }
  //
  m_algorithms.pop_back() ;                                      // POP_BACK
  //
  return StatusCode::SUCCESS ;
}

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

the stack of current algorithms

Definition at line 67 of file AlgContextSvc.h.

bool AlgContextSvc::m_check [private]

Definition at line 71 of file AlgContextSvc.h.

pointer to Incident Service

Definition at line 69 of file AlgContextSvc.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 Mon Jan 30 2012 13:53:09 for Gaudi Framework, version v23r0 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004