| The Gaudi Framework v28r2p1 (f1a77ff4)

- 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/System.h"
5 #include "GaudiKernel/Bootstrap.h"
6 #include "GaudiKernel/IMessageSvc.h"
7 #include "GaudiKernel/IStatusCodeSvc.h"
8 #include "GaudiKernel/ISvcLocator.h"
9 #include "GaudiKernel/MsgStream.h"
10 #include "GaudiKernel/IssueSeverity.h"
11 #include <fstream>
12 #include <iostream>
13 #include <sstream>
14 #include <stdlib.h>
15 #include <exception>
16
17 bool StatusCode::s_checking(false);
18
19 void StatusCode::enableChecking() {
20 s_checking = true;
21 }
22
23 void StatusCode::disableChecking() {
24 s_checking = false;
25 }
26
27 bool StatusCode::checkingEnabled() {
28 return s_checking;
29 }
30
31 const IssueSeverity& StatusCode::severity() const {
32 static const IssueSeverity dummy;
33 return m_severity ? *m_severity : dummy;
34 }
35
36 void StatusCode::check() {
37
38 if (!m_checked && !GaudiException::s_proc && !std::uncaught_exception() ) {
39
40 auto msg = Gaudi::svcLocator()->as<IMessageSvc>();
41 auto scs = Gaudi::svcLocator()->service<IStatusCodeSvc>("StatusCodeSvc");
42
43 const size_t depth = 21;
44 void* addresses[depth];
45
46 std::string lib, fnc;
47 void* addr = nullptr;
49 if (System::backTrace(addresses, depth)) {
50
51 for(size_t idx: {2, 3}) {
52 if (System::getStackLevel(addresses[idx], addr, fnc, lib) &&
53 fnc != "StatusCode::~StatusCode()") {
54
55 if (scs) {
56 scs->regFnc(fnc, lib);
57 } else {
58 MsgStream log(msg, "StatusCode");
59 log << MSG::WARNING << "Unchecked in " << fnc
60 << " (" << lib << ")" << endmsg;
61 }
62 break;
63 }
64 }
65 }
66 }
67 }
System.h
StatusCode::severity
GAUDI_API const IssueSeverity & severity() const
Severity.
Definition: StatusCode.cpp:31
MsgStream
Definition of the MsgStream class used to transmit messages.
Definition: MsgStream.h:24
IssueSeverity
Definition: IssueSeverity.h:42
StatusCode::check
void check()
Definition: StatusCode.cpp:36
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:177
GaudiException::s_proc
static bool s_proc
"previous" element in the linked list
Definition: GaudiException.h:169
Bootstrap.h
StatusCode::enableChecking
static GAUDI_API void enableChecking()
Definition: StatusCode.cpp:19
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:106
StatusCode::checkingEnabled
static GAUDI_API bool checkingEnabled()
Definition: StatusCode.cpp:27
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:78
Gaudi::svcLocator
GAUDI_API ISvcLocator * svcLocator()
IssueSeverity.h
IMessageSvc
The IMessage is the interface implemented by the message service.
Definition: IMessageSvc.h:57
StatusCode::s_checking
static bool s_checking
Global flag to control if StatusCode need to be checked.
Definition: StatusCode.h:180
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:23
MSG::WARNING
Definition: IMessageSvc.h:20
StatusCode.h
IStatusCodeSvc
Definition: IStatusCodeSvc.h:7
ISvcLocator.h
StatusCode::m_severity
std::shared_ptr< const IssueSeverity > m_severity
Pointer to a IssueSeverity.
Definition: StatusCode.h:178
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Gaudi.Configuration.log
log
Definition: Configuration.py:13