| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# 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:

[legend]

List of all members.

## Public Member Functions
| AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::StandardEventType evt)
| constructor
| AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::CustomEventTypeRef evt)
| constructor
| AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::StandardEventType evt, const StatusCode &sc)
| constructor
| AuditorGuard (INamedInterface *obj, IAuditor *svc, IAuditor::CustomEventTypeRef evt, const StatusCode &sc)
| constructor
| AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::StandardEventType evt)
| constructor
| AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::CustomEventTypeRef evt)
| constructor
| AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::StandardEventType evt, const StatusCode &sc)
| constructor
| AuditorGuard (const std::string &name, IAuditor *svc, IAuditor::CustomEventTypeRef evt, const StatusCode &sc)
| constructor
| ~AuditorGuard ()
| dectructor
const StatusCode & | code () const
## Private Member Functions
| AuditorGuard ()
| the default constructor is disabled
| AuditorGuard (const AuditorGuard &right)
| no copy
AuditorGuard & | operator= (const AuditorGuard &right)
| no assignement
void | i_before ()
void | i_after ()
## Private Attributes
INamedInterface * | m_obj
| the guarded object
std::string | m_objName
| the guarded object name (if there is no INamedInterface)
IAuditor * | m_svc
| auditor service
IAuditor::StandardEventType | m_evt
| Event type (standard events).
IAuditor::CustomEventType | m_cevt
| Event type (custom events).
const StatusCode * | m_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.
bool | m_customEvtType
| Flag to remember which event type was used.

