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 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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
T move(T...args)
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
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
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
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:280
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
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
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
T move(T...args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
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
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::AuditorGuard ( )
privatedelete
Gaudi::Guards::AuditorGuard::AuditorGuard ( const AuditorGuard right)
privatedelete

Member Function Documentation

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

Definition at line 260 of file Guards.h.

260 { 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:280
void Gaudi::Guards::AuditorGuard::i_after ( )
inlineprivate

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) {
308  } else {
310  }
311  } else {
312  if (m_sc) {
314  } else {
316  }
317  }
318  } else { // use object name
319  if (m_customEvtType) {
320  if (m_sc) {
322  } else {
324  }
325  } else {
326  if (m_sc) {
328  } else {
330  }
331  }
332  }
333  m_svc.reset();
334  }
335  }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
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:88
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
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
void Gaudi::Guards::AuditorGuard::i_before ( )
inlineprivate

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) {
289  } else {
291  }
292  } else { // use object name
293  if (m_customEvtType) {
295  } else {
297  }
298  }
299  }
300  }
virtual void before(StandardEventType, INamedInterface *)=0
Audit the start of a standard "event".
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:274
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:272
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:276
INamedInterface * m_obj
the guarded object
Definition: Guards.h:268
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:270
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:282
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 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: