Gaudi Framework, version v25r2
Home
Generated: Wed Jun 4 2014
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
.cern.ch
sw
Gaudi
releases
GAUDI
GAUDI_v25r2
GaudiKernel
GaudiKernel
StatusCode.h
Go to the documentation of this file.
1
#ifndef GAUDIKERNEL_STATUSCODE_H
2
#define GAUDIKERNEL_STATUSCODE_H
3
4
#include <ostream>
5
6
#include "
GaudiKernel/Kernel.h
"
7
#include "
GaudiKernel/IssueSeverity.h
"
8
9
#if defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
10
#include <memory>
11
#else
12
#include "boost/shared_ptr.hpp"
13
#endif
14
25
class
IMessageSvc
;
26
class
IStatusCodeSvc
;
27
28
class
IgnoreError
{};
29
30
class
StatusCode
{
31
public
:
32
enum
{
33
FAILURE
= 0,
34
SUCCESS
= 1,
35
RECOVERABLE
= 2
36
};
37
39
StatusCode
():
40
d_code
(
SUCCESS
),
m_checked
(false),
m_severity
() {}
41
StatusCode
(
unsigned
long
code,
const
IssueSeverity
& sev ):
42
d_code
(code),
m_checked
(false),
m_severity
() {
43
try
{
// ensure that we do not throw even if the we cannot copy the severity
44
m_severity
=
SeverityPtr
(
new
IssueSeverity
(sev));
45
}
46
catch
(...) {}
47
}
48
StatusCode
(
unsigned
long
code,
bool
checked =
false
):
49
d_code
(code),
m_checked
(checked),
m_severity
() {}
50
51
StatusCode
(
const
StatusCode
& rhs ):
52
d_code
(rhs.
d_code
),
m_checked
(rhs.
m_checked
),
53
m_severity
(rhs.
m_severity
)
54
{ rhs.
m_checked
=
true
; }
55
57
GAUDI_API
~StatusCode
();
58
62
bool
isSuccess
()
const
{
63
m_checked
=
true
;
64
return
(
d_code
==
SUCCESS
);
65
}
66
72
bool
isFailure
()
const
{
return
!
isSuccess
(); }
73
bool
isRecoverable
()
const
{
74
m_checked
=
true
;
75
return
(
d_code
==
RECOVERABLE
);
76
}
77
79
unsigned
long
getCode
()
const
{
80
m_checked
=
true
;
81
return
d_code
;
82
}
83
85
void
setCode
(
unsigned
long
value) {
86
m_checked
=
false
;
87
d_code
= value;
88
}
89
91
void
setChecked
()
const
{
92
m_checked
=
true
;
93
}
94
void
ignore
()
const
{
setChecked
(); }
95
97
operator
unsigned
long()
const
{
return
getCode
(); }
98
100
GAUDI_API
const
IssueSeverity
&
severity
()
const
;
101
103
StatusCode
&
operator=
(
unsigned
long
value) {
104
setCode
(value);
105
return
*
this
;
106
}
107
StatusCode
&
operator=
(
const
StatusCode
& rhs){
108
if
(
this
== &rhs)
return
*
this
;
// Protection against self-assignment
109
d_code
= rhs.
d_code
;
110
m_checked
= rhs.
m_checked
;
111
rhs.
m_checked
=
true
;
112
m_severity
= rhs.
m_severity
;
113
return
*
this
;
114
}
115
117
friend
bool
operator<
(
const
StatusCode
& a,
const
StatusCode
& b ) {
118
return
a.
d_code
< b.
d_code
;
119
}
120
122
friend
bool
operator>
(
const
StatusCode
& a,
const
StatusCode
& b ) {
123
return
a.
d_code
> b.
d_code
;
124
}
125
126
#ifndef _WIN32
127
operator
IgnoreError
()
const
{
128
m_checked
=
true
;
129
return
IgnoreError
();
130
}
131
#endif
132
133
static
GAUDI_API
void
enableChecking
();
134
static
GAUDI_API
void
disableChecking
();
135
136
protected
:
138
unsigned
long
d_code
;
139
mutable
bool
m_checked
;
140
#if defined(__GCCXML__)
141
// This is because GCCXML needs to see something that is not too in conflict with
142
// boost or std
143
typedef
IssueSeverity
*
SeverityPtr
;
144
#elif defined(__GXX_EXPERIMENTAL_CXX0X__) || __cplusplus >= 201103L
145
typedef
std::shared_ptr<IssueSeverity>
SeverityPtr
;
146
#else
147
typedef
boost::shared_ptr<IssueSeverity>
SeverityPtr
;
148
#endif
149
SeverityPtr
m_severity
;
150
151
static
bool
s_checking
;
152
};
153
154
inline
std::ostream&
operator<<
( std::ostream&
s
,
const
StatusCode
&
sc
)
155
{
156
if
( sc.
isSuccess
() ) {
return
s <<
"SUCCESS"
; }
157
else
if
( sc.
isRecoverable
() ) {
return
s <<
"RECOVERABLE"
; }
158
s <<
"FAILURE"
;
159
if
(
StatusCode::FAILURE
!= sc.
getCode
() )
160
{ s <<
"("
<< sc.
getCode
() <<
")"
;}
161
return
s
;
162
}
163
164
#endif // GAUDIKERNEL_STATUSCODES_H
165
166
167
Generated at Wed Jun 4 2014 14:48:57 for Gaudi Framework, version v25r2 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004