## 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 ibelyaev@physics.syr.edu

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.

    00067                                                                    :
    00068                  m_obj(obj),
    00069                  m_objName(),
    00070                  m_svc(svc),
    00071                  m_evt(evt),
    00072                  m_cevt(),
    00073                  m_sc(0),
    00074                  m_customEvtType(false)
    00075 {
    00076   i_before();
    00077 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface*          obj      ,

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

constructor

Definition at line 78 of file Guards.cpp.

    00080                                                                       :
    00081                  m_obj(obj),
    00082                  m_objName(),
    00083                  m_svc(svc),
    00084                  m_evt(IAuditor::Initialize), // Windows needs an explicit value
    00085                  m_cevt(evt),
    00086                  m_sc(0),
    00087                  m_customEvtType(true)
    00088 {
    00089   i_before();
    00090 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface*             obj      ,

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

constructor

Definition at line 91 of file Guards.cpp.

    00094                                             :
    00095       m_obj(obj),
    00096       m_objName(),
    00097       m_svc(svc),
    00098       m_evt(evt),
    00099       m_cevt(),
    00100       m_sc(&sc),
    00101       m_customEvtType(false)
    00102 {
    00103   i_before();
    00104 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( INamedInterface*                   obj      ,

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

constructor

Definition at line 105 of file Guards.cpp.

    00108                                                  :
    00109       m_obj(obj),
    00110       m_objName(),
    00111       m_svc(svc),
    00112       m_evt(IAuditor::Initialize), // Windows needs an explicit value
    00113       m_cevt(evt),
    00114       m_sc(&sc),
    00115       m_customEvtType(true)
    00116 {
    00117   i_before();
    00118 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string           &name      ,

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

constructor

Definition at line 119 of file Guards.cpp.

    00121                                          :
    00122       m_obj(0),
    00123       m_objName(name),
    00124       m_svc(svc),
    00125       m_evt(evt),
    00126       m_cevt(),
    00127       m_sc(0),
    00128       m_customEvtType(false)
    00129 {
    00130   i_before();
    00131 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string           &name      ,

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

constructor

Definition at line 132 of file Guards.cpp.

    00134                                                :
    00135       m_obj(0),
    00136       m_objName(name),
    00137       m_svc(svc),
    00138       m_evt(IAuditor::Initialize), // Windows needs an explicit value
    00139       m_cevt(evt),
    00140       m_sc(0),
    00141       m_customEvtType(true)
    00142 {
    00143   i_before();
    00144 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string           &name      ,

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.

    00148                                            :
    00149       m_obj(0),
    00150       m_objName(name),
    00151       m_svc(svc),
    00152       m_evt(evt),
    00153       m_cevt(),
    00154       m_sc(&sc),
    00155       m_customEvtType(false)
    00156 {
    00157   i_before();
    00158 }
    Gaudi::Guards::AuditorGuard::AuditorGuard ( const std::string           &name      ,

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.

    00162                                                  :
    00163       m_obj(0),
    00164       m_objName(name),
    00165       m_svc(svc),
    00166       m_evt(IAuditor::Initialize), // Windows needs an explicit value
    00167       m_cevt(evt),
    00168       m_sc(&sc),
    00169       m_customEvtType(true)
    00170 {
    00171   i_before();
    00172 }
    // ============================================================================

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

dectructor

Definition at line 176 of file Guards.cpp.

    00177 {
    00178   i_after();
    00179 }

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.

    00264 { return *m_sc ; }

AuditorGuard& Gaudi::Guards::AuditorGuard::operator= | ( | const AuditorGuard & | right | ) | `[private]`

no assignement

void Gaudi::Guards::AuditorGuard::i_before | ( |  | ) | `[inline, private]`

Definition at line 290 of file Guards.h.

    00290                              {
    00291         if ( 0 != m_svc ) { // if the service is not available, we cannot do anything
    00292           m_svc->addRef(); // increase the reference counting
    00293           if (0 != m_obj) {
    00294             if (m_customEvtType) {
    00295               m_svc->before(m_cevt,m_obj);
    00296             } else {
    00297               m_svc->before(m_evt,m_obj);
    00298             }
    00299           } else { // use object name
    00300             if (m_customEvtType) {
    00301               m_svc->before(m_cevt,m_objName);
    00302             } else {
    00303               m_svc->before(m_evt,m_objName);
    00304             }
    00305           }
    00306         }
    00307       }

void Gaudi::Guards::AuditorGuard::i_after | ( |  | ) | `[inline, private]`

Definition at line 309 of file Guards.h.

    00309                             {
    00310         if ( 0 != m_svc ) { // if the service is not available, we cannot do anything
    00311           if (0 != m_obj) {
    00312             if (m_customEvtType) {
    00313               if (0 != m_sc) {
    00314                 m_svc->after(m_cevt,m_obj,*m_sc);
    00315               } else {
    00316                 m_svc->after(m_cevt,m_obj);
    00317               }
    00318             } else {
    00319               if (0 != m_sc) {
    00320                 m_svc->after(m_evt,m_obj,*m_sc);
    00321               } else {
    00322                 m_svc->after(m_evt,m_obj);
    00323               }
    00324             }
    00325           } else { // use object name
    00326             if (m_customEvtType) {
    00327               if (0 != m_sc) {
    00328                 m_svc->after(m_cevt,m_objName,*m_sc);
    00329               } else {
    00330                 m_svc->after(m_cevt,m_objName);
    00331               }
    00332             } else {
    00333               if (0 != m_sc) {
    00334                 m_svc->after(m_evt,m_objName,*m_sc);
    00335               } else {
    00336                 m_svc->after(m_evt,m_objName);
    00337               }
    00338             }
    00339           }
    00340           m_svc->release(); // we do not need the service anymore
    00341           m_svc = 0 ;
    00342         }
    00343       }

## Member Data Documentation

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.

IAuditor* Gaudi::Guards::AuditorGuard::m_svc`[private]`

auditor service

Definition at line 278 of file Guards.h.

IAuditor::StandardEventType Gaudi::Guards::AuditorGuard::m_evt`[private]`

Event type (standard events).

Definition at line 280 of file Guards.h.

IAuditor::CustomEventType Gaudi::Guards::AuditorGuard::m_cevt`[private]`

Event type (custom events).

Definition at line 282 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.

bool Gaudi::Guards::AuditorGuard::m_customEvtType`[private]`

Flag to remember which event type was used.

Definition at line 288 of file Guards.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/GaudiKernel/Guards.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiKernel/src/Lib/Guards.cpp