| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Member Functions | Private Member Functions | Private Attributes | List of all members
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:
[legend]

## 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 StatusCode & | code () const

## Private Member Functions
| AuditorGuard ()=delete
| AuditorGuard (const AuditorGuard &right)=delete
AuditorGuard & | operator= (const AuditorGuard &right)=delete
void | i_before ()
void | i_after ()

## Private Attributes
INamedInterface * | m_obj = nullptr
| the guarded object More...
std::string | m_objName
| the guarded object name (if there is no INamedInterface) More...
SmartIF< IAuditor > | m_svc = nullptr
| auditor service More...
IAuditor::StandardEventType | m_evt
| Event type (standard events) More...
IAuditor::CustomEventType | m_cevt
| Event type (custom events) More...
const StatusCode * | m_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

StatusCode Algorithm::sysInitialize ()
{
AuditorGuard auditor ( this ,
auditSvc() ,
IAuditor::Initialize ) ;
...
StatusCode sc = ... ;
...
return sc ;
}
StatusCode Algorithm::sysExecute ()
{
AuditorGuard auditor ( this ,
auditSvc() ,
IAuditor::execute ) ;
...
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
IOTest.evt
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 )
66 , m_evt( IAuditor::Initialize )
67 , // Windows needs an explicit value
68 m_cevt( std::move( evt ) )
69 , m_customEvtType( true )
70 {
71 i_before();
72 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
std::move
T move(T...args)
IAuditor::Initialize
Definition: IAuditor.h:25
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::m_customEvtType
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::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
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
IOTest.evt
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 )
83 , m_evt( IAuditor::Initialize )
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
std::move
T move(T...args)
IAuditor::Initialize
Definition: IAuditor.h:25
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::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
Gaudi::Guards::AuditorGuard::m_customEvtType
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
std::move
T move(T...args)
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
IOTest.evt
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 )
99 , m_evt( IAuditor::Initialize )
100 , // Windows needs an explicit value
101 m_cevt( std::move( evt ) )
102 , m_customEvtType( true )
103 {
104 i_before();
105 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
std::move
T move(T...args)
IAuditor::Initialize
Definition: IAuditor.h:25
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::m_customEvtType
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
std::move
T move(T...args)
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::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
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266
IOTest.evt
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 )
116 , m_evt( IAuditor::Initialize )
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
std::move
T move(T...args)
IAuditor::Initialize
Definition: IAuditor.h:25
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::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
Gaudi::Guards::AuditorGuard::m_customEvtType
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::i_after
void i_after()
Definition: Guards.h:287

Gaudi::Guards::AuditorGuard::AuditorGuard | ( |  | ) |
| private delete

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | const AuditorGuard & | right | ) |
| private delete

## Member Function Documentation

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

Definition at line 242 of file Guards.h.

242 { return *m_sc; }
Gaudi::Guards::AuditorGuard::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 | ( |  | ) |
| inline private

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 ) {
307 m_svc->after( m_cevt, m_objName, *m_sc );
308 } else {
309 m_svc->after( m_cevt, m_objName );
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 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
IAuditor::after
virtual void after(StandardEventType, INamedInterface *, const StatusCode &sc=StatusCode(StatusCode::SUCCESS, true))=0
Audit the end of a standard "event".
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:92
Gaudi::Guards::AuditorGuard::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
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266

void Gaudi::Guards::AuditorGuard::i_before | ( |  | ) |
| inline private

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 ) {
279 m_svc->before( m_cevt, m_objName );
280 } else {
281 m_svc->before( m_evt, m_objName );
282 }
283 }
284 }
285 }
IAuditor::before
virtual void before(StandardEventType, INamedInterface *)=0
Audit the start of a standard "event".
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:258
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:256
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:260
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:252
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:254
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:266

AuditorGuard& Gaudi::Guards::AuditorGuard::operator= | ( | const AuditorGuard & | right | ) |
| private delete

## 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:

- GaudiKernel/GaudiKernel/Guards.h
- GaudiKernel/src/Lib/Guards.cpp