Gaudi Framework, version v23r6

Home   Generated: Wed Jan 30 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
ExceptionSvc Class Reference

Simple implementation of IExceptionSvc abstract interface. More...

#include <ExceptionSvc.h>

Inheritance diagram for ExceptionSvc:
Inheritance graph
[legend]
Collaboration diagram for ExceptionSvc:
Collaboration graph
[legend]

Public Member Functions

virtual StatusCode handle (const INamedInterface &o, const GaudiException &e) const
 Handle caught GaudiExceptions.
 
virtual StatusCode handle (const INamedInterface &o, const std::exception &e) const
 Handle caught std::exceptions.
 
virtual StatusCode handle (const INamedInterface &o) const
 Handle caught (unknown)exceptions.
 
virtual StatusCode handleErr (const INamedInterface &o, const StatusCode &s) const
 Handle errors.
 
virtual StatusCode initialize ()
 initialize the service
 
virtual StatusCode finalize ()
 finalize the service
 
 ExceptionSvc (const std::string &name, ISvcLocator *svc)
 standard constructor
 
virtual ~ExceptionSvc ()
 Destructor.
 
- Public Member Functions inherited from extends1< Service, IExceptionSvc >
 extends1 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends1 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends1 (A1 a1)
 Templated constructor with 1 argument.
 
 extends1 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends1 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces1< IExceptionSvc >
virtual ~extend_interfaces1 ()
 Virtual destructor.
 
- Public Member Functions inherited from IExceptionSvc
 DeclareInterfaceID (IExceptionSvc, 3, 0)
 InterfaceID.
 
- Public Member Functions inherited from IInterface
virtual unsigned long addRef ()=0
 Increment the reference count of Interface instance.
 
virtual unsigned long release ()=0
 Release Interface instance.
 
virtual unsigned long refCount () const =0
 Current reference count.
 
virtual ~IInterface ()
 Virtual destructor.
 

Private Types

enum  Policy { ALL, NONE }
 
enum  ReturnState {
  SUCCESS, FAILURE, RECOVERABLE, RETHROW,
  DEFAULT
}
 

Private Member Functions

 ExceptionSvc ()
 no default constructor
 
 ExceptionSvc (const ExceptionSvc &)
 no copy constructor
 
ExceptionSvcoperator= (const ExceptionSvc &)
 no assignement
 
virtual StatusCode process (const INamedInterface &o) const
 

Private Attributes

Policy m_mode_exc
 
Policy m_mode_err
 
StringProperty m_mode_exc_s
 
StringProperty m_mode_err_s
 
std::map< std::string,
ReturnState
m_retCodesExc
 
std::map< std::string,
ReturnState
m_retCodesErr
 
MsgStream m_log
 

Friends

class SvcFactory< ExceptionSvc >
 

Additional Inherited Members

- Public Types inherited from extends1< Service, IExceptionSvc >
typedef extends1 base_class
 Typedef to this class.
 
typedef extend_interfaces1
< IExceptionSvc
extend_interfaces_base
 Typedef to the base of this class.
 
typedef
extend_interfaces_base::ext_iids 
interfaces
 MPL set of all the implemented interfaces.
 
- Static Public Member Functions inherited from IInterface
static const InterfaceIDinterfaceID ()
 Return an instance of InterfaceID identifying the interface.
 
- Protected Member Functions inherited from Service
virtual ~Service ()
 Standard Destructor.
 
int outputLevel () const
 get the Service's output level
 
- Protected Member Functions inherited from IExceptionSvc
virtual ~IExceptionSvc ()
 virtual and protected destructor
 
- Protected Attributes inherited from Service
IntegerProperty m_outputLevel
 Service output level.
 
Gaudi::StateMachine::State m_state
 Service state.
 
Gaudi::StateMachine::State m_targetState
 Service state.
 

Detailed Description

Simple implementation of IExceptionSvc abstract interface.

Author
(1) ATLAS collaboration
(2) modified by Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-03-08

Definition at line 20 of file ExceptionSvc.h.

Member Enumeration Documentation

enum ExceptionSvc::Policy
private
Enumerator:
ALL 
NONE 

