| The Gaudi Framework v28r2p1 (f1a77ff4)

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

## Constructor & Destructor Documentation

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

constructor

Definition at line 64 of file Guards.cpp.

66 :
67 m_obj(obj),
68 m_svc(svc),
69 m_evt(evt)
70 {
71 i_before();
72 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
IOTest.evt
evt
Definition: IOTest.py:85

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

constructor

Definition at line 73 of file Guards.cpp.

75 :
76 m_obj(obj),
77 m_svc(svc),
78 m_evt(IAuditor::Initialize), // Windows needs an explicit value
79 m_cevt(std::move(evt)),
80 m_customEvtType(true)
81 {
82 i_before();
83 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
std::move
T move(T...args)
IAuditor::Initialize
Definition: IAuditor.h:25
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282

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

constructor

Definition at line 84 of file Guards.cpp.

87 :
88 m_obj(obj),
89 m_svc(svc),
90 m_evt(evt),
91 m_sc(&sc),
92 m_customEvtType(false)
93 {
94 i_before();
95 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
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:280
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
IOTest.evt
evt
Definition: IOTest.py:85

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

constructor

Definition at line 96 of file Guards.cpp.

99 :
100 m_obj(obj),
101 m_svc(svc),
102 m_evt(IAuditor::Initialize), // Windows needs an explicit value
103 m_cevt(std::move(evt)),
104 m_sc(&sc),
105 m_customEvtType(true)
106 {
107 i_before();
108 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
std::move
T move(T...args)
IAuditor::Initialize
Definition: IAuditor.h:25
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
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:280
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282

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

constructor

Definition at line 109 of file Guards.cpp.

111 :
112 m_objName(std::move(name)),
113 m_svc(svc),
114 m_evt(evt),
115 m_customEvtType(false)
116 {
117 i_before();
118 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
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:270
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
IOTest.evt
evt
Definition: IOTest.py:85

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

constructor

Definition at line 119 of file Guards.cpp.

121 :
122 m_objName(std::move(name)),
123 m_svc(svc),
124 m_evt(IAuditor::Initialize), // Windows needs an explicit value
125 m_cevt(std::move(evt)),
126 m_customEvtType(true)
127 {
128 i_before();
129 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
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:270
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282

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

constructor

Definition at line 130 of file Guards.cpp.

133 :
134 m_objName(std::move(name)),
135 m_svc(svc),
136 m_evt(evt),
137 m_sc(&sc),
138 m_customEvtType(false)
139 {
140 i_before();
141 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
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:270
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
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:280
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
IOTest.evt
evt
Definition: IOTest.py:85

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

constructor

Definition at line 142 of file Guards.cpp.

145 :
146 m_objName(std::move(name)),
147 m_svc(svc),
148 m_evt(IAuditor::Initialize), // Windows needs an explicit value
149 m_cevt(std::move(evt)),
150 m_sc(&sc),
151 m_customEvtType(true)
152 {
153 i_before();
154 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
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:270
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:284
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:280
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282

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

dectructor

Definition at line 158 of file Guards.cpp.

159 {
160 i_after();
161 }
Gaudi::Guards::AuditorGuard::i_after
void i_after()
Definition: Guards.h:302

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

260 { 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:280

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

Definition at line 302 of file Guards.h.

302 {
303 if ( m_svc ) { // if the service is not available, we cannot do anything
304 if ( m_obj) {
305 if (m_customEvtType) {
306 if ( m_sc) {
307 m_svc->after(m_cevt,m_obj,*m_sc);
308 } else {
309 m_svc->after(m_cevt,m_obj);
310 }
311 } else {
312 if (m_sc) {
313 m_svc->after(m_evt,m_obj,*m_sc);
314 } else {
315 m_svc->after(m_evt,m_obj);
316 }
317 }
318 } else { // use object name
319 if (m_customEvtType) {
320 if (m_sc) {
321 m_svc->after(m_cevt,m_objName,*m_sc);
322 } else {
323 m_svc->after(m_cevt,m_objName);
324 }
325 } else {
326 if (m_sc) {
327 m_svc->after(m_evt,m_objName,*m_sc);
328 } else {
329 m_svc->after(m_evt,m_objName);
330 }
331 }
332 }
333 m_svc.reset();
334 }
335 }
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
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:88
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:280
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282

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

Definition at line 284 of file Guards.h.

284 {
285 if ( m_svc ) { // if the service is not available, we cannot do anything
286 if (m_obj) {
287 if (m_customEvtType) {
288 m_svc->before(m_cevt,m_obj);
289 } else {
290 m_svc->before(m_evt,m_obj);
291 }
292 } else { // use object name
293 if (m_customEvtType) {
294 m_svc->before(m_cevt,m_objName);
295 } else {
296 m_svc->before(m_evt,m_objName);
297 }
298 }
299 }
300 }
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:274
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282

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

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

Flag to remember which event type was used.

Definition at line 282 of file Guards.h.

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

Event type (standard events)

Definition at line 274 of file Guards.h.

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

the guarded object

Definition at line 268 of file Guards.h.

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

the guarded object name (if there is no INamedInterface)

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

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

auditor service

Definition at line 272 of file Guards.h.

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

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