The Gaudi Framework  v30r4 (9b837755)
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 (INamedInterface *obj, IAuditor *svc, IAuditor::StandardEventType evt)
 constructor More...
 
 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::CustomEventTypeRef evt)
 constructor More...
 
 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::StandardEventType evt, const StatusCode &sc)
 constructor More...
 
 AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::CustomEventTypeRef evt, const StatusCode &sc)
 constructor More...
 
 AuditorGuard (std::string name, IAuditor *svc, IAuditor::StandardEventType evt)
 constructor More...
 
 AuditorGuard (std::string name, IAuditor *svc, IAuditor::CustomEventTypeRef evt)
 constructor More...
 
 AuditorGuard (std::string name, IAuditor *svc, IAuditor::StandardEventType evt, const StatusCode &sc)
 constructor More...
 
 AuditorGuard (std::string name, IAuditor *svc, IAuditor::CustomEventTypeRef evt, const StatusCode &sc)
 constructor More...
 
 ~AuditorGuard ()
 dectructor More...
 
const StatusCodecode () const
 

Private Member Functions

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

Private Attributes

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

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 215 of file Guards.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 58 of file Guards.cpp.

59  : m_obj( obj ), m_svc( svc ), m_evt( evt )
60 {
61  i_before();
62 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
evt
Definition: IOTest.py:96
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt 
)

constructor

Definition at line 63 of file Guards.cpp.

64  : m_obj( obj )
65  , m_svc( svc )
67  , // Windows needs an explicit value
68  m_cevt( std::move( evt ) )
69  , m_customEvtType( true )
70 {
71  i_before();
72 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
T move(T...args)
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::StandardEventType  evt,
const StatusCode sc 
)

constructor

Definition at line 73 of file Guards.cpp.

75  : m_obj( obj ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false )
76 {
77  i_before();
78 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
const StatusCode * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition: Guards.h:264
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
evt
Definition: IOTest.py:96
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt,
const StatusCode sc 
)

constructor

Definition at line 79 of file Guards.cpp.

81  : m_obj( obj )
82  , m_svc( svc )
84  , // Windows needs an explicit value
85  m_cevt( std::move( evt ) )
86  , m_sc( &sc )
87  , m_customEvtType( true )
88 {
89  i_before();
90 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
T move(T...args)
const StatusCode * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition: Guards.h:264
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
Gaudi::Guards::AuditorGuard::AuditorGuard ( std::string  name,
IAuditor svc,
IAuditor::StandardEventType  evt 
)

constructor

Definition at line 91 of file Guards.cpp.

92  : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_customEvtType( false )
93 {
94  i_before();
95 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
evt
Definition: IOTest.py:96
Gaudi::Guards::AuditorGuard::AuditorGuard ( std::string  name,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt 
)

constructor

Definition at line 96 of file Guards.cpp.

97  : m_objName( std::move( name ) )
98  , m_svc( svc )
100  , // Windows needs an explicit value
101  m_cevt( std::move( evt ) )
102  , m_customEvtType( true )
103 {
104  i_before();
105 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
Gaudi::Guards::AuditorGuard::AuditorGuard ( std::string  name,
IAuditor svc,
IAuditor::StandardEventType  evt,
const StatusCode sc 
)

constructor

Definition at line 106 of file Guards.cpp.

108  : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false )
109 {
110  i_before();
111 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
const StatusCode * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition: Guards.h:264
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
evt
Definition: IOTest.py:96
Gaudi::Guards::AuditorGuard::AuditorGuard ( std::string  name,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt,
const StatusCode sc 
)

constructor

Definition at line 112 of file Guards.cpp.

114  : m_objName( std::move( name ) )
115  , m_svc( svc )
117  , // Windows needs an explicit value
118  m_cevt( std::move( evt ) )
119  , m_sc( &sc )
120  , m_customEvtType( true )
121 {
122  i_before();
123 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
const StatusCode * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition: Guards.h:264
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
Gaudi::Guards::AuditorGuard::~AuditorGuard ( )

dectructor

Definition at line 127 of file Guards.cpp.

127 { i_after(); }
Gaudi::Guards::AuditorGuard::AuditorGuard ( )
privatedelete
Gaudi::Guards::AuditorGuard::AuditorGuard ( const AuditorGuard right)
privatedelete

Member Function Documentation

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

Definition at line 242 of file Guards.h.

242 { return *m_sc; }
const StatusCode * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition: Guards.h:264
void Gaudi::Guards::AuditorGuard::i_after ( )
inlineprivate

Definition at line 287 of file Guards.h.

288  {
289  if ( m_svc ) { // if the service is not available, we cannot do anything
290  if ( m_obj ) {
291  if ( m_customEvtType ) {
292  if ( m_sc ) {
293  m_svc->after( m_cevt, m_obj, *m_sc );
294  } else {
295  m_svc->after( m_cevt, m_obj );
296  }
297  } else {
298  if ( m_sc ) {
299  m_svc->after( m_evt, m_obj, *m_sc );
300  } else {
301  m_svc->after( m_evt, m_obj );
302  }
303  }
304  } else { // use object name
305  if ( m_customEvtType ) {
306  if ( m_sc ) {
308  } else {
310  }
311  } else {
312  if ( m_sc ) {
313  m_svc->after( m_evt, m_objName, *m_sc );
314  } else {
315  m_svc->after( m_evt, m_objName );
316  }
317  }
318  }
319  m_svc.reset();
320  }
321  }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
virtual void after(StandardEventType, INamedInterface *, const StatusCode &sc=StatusCode(StatusCode::SUCCESS, true))=0
Audit the end of a standard "event".
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
const StatusCode * m_sc
Pointer to a status code instance, to be passed to the "after" function if needed The instance must h...
Definition: Guards.h:264
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
void Gaudi::Guards::AuditorGuard::i_before ( )
inlineprivate

Definition at line 268 of file Guards.h.

269  {
270  if ( m_svc ) { // if the service is not available, we cannot do anything
271  if ( m_obj ) {
272  if ( m_customEvtType ) {
273  m_svc->before( m_cevt, m_obj );
274  } else {
275  m_svc->before( m_evt, m_obj );
276  }
277  } else { // use object name
278  if ( m_customEvtType ) {
280  } else {
282  }
283  }
284  }
285  }
virtual void before(StandardEventType, INamedInterface *)=0
Audit the start of a standard "event".
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
AuditorGuard& Gaudi::Guards::AuditorGuard::operator= ( const AuditorGuard right)
privatedelete

Member Data Documentation

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

Event type (custom events)

Definition at line 260 of file Guards.h.

bool Gaudi::Guards::AuditorGuard::m_customEvtType = false
private

Flag to remember which event type was used.

Definition at line 266 of file Guards.h.

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

Event type (standard events)

Definition at line 258 of file Guards.h.

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

the guarded object

Definition at line 252 of file Guards.h.

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

the guarded object name (if there is no INamedInterface)

Definition at line 254 of file Guards.h.

const StatusCode* Gaudi::Guards::AuditorGuard::m_sc = nullptr
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 264 of file Guards.h.

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

auditor service

Definition at line 256 of file Guards.h.


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