Gaudi Framework, version v25r1

Home   Generated: Mon Mar 24 2014
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Gaudi::Guards::AuditorGuard Class Reference

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:
Collaboration graph
[legend]

Public Member Functions

 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::StandardEventType evt)
 constructor
 
 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::CustomEventTypeRef evt)
 constructor
 
 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::StandardEventType evt, const StatusCode &sc)
 constructor
 
 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::CustomEventTypeRef evt, const StatusCode &sc)
 constructor
 
 AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::StandardEventType evt)
 constructor
 
 AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::CustomEventTypeRef evt)
 constructor
 
 AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::StandardEventType evt, const StatusCode &sc)
 constructor
 
 AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::CustomEventTypeRef evt, const StatusCode &sc)
 constructor
 
 ~AuditorGuard ()
 dectructor
 
const StatusCodecode () const
 

Private Member Functions

 AuditorGuard ()
 the default constructor is disabled
 
 AuditorGuard (const AuditorGuard &right)
 no copy
 
AuditorGuardoperator= (const AuditorGuard &right)
 no assignement
 
void i_before ()
 
void i_after ()
 

Private Attributes

INamedInterfacem_obj
 the guarded object
 
std::string m_objName
 the guarded object name (if there is no INamedInterface)
 
IAuditorm_svc
 auditor service
 
IAuditor::StandardEventType m_evt
 Event type (standard events)
 
IAuditor::CustomEventType m_cevt
 Event type (custom events)
 
const StatusCodem_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.
 
bool m_customEvtType
 Flag to remember which event type was used.
 

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 ;
}
{
AuditorGuard auditor ( this ,
auditSvc() ,
...
StatusCode sc = ... ;
...
auditor.setCode ( sc ) ;
...
return sc ;
}
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 218 of file Guards.h.

Constructor & Destructor Documentation

Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::StandardEventType  evt 
)

constructor

Definition at line 65 of file Guards.cpp.

:
m_obj(obj),
m_svc(svc),
m_cevt(),
m_sc(0),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt 
)

constructor

Definition at line 78 of file Guards.cpp.

:
m_obj(obj),
m_svc(svc),
m_evt(IAuditor::Initialize), // Windows needs an explicit value
m_sc(0),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::StandardEventType  evt,
const StatusCode sc 
)

constructor

Definition at line 91 of file Guards.cpp.

:
m_obj(obj),
m_svc(svc),
m_cevt(),
m_sc(&sc),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt,
const StatusCode sc 
)

constructor

Definition at line 105 of file Guards.cpp.

:
m_obj(obj),
m_svc(svc),
m_evt(IAuditor::Initialize), // Windows needs an explicit value
m_sc(&sc),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::StandardEventType  evt 
)

constructor

Definition at line 119 of file Guards.cpp.

:
m_obj(0),
m_objName(name),
m_svc(svc),
m_cevt(),
m_sc(0),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt 
)

constructor

Definition at line 132 of file Guards.cpp.

:
m_obj(0),
m_objName(name),
m_svc(svc),
m_evt(IAuditor::Initialize), // Windows needs an explicit value
m_sc(0),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::StandardEventType  evt,
const StatusCode sc 
)

constructor

Definition at line 145 of file Guards.cpp.

:
m_obj(0),
m_objName(name),
m_svc(svc),
m_cevt(),
m_sc(&sc),
{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt,
const StatusCode sc 
)

constructor

Definition at line 159 of file Guards.cpp.

:
m_obj(0),
m_objName(name),
m_svc(svc),
m_evt(IAuditor::Initialize), // Windows needs an explicit value
m_sc(&sc),
{
}
Gaudi::Guards::AuditorGuard::~AuditorGuard ( )

dectructor

Definition at line 176 of file Guards.cpp.

{
}
Gaudi::Guards::AuditorGuard::AuditorGuard ( )
private

the default constructor is disabled

Gaudi::Guards::AuditorGuard::AuditorGuard ( const AuditorGuard right)
private

no copy

Member Function Documentation

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

Definition at line 264 of file Guards.h.

{ return *m_sc ; }
void Gaudi::Guards::AuditorGuard::i_after ( )
inlineprivate

Definition at line 309 of file Guards.h.

{
if ( 0 != m_svc ) { // if the service is not available, we cannot do anything
if (0 != m_obj) {
if (m_customEvtType) {
if (0 != m_sc) {
m_svc->after(m_cevt,m_obj,*m_sc);
} else {
m_svc->after(m_cevt,m_obj);
}
} else {
if (0 != m_sc) {
m_svc->after(m_evt,m_obj,*m_sc);
} else {
m_svc->after(m_evt,m_obj);
}
}
} else { // use object name
if (m_customEvtType) {
if (0 != m_sc) {
m_svc->after(m_cevt,m_objName,*m_sc);
} else {
m_svc->after(m_cevt,m_objName);
}
} else {
if (0 != m_sc) {
m_svc->after(m_evt,m_objName,*m_sc);
} else {
m_svc->after(m_evt,m_objName);
}
}
}
m_svc->release(); // we do not need the service anymore
m_svc = 0 ;
}
}
void Gaudi::Guards::AuditorGuard::i_before ( )
inlineprivate

Definition at line 290 of file Guards.h.

{
if ( 0 != m_svc ) { // if the service is not available, we cannot do anything
m_svc->addRef(); // increase the reference counting
if (0 != m_obj) {
if (m_customEvtType) {
m_svc->before(m_cevt,m_obj);
} else {
m_svc->before(m_evt,m_obj);
}
} else { // use object name
if (m_customEvtType) {
m_svc->before(m_cevt,m_objName);
} else {
m_svc->before(m_evt,m_objName);
}
}
}
}
AuditorGuard& Gaudi::Guards::AuditorGuard::operator= ( const AuditorGuard right)
private

no assignement

Member Data Documentation

IAuditor::CustomEventType Gaudi::Guards::AuditorGuard::m_cevt
private

Event type (custom events)

Definition at line 282 of file Guards.h.

bool Gaudi::Guards::AuditorGuard::m_customEvtType
private

Flag to remember which event type was used.

Definition at line 288 of file Guards.h.

IAuditor::StandardEventType Gaudi::Guards::AuditorGuard::m_evt
private

Event type (standard events)

Definition at line 280 of file Guards.h.

INamedInterface* Gaudi::Guards::AuditorGuard::m_obj
private

the guarded object

Definition at line 274 of file Guards.h.

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

the guarded object name (if there is no INamedInterface)

Definition at line 276 of file Guards.h.

const StatusCode* 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 286 of file Guards.h.

IAuditor* Gaudi::Guards::AuditorGuard::m_svc
private

auditor service

Definition at line 278 of file Guards.h.


The documentation for this class was generated from the following files:
Generated at Mon Mar 24 2014 18:27:52 for Gaudi Framework, version v25r1 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004