Definition at line 64 of file ExceptionSvc.h.

{ ALL, NONE };
Enumerator:
SUCCESS 
FAILURE 
RECOVERABLE 
RETHROW 
DEFAULT 

Definition at line 65 of file ExceptionSvc.h.

Constructor & Destructor Documentation

ExceptionSvc::ExceptionSvc ( const std::string name,
ISvcLocator svc 
)

standard constructor

Parameters
nameservice instance name
pSvcpointer to Service Locator

Definition at line 36 of file ExceptionSvc.cpp.

: base_class( name, svc )
, m_log(msgSvc(), name )
{
// for exceptions
declareProperty( "Catch" , m_mode_exc_s="ALL" ) ;
// for return codes
declareProperty( "Errors" , m_mode_err_s="NONE" ) ;
}
ExceptionSvc::~ExceptionSvc ( )
virtual

Destructor.

Definition at line 50 of file ExceptionSvc.cpp.

{
}
ExceptionSvc::ExceptionSvc ( )
private

no default constructor

ExceptionSvc::ExceptionSvc ( const ExceptionSvc )
private

no copy constructor

Member Function Documentation

StatusCode ExceptionSvc::finalize ( )
virtual

finalize the service

Reimplemented from Service.

Definition at line 199 of file ExceptionSvc.cpp.

{
return status;
}
StatusCode ExceptionSvc::handle ( const INamedInterface o,
const GaudiException e 
) const
virtual

Handle caught GaudiExceptions.

Handle caught exceptions

Implements IExceptionSvc.

Definition at line 308 of file ExceptionSvc.cpp.

{
m_log << MSG::DEBUG << "Handling GaudiException: \"" << exc << "\" for "
<< alg.name() << endmsg;
return process(alg);
}
StatusCode ExceptionSvc::handle ( const INamedInterface o,
const std::exception e 
) const
virtual

Handle caught std::exceptions.

Handle caught exceptions

Implements IExceptionSvc.

Definition at line 296 of file ExceptionSvc.cpp.

{
m_log << MSG::DEBUG << "Handling std:except: \"" << exc.what() << "\" for "
<< alg.name() << endmsg;
return process(alg) ;
}
StatusCode ExceptionSvc::handle ( const INamedInterface o) const
virtual

Handle caught (unknown)exceptions.

Handle caught exceptions

Implements IExceptionSvc.

Definition at line 286 of file ExceptionSvc.cpp.

{
m_log << MSG::DEBUG << "Handling unknown exception for " << alg.name()
<< endmsg;
return process(alg);
}
StatusCode ExceptionSvc::handleErr ( const INamedInterface o,
const StatusCode s 
) const
virtual

Handle errors.

Handle errors

Implements IExceptionSvc.

Definition at line 208 of file ExceptionSvc.cpp.

{
m_log << MSG::DEBUG << "Handling Error from " << alg.name() << endmsg;
// is this Alg special?
if (m_retCodesErr.find(alg.name()) != m_retCodesErr.end()) {
ReturnState iret = m_retCodesErr.find(alg.name())->second;
switch ( iret ) {
case SUCCESS:
case FAILURE:
case RETHROW:
// should never get here
break;
case DEFAULT:
// should never get here
break;
}
} else {
if (m_mode_err == ALL) {
// turn it into a FAILURE
} else {
assert (m_mode_err == NONE );
// don't touch the return code
return st;
}
}
}
StatusCode ExceptionSvc::initialize ( )
virtual

initialize the service

Reimplemented from Service.

Definition at line 58 of file ExceptionSvc.cpp.

