| # Gaudi Framework, version v25r0 |

Home |  | Generated: Mon Feb 17 2014

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

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

Guards.h GaudiKernel/Guards.h Collection of very simple classes which allows to execution of some functions within the given well-defined and exception-safe context. More...

## Classes
class | ExceptionGuard
| The most simple guard - it execute the certain code withing typical "try {} catch" clause, used in Auditor, Algorithm, AlgTool, etc. More...
class | AuditorGuard
| It is a simple guard, which "locks" the scope for the Auditor Service is am exception-safe way. More...

## Detailed Description

Guards.h GaudiKernel/Guards.h Collection of very simple classes which allows to execution of some functions within the given well-defined and exception-safe context.

In addition these utilities allow to remove many ugly lines from many ancient base classes

The namespace contains two simple guards:

- class Gaudi::Guards::ExceptionGuard
- class Gaudi::Guards::AuditorGuard

Please note tha the class Gaudi::Utils::AlgContext is also some kind of "guard".

All these guards could work together in very collaborative way:

StatusCode Algorithm::sysInitialize ()
{
// create the message stream:
MsgStream log ( msgSvc() , name() ) ;
// lock the scope for Auditor Service
Gaudi::Guards::AuditorGuard auditor
( this ,
auditorSvc() ,
&IAuditorSvc::beforeInitialize ,
&IAuditorsvc::afterInitialize ) ;
// Lock the scope for Algorithm Context Service:
Gaudi::Utils::AlgContext context ( this , m_contextSvc ) ;
// execute IAlgorithm::initialize within "try{}catch(..)" clause:
Gaudi::Guards::ExceptionGuard guard
( this ,
std::mem_fun(&IAlgorithm::initialize) ,
log ,
m_exceptionSvc ) ;
return guard ;
}

C++ guarantees the proper execution of all "post"-actions for all involved guards when the scope is destroyed.

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