| The Gaudi Framework v30r0 (c919700c)

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

- File List
- File Members

StatusCode.cpp
Go to the documentation of this file.
1 #define GAUDIKERNEL_STATUSCODE_CPP 1
2
3 #include "GaudiKernel/StatusCode.h"
4 #include "GaudiKernel/Bootstrap.h"
5 #include "GaudiKernel/IMessageSvc.h"
6 #include "GaudiKernel/IStatusCodeSvc.h"
7 #include "GaudiKernel/ISvcLocator.h"
8 #include "GaudiKernel/MsgStream.h"
9 #include "GaudiKernel/System.h"
10 #include <exception>
11 #include <fstream>
12 #include <iostream>
13 #include <sstream>
14 #include <stdlib.h>
15
16 bool StatusCode::s_checking( false );
17
18 void StatusCode::enableChecking() { s_checking = true; }
19
20 void StatusCode::disableChecking() { s_checking = false; }
21
22 bool StatusCode::checkingEnabled() { return s_checking; }
23
24 void StatusCode::check()
25 {
26
27 if ( !m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
28
29 auto msg = Gaudi::svcLocator()->as<IMessageSvc>();
30 auto scs = Gaudi::svcLocator()->service<IStatusCodeSvc>( "StatusCodeSvc" );
31
32 const size_t depth = 21;
33 void* addresses[depth];
34
35 std::string lib, fnc;
36 void* addr = nullptr;
38 if ( System::backTrace( addresses, depth ) ) {
39
40 for ( size_t idx : {2, 3} ) {
41 if ( System::getStackLevel( addresses[idx], addr, fnc, lib ) && fnc != "StatusCode::~StatusCode()" ) {
42
43 if ( scs ) {
44 scs->regFnc( fnc, lib );
45 } else {
46 MsgStream log( msg, "StatusCode" );
47 log << MSG::WARNING << "Unchecked in " << fnc << " (" << lib << ")" << endmsg;
48 }
49 break;
50 }
51 }
52 }
53 }
54 }
System.h
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
StatusCode::check
void check()
Definition: StatusCode.cpp:24
MsgStream.h
System::getStackLevel
GAUDI_API bool getStackLevel(void *addresses, void *&addr, std::string &fnc, std::string &lib)
StatusCode::m_checked
bool m_checked
If the Status code has been checked.
Definition: StatusCode.h:155
GaudiException::s_proc
static bool s_proc
"previous" element in the linked list
Definition: GaudiException.h:178
Bootstrap.h
StatusCode::enableChecking
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:18
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
StatusCode::checkingEnabled
static GAUDI_API bool checkingEnabled()
Definition: StatusCode.cpp:22
System::backTrace
GAUDI_API int backTrace(void **addresses, const int depth)
IStatusCodeSvc.h
std::string
STL class.
ISvcLocator::service
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:79
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:38
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:157
IMessageSvc.h
std::uncaught_exception
T uncaught_exception(T...args)
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:8
StatusCode::disableChecking
static GAUDI_API void disableChecking()
Definition: StatusCode.cpp:20
MSG::WARNING
Definition: IMessageSvc.h:16
StatusCode.h
IStatusCodeSvc
Definition: IStatusCodeSvc.h:7
ISvcLocator.h
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
Gaudi.Configuration.log
log
Definition: Configuration.py:13