The Gaudi Framework  master (b9786168)
Loading...
Searching...
No Matches
Gaudi::Guards::AuditorGuard Class Referencefinal

It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way. More...

#include <GaudiKernel/Guards.h>

Collaboration diagram for Gaudi::Guards::AuditorGuard:

Public Member Functions

 AuditorGuard (std::string name, IAuditor *svc, std::string const &evt, EventContext const &context={})
 
 AuditorGuard (std::string name, IAuditor *svc, std::string const &evt, StatusCode const &sc, EventContext const &context={})
 
 ~AuditorGuard ()
 
const StatusCode code () const
 

Private Member Functions

 AuditorGuard (const AuditorGuard &right)=delete
 
AuditorGuardoperator= (const AuditorGuard &right)=delete
 
void i_before ()
 
void i_after ()
 

Private Attributes

std::string m_objName
 the guarded object name (if there is no INamedInterface)
 
SmartIF< IAuditorm_svc = nullptr
 auditor service
 
std::string const m_evt
 Event type.
 
StatusCode const * m_sc {}
 Pointer to a status code instance, to be passed to the "after" function if needed The instance must have a scope larger than the one of the guard.
 
const EventContextm_context
 Pointer to a EventContext instance, to be passed to the "before" and "after" function If given, the instance must have a scope larger than the one of the guard.
 

Detailed Description

It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way.

The pattern ensures that "post-action" will be always executed

{
AuditorGuard auditor ( this ,
auditSvc() ,
...
StatusCode sc = ... ;
...
return sc ;
}
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition Algorithm.cpp:53
AuditorGuard(std::string name, IAuditor *svc, std::string const &evt, EventContext const &context={})
Definition Guards.cpp:42
static const std::string Initialize
Definition IAuditor.h:47
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
{
AuditorGuard auditor ( this ,
auditSvc() ,
IAuditor::execute ) ;
...
StatusCode sc = ... ;
...
auditor.setCode ( sc ) ;
...
return sc ;
}
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-03-07

Definition at line 202 of file Guards.h.

Constructor & Destructor Documentation

◆ AuditorGuard() [1/3]

Gaudi::Guards::AuditorGuard::AuditorGuard ( std::string name,
IAuditor * svc,
std::string const & evt,
EventContext const & context = {} )

Definition at line 42 of file Guards.cpp.

44 : m_objName( name ), m_svc( svc ), m_evt( evt ), m_context( context ) {
45 i_before();
46}
std::string const m_evt
Event type.
Definition Guards.h:226
SmartIF< IAuditor > m_svc
auditor service
Definition Guards.h:224
const EventContext & m_context
Pointer to a EventContext instance, to be passed to the "before" and "after" function If given,...
Definition Guards.h:234
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition Guards.h:222

◆ AuditorGuard() [2/3]

Gaudi::Guards::AuditorGuard::AuditorGuard ( std::string name,
IAuditor * svc,
std::string const & evt,
StatusCode const & sc,
EventContext const & context = {} )

Definition at line 48 of file Guards.cpp.

50 : m_objName( name ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_context( context ) {
51 i_before();
52}
StatusCode const * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition Guards.h:230

◆ ~AuditorGuard()

Gaudi::Guards::AuditorGuard::~AuditorGuard ( )
inline

Definition at line 209 of file Guards.h.

◆ AuditorGuard() [3/3]

Gaudi::Guards::AuditorGuard::AuditorGuard ( const AuditorGuard & right)
privatedelete

Member Function Documentation

◆ code()

const StatusCode Gaudi::Guards::AuditorGuard::code ( ) const
inline

Definition at line 213 of file Guards.h.

◆ i_after()

void Gaudi::Guards::AuditorGuard::i_after ( )
inlineprivate

Definition at line 242 of file Guards.h.

243 {
244 if ( m_svc ) { // if the service is not available, we cannot do anything
245 if ( m_sc ) {
246 m_svc->after( m_evt, m_objName, m_context, *m_sc );
247 } else {
248 m_svc->after( m_evt, m_objName, m_context );
249 }
250 m_svc.reset();
251 }

◆ i_before()

void Gaudi::Guards::AuditorGuard::i_before ( )
inlineprivate

Definition at line 236 of file Guards.h.

237 {
238 if ( m_svc ) { // if the service is not available, we cannot do anything
239 m_svc->before( m_evt, m_objName, m_context );
240 }

◆ operator=()

AuditorGuard & Gaudi::Guards::AuditorGuard::operator= ( const AuditorGuard & right)
privatedelete

Member Data Documentation

◆ m_context

const EventContext& Gaudi::Guards::AuditorGuard::m_context
private

Pointer to a EventContext instance, to be passed to the "before" and "after" function If given, the instance must have a scope larger than the one of the guard.

No check is performed.

Definition at line 234 of file Guards.h.

◆ m_evt

std::string const Gaudi::Guards::AuditorGuard::m_evt
private

Event type.

Definition at line 226 of file Guards.h.

◆ m_objName

std::string Gaudi::Guards::AuditorGuard::m_objName
private

the guarded object name (if there is no INamedInterface)

Definition at line 222 of file Guards.h.

◆ m_sc

StatusCode const* Gaudi::Guards::AuditorGuard::m_sc {}
private

Pointer to a status code instance, to be passed to the "after" function if needed The instance must have a scope larger than the one of the guard.

No check is performed.

Definition at line 230 of file Guards.h.

◆ m_svc

SmartIF<IAuditor> Gaudi::Guards::AuditorGuard::m_svc = nullptr
private

auditor service

Definition at line 224 of file Guards.h.


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