| The Gaudi Framework v32r1 (f65d50dc)

Guards.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // STD & STL
5 // ============================================================================
6 #include <exception>
7 // ============================================================================
8 // GaudiKernel
9 // ============================================================================
10 #include "GaudiKernel/GaudiException.h"
11 #include "GaudiKernel/Guards.h"
12 #include "GaudiKernel/MsgStream.h"
13 #include "GaudiKernel/System.h"
14 // ============================================================================
21 // ============================================================================
22 // Local handle (print) of GaudiException
23 // ============================================================================
24 void Gaudi::Guards::ExceptionGuard::handle( const GaudiException& exc, MsgStream& log ) {
25 // the general printout
26 log << MSG::FATAL << System::typeinfoName( typeid( exc ) ) << "('" << exc.tag() << "') is caught!" << endmsg;
27 // print the detailes about the exception:
28 log << MSG::ERROR << exc << endmsg;
29 // get the status code form the exception:
30 m_sc = exc.code();
31 }
32 // ============================================================================
33 // Local handle (print) of std::exception
34 // ============================================================================
35 void Gaudi::Guards::ExceptionGuard::handle( const std::exception& exc, MsgStream& log ) {
36 // the general printout
37 log << MSG::FATAL << System::typeinfoName( typeid( exc ) ) << " is caught!" << endmsg;
38 // print the detailes abotu the exception:
39 log << MSG::ERROR << exc.what() << endmsg;
40 }
41 // ============================================================================
42 // Local handle (print) of unknown exception
43 // ============================================================================
44 void Gaudi::Guards::ExceptionGuard::handle( MsgStream& log ) {
45 // the general printout
46 log << MSG::FATAL << "UNKNOWN exception is caught!" << endmsg;
47 }
48 // ============================================================================
49 // dectructor
50 // ============================================================================
51 Gaudi::Guards::ExceptionGuard::~ExceptionGuard() { m_sc.ignore(); }
52 // ============================================================================
53 // constructor with standard post-action
54 // ============================================================================
55 Gaudi::Guards::AuditorGuard::AuditorGuard( INamedInterface* obj, IAuditor* svc, IAuditor::StandardEventType evt )
56 : m_obj( obj ), m_svc( svc ), m_evt( evt ) {
57 i_before();
58 }
59 Gaudi::Guards::AuditorGuard::AuditorGuard( INamedInterface* obj, IAuditor* svc, IAuditor::CustomEventTypeRef evt )
60 : m_obj( obj )
61 , m_svc( svc )
62 , m_evt( IAuditor::Initialize )
63 , // Windows needs an explicit value
64 m_cevt( std::move( evt ) )
65 , m_customEvtType( true ) {
66 i_before();
67 }
68 Gaudi::Guards::AuditorGuard::AuditorGuard( INamedInterface* obj, IAuditor* svc, IAuditor::StandardEventType evt,
69 const StatusCode& sc )
70 : m_obj( obj ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false ) {
71 i_before();
72 }
73 Gaudi::Guards::AuditorGuard::AuditorGuard( INamedInterface* obj, IAuditor* svc, IAuditor::CustomEventTypeRef evt,
74 const StatusCode& sc )
75 : m_obj( obj )
76 , m_svc( svc )
77 , m_evt( IAuditor::Initialize )
78 , // Windows needs an explicit value
79 m_cevt( std::move( evt ) )
80 , m_sc( &sc )
81 , m_customEvtType( true ) {
82 i_before();
83 }
84 Gaudi::Guards::AuditorGuard::AuditorGuard( std::string name, IAuditor* svc, IAuditor::StandardEventType evt )
85 : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_customEvtType( false ) {
86 i_before();
87 }
88 Gaudi::Guards::AuditorGuard::AuditorGuard( std::string name, IAuditor* svc, IAuditor::CustomEventTypeRef evt )
89 : m_objName( std::move( name ) )
90 , m_svc( svc )
91 , m_evt( IAuditor::Initialize )
92 , // Windows needs an explicit value
93 m_cevt( std::move( evt ) )
94 , m_customEvtType( true ) {
95 i_before();
96 }
97 Gaudi::Guards::AuditorGuard::AuditorGuard( std::string name, IAuditor* svc, IAuditor::StandardEventType evt,
98 const StatusCode& sc )
99 : m_objName( std::move( name ) ), m_svc( svc ), m_evt( evt ), m_sc( &sc ), m_customEvtType( false ) {
100 i_before();
101 }
102 Gaudi::Guards::AuditorGuard::AuditorGuard( std::string name, IAuditor* svc, IAuditor::CustomEventTypeRef evt,
103 const StatusCode& sc )
104 : m_objName( std::move( name ) )
105 , m_svc( svc )
106 , m_evt( IAuditor::Initialize )
107 , // Windows needs an explicit value
108 m_cevt( std::move( evt ) )
109 , m_sc( &sc )
110 , m_customEvtType( true ) {
111 i_before();
112 }
113 // ============================================================================
114 // destructor
115 // ============================================================================
116 Gaudi::Guards::AuditorGuard::~AuditorGuard() { i_after(); }
117 // ============================================================================
119 // ============================================================================
System.h
Gaudi::Guards::ExceptionGuard::handle
void handle(const GaudiException &e, MsgStream &s)
local handler of GaudiException
Definition: Guards.cpp:24
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:21
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:41
IAuditor::StandardEventType
StandardEventType
Defines the standard (= used by the framework) auditable event types.
Definition: IAuditor.h:24
MsgStream.h
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:298
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:67
std
STL namespace.
Gaudi::Guards::ExceptionGuard::~ExceptionGuard
~ExceptionGuard()
destructor
Definition: Guards.cpp:51
Gaudi::Guards::ExceptionGuard::m_sc
StatusCode m_sc
status code : result of function evaluation
Definition: Guards.h:158
std::string
STL class.
MSG::FATAL
Definition: IMessageSvc.h:15
std::exception::what
T what(T... args)
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
GaudiException.h
Guards.h
std::exception
STL class.
GaudiException::code
virtual const StatusCode & code() const
StatusCode for Exception.
Definition: GaudiException.h:76
INamedInterface
IInterface compliant class extending IInterface with the name() method.
Definition: INamedInterface.h:15
Gaudi::Guards::AuditorGuard::AuditorGuard
AuditorGuard()=delete
Gaudi::Guards::AuditorGuard::i_before
void i_before()
Definition: Guards.h:255
Gaudi::Guards::AuditorGuard::~AuditorGuard
~AuditorGuard()
dectructor
Definition: Guards.cpp:116
MSG::ERROR
Definition: IMessageSvc.h:15
IAuditor
The IAuditor is the interface implmented by the AlgAuditor base class.
Definition: IAuditor.h:18
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
IOTest.evt
evt
Definition: IOTest.py:94
Gaudi.Configuration.log
log
Definition: Configuration.py:13