The Gaudi Framework  v36r9 (fd2bdac3)
Gaudi::Guards::AuditorGuard Class Referencefinal

#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 213 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 65 of file Guards.cpp.

66  : m_obj( obj ), m_svc( svc ), m_evt( evt ) {
67  i_before();
68 }

◆ AuditorGuard() [2/10]

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

constructor

Definition at line 69 of file Guards.cpp.

70  : m_obj( obj )
71  , m_svc( svc )
73  , // Windows needs an explicit value
74  m_cevt( std::move( evt ) )
75  , m_customEvtType( true ) {
76  i_before();
77 }

◆ AuditorGuard() [3/10]

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

constructor

Definition at line 78 of file Guards.cpp.

80  : m_obj( obj ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false ) {
81  i_before();
82 }

◆ AuditorGuard() [4/10]

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

constructor

Definition at line 83 of file Guards.cpp.

85  : m_obj( obj )
86  , m_svc( svc )
88  , // Windows needs an explicit value
89  m_cevt( std::move( evt ) )
90  , m_sc( &sc )
91  , m_customEvtType( true ) {
92  i_before();
93 }

◆ AuditorGuard() [5/10]

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

constructor

Definition at line 94 of file Guards.cpp.

95  : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_customEvtType( false ) {
96  i_before();
97 }

◆ AuditorGuard() [6/10]

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

constructor

Definition at line 98 of file Guards.cpp.

99  : m_objName( std::move( name ) )
100  , m_svc( svc )
102  , // Windows needs an explicit value
103  m_cevt( std::move( evt ) )
104  , m_customEvtType( true ) {
105  i_before();
106 }

◆ AuditorGuard() [7/10]

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

constructor

Definition at line 107 of file Guards.cpp.

109  : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false ) {
110  i_before();
111 }

◆ AuditorGuard() [8/10]

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

constructor

Definition at line 112 of file Guards.cpp.

114  : m_objName( std::move( name ) )
115  , m_svc( svc )
117  , // Windows needs an explicit value
118  m_cevt( std::move( evt ) )
119  , m_sc( &sc )
120  , m_customEvtType( true ) {
121  i_before();
122 }

◆ ~AuditorGuard()

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

dectructor

Definition at line 126 of file Guards.cpp.

126 { 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 239 of file Guards.h.

239 { return *m_sc; }

◆ i_after()

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

Definition at line 283 of file Guards.h.

283  {
284  if ( m_svc ) { // if the service is not available, we cannot do anything
285  if ( m_obj ) {
286  if ( m_customEvtType ) {
287  if ( m_sc ) {
288  m_svc->after( m_cevt, m_obj, *m_sc );
289  } else {
290  m_svc->after( m_cevt, m_obj );
291  }
292  } else {
293  if ( m_sc ) {
294  m_svc->after( m_evt, m_obj, *m_sc );
295  } else {
296  m_svc->after( m_evt, m_obj );
297  }
298  }
299  } else { // use object name
300  if ( m_customEvtType ) {
301  if ( m_sc ) {
302  m_svc->after( m_cevt, m_objName, *m_sc );
303  } else {
304  m_svc->after( m_cevt, m_objName );
305  }
306  } else {
307  if ( m_sc ) {
308  m_svc->after( m_evt, m_objName, *m_sc );
309  } else {
310  m_svc->after( m_evt, m_objName );
311  }
312  }
313  }
314  m_svc.reset();
315  }
316  }

◆ i_before()

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

Definition at line 265 of file Guards.h.

265  {
266  if ( m_svc ) { // if the service is not available, we cannot do anything
267  if ( m_obj ) {
268  if ( m_customEvtType ) {
269  m_svc->before( m_cevt, m_obj );
270  } else {
271  m_svc->before( m_evt, m_obj );
272  }
273  } else { // use object name
274  if ( m_customEvtType ) {
275  m_svc->before( m_cevt, m_objName );
276  } else {
277  m_svc->before( m_evt, m_objName );
278  }
279  }
280  }
281  }

◆ 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 257 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 263 of file Guards.h.

◆ m_evt

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

Event type (standard events)

Definition at line 255 of file Guards.h.

◆ m_obj

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

the guarded object

Definition at line 249 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 251 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 261 of file Guards.h.

◆ m_svc

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

auditor service

Definition at line 253 of file Guards.h.


The documentation for this class was generated from the following files:
IOTest.evt
evt
Definition: IOTest.py:110
Gaudi::Algorithm::sysExecute
StatusCode sysExecute(const EventContext &ctx) override
The actions to be performed by the algorithm on an event.
Definition: Algorithm.cpp:341
std::move
T move(T... args)
SmartIF::reset
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:96
Gaudi::Guards::AuditorGuard::m_obj
INamedInterface * m_obj
the guarded object
Definition: Guards.h:249
Gaudi::Guards::AuditorGuard::m_svc
SmartIF< IAuditor > m_svc
auditor service
Definition: Guards.h:253
TimingHistograms.name
name
Definition: TimingHistograms.py:25
StatusCode
Definition: StatusCode.h:65
Gaudi::Guards::AuditorGuard::m_objName
std::string m_objName
the guarded object name (if there is no INamedInterface)
Definition: Guards.h:251
GaudiPython.Pythonizations.execute
execute
Definition: Pythonizations.py:588
IAuditor::Initialize
@ Initialize
Definition: IAuditor.h:34
Gaudi::Algorithm::sysInitialize
StatusCode sysInitialize() override
Initialization method invoked by the framework.
Definition: Algorithm.cpp:58
Gaudi::Guards::AuditorGuard::AuditorGuard
AuditorGuard()=delete
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:265
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:261
Gaudi::Guards::AuditorGuard::m_customEvtType
bool m_customEvtType
Flag to remember which event type was used.
Definition: Guards.h:263
Gaudi::Guards::AuditorGuard::m_evt
IAuditor::StandardEventType m_evt
Event type (standard events)
Definition: Guards.h:255
Gaudi::Guards::AuditorGuard::i_after
void i_after()
Definition: Guards.h:283
Gaudi::Guards::AuditorGuard::m_cevt
IAuditor::CustomEventType m_cevt
Event type (custom events)
Definition: Guards.h:257