The Gaudi Framework  v32r2 (46d42edc)
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 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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
evt
Definition: IOTest.py:95

◆ 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 )
63  , // Windows needs an explicit value
64  m_cevt( std::move( evt ) )
65  , m_customEvtType( true ) {
66  i_before();
67 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
T move(T... args)
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
evt
Definition: IOTest.py:95

◆ 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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
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
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
evt
Definition: IOTest.py:95

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

◆ 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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
T move(T... args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
evt
Definition: IOTest.py:95

◆ 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 )
92  , // Windows needs an explicit value
93  m_cevt( std::move( evt ) )
94  , m_customEvtType( true ) {
95  i_before();
96 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
T move(T... args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
evt
Definition: IOTest.py:95

◆ 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 }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
T move(T... args)
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
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
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253
evt
Definition: IOTest.py:95

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

◆ ~AuditorGuard()

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

dectructor

Definition at line 116 of file Guards.cpp.

116 { i_after(); }

◆ AuditorGuard() [9/10]

Gaudi::Guards::AuditorGuard::AuditorGuard ( )
privatedelete

◆ AuditorGuard() [10/10]

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

Member Function Documentation

◆ code()

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

Definition at line 229 of file Guards.h.

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

◆ i_after()

void Gaudi::Guards::AuditorGuard::i_after ( )
inlineprivate

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 ) {
293  } else {
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  }
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
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:86
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
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253

◆ i_before()

void Gaudi::Guards::AuditorGuard::i_before ( )
inlineprivate

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 ) {
266  } else {
268  }
269  }
270  }
271  }
virtual void before(StandardEventType, INamedInterface *)=0
Audit the start of a standard "event".
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:245
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:243
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:247
INamedInterface * m_obj
the guarded object
Definition: Guards.h:239
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:241
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:253

◆ operator=()

AuditorGuard& Gaudi::Guards::AuditorGuard::operator= ( const AuditorGuard right)
privatedelete

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: