Gaudi Framework, version v24r2
Home
Generated: Wed Dec 4 2013
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
GaudiKernel
GaudiKernel
StatusCode.h
Go to the documentation of this file.
1
// $Id: StatusCode.h,v 1.12 2008/10/28 17:21:58 marcocle Exp $
2
#ifndef GAUDIKERNEL_STATUSCODE_H
3
#define GAUDIKERNEL_STATUSCODE_H
4
5
#include <
ostream
>
6
7
#include "
GaudiKernel/Kernel.h
"
8
#include "
GaudiKernel/IssueSeverity.h
"
9
#include "boost/shared_ptr.hpp"
10
21
class
IMessageSvc
;
22
class
IStatusCodeSvc
;
23
24
class
IgnoreError
{};
25
26
class
StatusCode
{
27
public
:
28
enum
{
29
FAILURE
= 0,
30
SUCCESS
= 1,
31
RECOVERABLE
= 2
32
};
33
35
StatusCode
():
36
d_code
(
SUCCESS
),
m_checked
(false),
m_severity
() {}
37
StatusCode
(
unsigned
long
code,
const
IssueSeverity
& sev ):
38
d_code
(code),
m_checked
(false),
m_severity
() {
39
try
{
// ensure that we do not throw even if the we cannot copy the severity
40
m_severity
=
SeverityPtr
(
new
IssueSeverity
(sev));
41
}
42
catch
(...) {}
43
}
44
StatusCode
(
unsigned
long
code,
bool
checked =
false
):
45
d_code
(code),
m_checked
(checked),
m_severity
() {}
46
47
StatusCode
(
const
StatusCode
& rhs ):
48
d_code
(rhs.
d_code
),
m_checked
(rhs.
m_checked
),
49
m_severity
(rhs.
m_severity
)
50
{ rhs.
m_checked
=
true
; }
51
53
GAUDI_API
~StatusCode
();
54
58
bool
isSuccess
()
const
{
59
m_checked
=
true
;
60
return
(
d_code
==
SUCCESS
);
61
}
62
68
bool
isFailure
()
const
{
return
!
isSuccess
(); }
69
bool
isRecoverable
()
const
{
70
m_checked
=
true
;
71
return
(
d_code
==
RECOVERABLE
);
72
}
73
75
unsigned
long
getCode
()
const
{
76
m_checked
=
true
;
77
return
d_code
;
78
}
79
81
void
setCode
(
unsigned
long
value) {
82
m_checked
=
false
;
83
d_code
= value;
84
}
85
87
void
setChecked
()
const
{
88
m_checked
=
true
;
89
}
90
void
ignore
()
const
{
setChecked
(); }
91
93
operator
unsigned
long()
const
{
return
getCode
(); }
94
96
GAUDI_API
const
IssueSeverity
&
severity
()
const
;
97
99
StatusCode
&
operator=
(
unsigned
long
value) {
100
setCode
(value);
101
return
*
this
;
102
}
103
StatusCode
&
operator=
(
const
StatusCode
& rhs){
104
if
(
this
== &rhs)
return
*
this
;
// Protection against self-assignment
105
d_code
= rhs.
d_code
;
106
m_checked
= rhs.
m_checked
;
107
rhs.
m_checked
=
true
;
108
m_severity
= rhs.
m_severity
;
109
return
*
this
;
110
}
111
113
friend
bool
operator<
(
const
StatusCode
& a,
const
StatusCode
& b ) {
114
return
a.
d_code
< b.
d_code
;
115
}
116
118
friend
bool
operator>
(
const
StatusCode
& a,
const
StatusCode
& b ) {
119
return
a.
d_code
> b.
d_code
;
120
}
121
122
#ifndef _WIN32
123
operator
IgnoreError
()
const
{
124
m_checked
=
true
;
125
return
IgnoreError
();
126
}
127
#endif
128
129
static
GAUDI_API
void
enableChecking
();
130
static
GAUDI_API
void
disableChecking
();
131
132
protected
:
134
unsigned
long
d_code
;
135
mutable
bool
m_checked
;
136
typedef
boost::shared_ptr<IssueSeverity>
SeverityPtr
;
137
SeverityPtr
m_severity
;
138
139
static
bool
s_checking
;
140
};
141
142
inline
std::ostream
&
operator<<
(
std::ostream
&
s
,
const
StatusCode
&
sc
)
143
{
144
if
( sc.
isSuccess
() ) {
return
s <<
"SUCCESS"
; }
145
else
if
( sc.
isRecoverable
() ) {
return
s <<
"RECOVERABLE"
; }
146
s <<
"FAILURE"
;
147
if
(
StatusCode::FAILURE
!= sc.
getCode
() )
148
{ s <<
"("
<< sc.
getCode
() <<
")"
;}
149
return
s
;
150
}
151
152
#endif // GAUDIKERNEL_STATUSCODES_H
153
154
155
Generated at Wed Dec 4 2013 14:33:09 for Gaudi Framework, version v24r2 by
Doxygen
version 1.8.2 written by
Dimitri van Heesch
, © 1997-2004