{
if ( status.isFailure() ) { return status ; } // RETURN
string key = m_mode_exc_s.value();
string::size_type loc = key.find(" ");
if (loc == std::string::npos) {
mode = key;
} else {
mode = key.substr(0,loc);
}
toupper(mode);
if (mode == "NONE") {
} else if (mode == "ALL") {
} else {
m_log << MSG::ERROR << "Unknown mode for Exception handling: \"" << mode
<< "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg;
}
if (loc == string::npos) {
key = "";
} else {
key = key.substr(loc+1,key.length());
}
Tokenizer tok(true);
std::string val,VAL,TAG;
tok.analyse( key, " ", "", "", "=", "", "");
for ( Tokenizer::Items::iterator i = tok.items().begin();
i != tok.items().end(); i++) {
const std::string& tag = (*i).tag();
TAG = tag;
val = (*i).value();
VAL = val;
toupper(VAL);
if (VAL == "SUCCESS") {
} else if ( VAL == "FAILURE" ) {
} else if ( VAL == "REVOVERABLE" ) {
} else if ( VAL == "RETHROW" ) {
} else if ( VAL == "DEFAULT" ) {
} else {
m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL
<< "\" for Algorithm " << TAG << std::endl
<< " Must be one of: DEFAULT, SUCCESS, FAILURE, RECOVERABLE, RETHROW"
<< endmsg;
}
m_log << MSG::DEBUG << "Will catch exceptions thrown by: " << TAG
<< " -> action: " << VAL << endmsg;
}
// now process errors
loc = key.find(" ");
if (loc == std::string::npos) {
mode = key;
} else {
mode = key.substr(0,loc);
}
toupper(mode);
if (mode == "NONE") {
} else if (mode == "ALL") {
} else {
m_log << MSG::ERROR << "Unknown mode for Error handling: \"" << mode
<< "\". Default must be one of \"ALL\" or \"NONE\"" << endmsg;
}
if (loc == string::npos) {
key = "";
} else {
key = key.substr(loc+1,key.length());
}
Tokenizer tok2(true);
tok2.analyse( key, " ", "", "", "=", "", "");
for ( Tokenizer::Items::iterator i = tok2.items().begin();
i != tok2.items().end(); i++) {
const std::string& tag = (*i).tag();
TAG = tag;
val = (*i).value();
VAL = val;
toupper(VAL);
if (VAL == "SUCCESS") {
} else if ( VAL == "FAILURE" ) {
} else if ( VAL == "RECOVERABLE" ) {
} else {
m_log << MSG::ERROR << "In JobOpts: unknown return code \"" << VAL
<< "\" for Algorithm " << TAG << std::endl
<< " Must be one of: SUCCESS, FAILURE, RECOVERABLE"
<< endmsg;
}
m_log << MSG::DEBUG << "Will process Errors returned by: " << TAG
<< " -> action: " << VAL << endmsg;
}
return status;
}
ExceptionSvc& ExceptionSvc::operator= ( const ExceptionSvc )
private

no assignement

StatusCode ExceptionSvc::process ( const INamedInterface o) const
privatevirtual

Definition at line 250 of file ExceptionSvc.cpp.

{
// is this Alg special?
if (m_retCodesExc.find(alg.name()) != m_retCodesExc.end()) {
ReturnState iret = m_retCodesExc.find(alg.name())->second;
switch ( iret ) {
case DEFAULT:
// there is no default
case SUCCESS:
case FAILURE:
case RETHROW:
throw;
}
} else {
if (m_mode_exc == ALL) {
throw;
} else {
assert (m_mode_exc == NONE);
}
}
}

Friends And Related Function Documentation

friend class SvcFactory< ExceptionSvc >
friend

Definition at line 21 of file ExceptionSvc.h.

Member Data Documentation

MsgStream ExceptionSvc::m_log
mutableprivate

Definition at line 71 of file ExceptionSvc.h.

Policy ExceptionSvc::m_mode_err
private

Definition at line 67 of file ExceptionSvc.h.

StringProperty ExceptionSvc::m_mode_err_s
private

Definition at line 68 of file ExceptionSvc.h.

Policy ExceptionSvc::m_mode_exc
private

Definition at line 67 of file ExceptionSvc.h.

StringProperty ExceptionSvc::m_mode_exc_s
private

Definition at line 68 of file ExceptionSvc.h.

std::map<std::string,ReturnState> ExceptionSvc::m_retCodesErr
private

Definition at line 69 of file ExceptionSvc.h.

std::map<std::string,ReturnState> ExceptionSvc::m_retCodesExc
private

Definition at line 69 of file ExceptionSvc.h.


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

Generated at Wed Jan 30 2013 17:13:45 for Gaudi Framework, version v23r6 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004