| The Gaudi Framework v32r1 (f65d50dc)

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

## Constructor & Destructor Documentation

## ◆ AuditorGuard() [1/10]

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

constructor

Definition at line 55 of file Guards.cpp.

56 : m_obj( obj ), m_svc( svc ), m_evt( evt ) {
57 i_before();
58 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [2/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | INamedInterface * | obj,
|  | IAuditor * | svc,
|  | IAuditor::CustomEventTypeRef | evt
| ) |  |

constructor

Definition at line 59 of file Guards.cpp.

60 : m_obj( obj )
61 , m_svc( svc )
62 , m_evt( IAuditor::Initialize )
63 , // Windows needs an explicit value
64 m_cevt( std::move( evt ) )
65 , m_customEvtType( true ) {
66 i_before();
67 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
std::move
T move(T... args)
IAuditor::Initialize
Definition: IAuditor.h:24
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [3/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | INamedInterface * | obj,
|  | IAuditor * | svc,
|  | IAuditor::StandardEventType | evt,
|  | const StatusCode & | sc
| ) |  |

constructor

Definition at line 68 of file Guards.cpp.

70 : m_obj( obj ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false ) {
71 i_before();
72 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
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:251
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [4/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | INamedInterface * | obj,
|  | IAuditor * | svc,
|  | IAuditor::CustomEventTypeRef | evt,
|  | const StatusCode & | sc
| ) |  |

constructor

Definition at line 73 of file Guards.cpp.

75 : m_obj( obj )
76 , m_svc( svc )
77 , m_evt( IAuditor::Initialize )
78 , // Windows needs an explicit value
79 m_cevt( std::move( evt ) )
80 , m_sc( &sc )
81 , m_customEvtType( true ) {
82 i_before();
83 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
std::move
T move(T... args)
IAuditor::Initialize
Definition: IAuditor.h:24
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
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:251
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [5/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | std::string | name,
|  | IAuditor * | svc,
|  | IAuditor::StandardEventType | evt
| ) |  |

constructor

Definition at line 84 of file Guards.cpp.

85 : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_customEvtType( false ) {
86 i_before();
87 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
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:241
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [6/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | std::string | name,
|  | IAuditor * | svc,
|  | IAuditor::CustomEventTypeRef | evt
| ) |  |

constructor

Definition at line 88 of file Guards.cpp.

89 : m_objName( std::move( name ) )
90 , m_svc( svc )
91 , m_evt( IAuditor::Initialize )
92 , // Windows needs an explicit value
93 m_cevt( std::move( evt ) )
94 , m_customEvtType( true ) {
95 i_before();
96 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
std::move
T move(T... args)
IAuditor::Initialize
Definition: IAuditor.h:24
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [7/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | std::string | name,
|  | IAuditor * | svc,
|  | IAuditor::StandardEventType | evt,
|  | const StatusCode & | sc
| ) |  |

constructor

Definition at line 97 of file Guards.cpp.

99 : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false ) {
100 i_before();
101 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
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:241
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
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:251
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ AuditorGuard() [8/10]

Gaudi::Guards::AuditorGuard::AuditorGuard | ( | std::string | name,
|  | IAuditor * | svc,
|  | IAuditor::CustomEventTypeRef | evt,
|  | const StatusCode & | sc
| ) |  |

constructor

Definition at line 102 of file Guards.cpp.

104 : m_objName( std::move( name ) )
105 , m_svc( svc )
106 , m_evt( IAuditor::Initialize )
107 , // Windows needs an explicit value
108 m_cevt( std::move( evt ) )
109 , m_sc( &sc )
110 , m_customEvtType( true ) {
111 i_before();
112 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
std::move
T move(T... args)
IAuditor::Initialize
Definition: IAuditor.h:24
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
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:251
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
IOTest.evt
evt
Definition: IOTest.py:94

## ◆ ~AuditorGuard()

Gaudi::Guards::AuditorGuard::~AuditorGuard | ( |  | ) |

dectructor

Definition at line 116 of file Guards.cpp.

116 { i_after(); }
Gaudi::Guards::AuditorGuard::i_after
void i_after()
Definition: Guards.h:273

## ◆ AuditorGuard() [9/10]

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

## ◆ AuditorGuard() [10/10]

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

## Member Function Documentation

## ◆ code()

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

Definition at line 229 of file Guards.h.

229 { 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:251

## ◆ i_after()

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

Definition at line 273 of file Guards.h.

273 {
274 if ( m_svc ) { // if the service is not available, we cannot do anything
275 if ( m_obj ) {
276 if ( m_customEvtType ) {
277 if ( m_sc ) {
278 m_svc->after( m_cevt, m_obj, *m_sc );
279 } else {
280 m_svc->after( m_cevt, m_obj );
281 }
282 } else {
283 if ( m_sc ) {
284 m_svc->after( m_evt, m_obj, *m_sc );
285 } else {
286 m_svc->after( m_evt, m_obj );
287 }
288 }
289 } else { // use object name
290 if ( m_customEvtType ) {
291 if ( m_sc ) {
292 m_svc->after( m_cevt, m_objName, *m_sc );
293 } else {
294 m_svc->after( m_cevt, m_objName );
295 }
296 } else {
297 if ( m_sc ) {
298 m_svc->after( m_evt, m_objName, *m_sc );
299 } else {
300 m_svc->after( m_evt, m_objName );
301 }
302 }
303 }
304 m_svc.reset();
305 }
306 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
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:86
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:251
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253

## ◆ i_before()

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

Definition at line 255 of file Guards.h.

255 {
256 if ( m_svc ) { // if the service is not available, we cannot do anything
257 if ( m_obj ) {
258 if ( m_customEvtType ) {
259 m_svc->before( m_cevt, m_obj );
260 } else {
261 m_svc->before( m_evt, m_obj );
262 }
263 } else { // use object name
264 if ( m_customEvtType ) {
265 m_svc->before( m_cevt, m_objName );
266 } else {
267 m_svc->before( m_evt, m_objName );
268 }
269 }
270 }
271 }
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:245
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253

## ◆ operator=()

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

## Member Data Documentation

## ◆ m_cevt

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

Event type (custom events)

Definition at line 247 of file Guards.h.

## ◆ m_customEvtType

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

Flag to remember which event type was used.

Definition at line 253 of file Guards.h.

## ◆ m_evt

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

Event type (standard events)

Definition at line 245 of file Guards.h.

## ◆ m_obj

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

the guarded object

Definition at line 239 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 241 of file Guards.h.

## ◆ m_sc

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

## ◆ m_svc

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

auditor service

Definition at line 243 of file Guards.h.

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

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