All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Gaudi::Guards::AuditorGuard Class Reference

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

Private Member Functions

 AuditorGuard ()
 the default constructor is disabled More...
 
 AuditorGuard (const AuditorGuard &right)
 no copy More...
 
AuditorGuardoperator= (const AuditorGuard &right)
 no assignement More...
 
void i_before ()
 
void i_after ()
 

Private Attributes

INamedInterfacem_obj
 the guarded object More...
 
std::string m_objName
 the guarded object name (if there is no INamedInterface) More...
 
IAuditorm_svc
 auditor service More...
 
IAuditor::StandardEventType m_evt
 Event type (standard events) More...
 
IAuditor::CustomEventType m_cevt
 Event type (custom events) More...
 
const StatusCodem_sc
 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
 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 218 of file Guards.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 65 of file Guards.cpp.

67  :
68  m_obj(obj),
69  m_objName(),
70  m_svc(svc),
71  m_evt(evt),
72  m_cevt(),
73  m_sc(0),
74  m_customEvtType(false)
75 {
76  i_before();
77 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt 
)

constructor

Definition at line 78 of file Guards.cpp.

80  :
81  m_obj(obj),
82  m_objName(),
83  m_svc(svc),
84  m_evt(IAuditor::Initialize), // Windows needs an explicit value
85  m_cevt(evt),
86  m_sc(0),
87  m_customEvtType(true)
88 {
89  i_before();
90 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::StandardEventType  evt,
const StatusCode sc 
)

constructor

Definition at line 91 of file Guards.cpp.

94  :
95  m_obj(obj),
96  m_objName(),
97  m_svc(svc),
98  m_evt(evt),
99  m_cevt(),
100  m_sc(&sc),
101  m_customEvtType(false)
102 {
103  i_before();
104 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface obj,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt,
const StatusCode sc 
)

constructor

Definition at line 105 of file Guards.cpp.

108  :
109  m_obj(obj),
110  m_objName(),
111  m_svc(svc),
112  m_evt(IAuditor::Initialize), // Windows needs an explicit value
113  m_cevt(evt),
114  m_sc(&sc),
115  m_customEvtType(true)
116 {
117  i_before();
118 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::StandardEventType  evt 
)

constructor

Definition at line 119 of file Guards.cpp.

121  :
122  m_obj(0),
123  m_objName(name),
124  m_svc(svc),
125  m_evt(evt),
126  m_cevt(),
127  m_sc(0),
128  m_customEvtType(false)
129 {
130  i_before();
131 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt 
)

constructor

Definition at line 132 of file Guards.cpp.

134  :
135  m_obj(0),
136  m_objName(name),
137  m_svc(svc),
138  m_evt(IAuditor::Initialize), // Windows needs an explicit value
139  m_cevt(evt),
140  m_sc(0),
141  m_customEvtType(true)
142 {
143  i_before();
144 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::StandardEventType  evt,
const StatusCode sc 
)

constructor

Definition at line 145 of file Guards.cpp.

148  :
149  m_obj(0),
150  m_objName(name),
151  m_svc(svc),
152  m_evt(evt),
153  m_cevt(),
154  m_sc(&sc),
155  m_customEvtType(false)
156 {
157  i_before();
158 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string &  name,
IAuditor svc,
IAuditor::CustomEventTypeRef  evt,
const StatusCode sc 
)

constructor

Definition at line 159 of file Guards.cpp.

162  :
163  m_obj(0),
164  m_objName(name),
165  m_svc(svc),
166  m_evt(IAuditor::Initialize), // Windows needs an explicit value
167  m_cevt(evt),
168  m_sc(&sc),
169  m_customEvtType(true)
170 {
171  i_before();
172 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
Gaudi::Guards::AuditorGuard::~AuditorGuard ( )

dectructor

Definition at line 176 of file Guards.cpp.

177 {
178  i_after();
179 }
Gaudi::Guards::AuditorGuard::AuditorGuard ( )
private

the default constructor is disabled

Gaudi::Guards::AuditorGuard::AuditorGuard ( const AuditorGuard right)
private

no copy

Member Function Documentation

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

Definition at line 264 of file Guards.h.

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

Definition at line 309 of file Guards.h.

309  {
310  if ( 0 != m_svc ) { // if the service is not available, we cannot do anything
311  if (0 != m_obj) {
312  if (m_customEvtType) {
313  if (0 != m_sc) {
315  } else {
317  }
318  } else {
319  if (0 != m_sc) {
321  } else {
323  }
324  }
325  } else { // use object name
326  if (m_customEvtType) {
327  if (0 != m_sc) {
329  } else {
331  }
332  } else {
333  if (0 != m_sc) {
335  } else {
337  }
338  }
339  }
340  m_svc->release(); // we do not need the service anymore
341  m_svc = 0 ;
342  }
343  }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
virtual unsigned long release()=0
Release Interface instance.
virtual void after(StandardEventType, INamedInterface *, const StatusCode &sc=StatusCode(StatusCode::SUCCESS, true))=0
Audit the end of a standard "event".
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:286
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
void Gaudi::Guards::AuditorGuard::i_before ( )
inlineprivate

Definition at line 290 of file Guards.h.

290  {
291  if ( 0 != m_svc ) { // if the service is not available, we cannot do anything
292  m_svc->addRef(); // increase the reference counting
293  if (0 != m_obj) {
294  if (m_customEvtType) {
296  } else {
298  }
299  } else { // use object name
300  if (m_customEvtType) {
302  } else {
304  }
305  }
306  }
307  }
virtual void before(StandardEventType, INamedInterface *)=0
Audit the start of a standard "event".
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:280
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:282
INamedInterface * m_obj
the guarded object
Definition: Guards.h:274
IAuditor * m_svc
auditor service
Definition: Guards.h:278
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:276
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:288
AuditorGuard& Gaudi::Guards::AuditorGuard::operator= ( const AuditorGuard right)
private

no assignement

Member Data Documentation

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

Event type (custom events)

Definition at line 282 of file Guards.h.

bool Gaudi::Guards::AuditorGuard::m_customEvtType
private

Flag to remember which event type was used.

Definition at line 288 of file Guards.h.

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

Event type (standard events)

Definition at line 280 of file Guards.h.

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

the guarded object

Definition at line 274 of file Guards.h.

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

the guarded object name (if there is no INamedInterface)

Definition at line 276 of file Guards.h.

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

IAuditor* Gaudi::Guards::AuditorGuard::m_svc
private

auditor service

Definition at line 278 of file Guards.h.


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