ATLAS Offline Software
PhysicsAnalysis
D3PDTools
RootCoreUtils
Root
Assert.cxx
Go to the documentation of this file.
1
// - 2012.
2
// Distributed under the Boost Software License, Version 1.0.
3
// (See accompanying file LICENSE_1_0.txt or copy at
4
// http://www.boost.org/LICENSE_1_0.txt)
5
6
// Please feel free to contact me (krumnack@iastate.edu) for bug
7
// reports, feature suggestions, praise and complaints.
8
9
10
//
11
// includes
12
//
13
14
#include <
RootCoreUtils/Assert.h
>
15
16
#include <cstdlib>
17
#include <string>
18
#include <
RootCoreUtils/Message.h
>
19
#include <
RootCoreUtils/PrintMsg.h
>
20
21
//
22
// method implementations
23
//
24
25
namespace
RCU
26
{
27
namespace
Check
28
{
29
const
char
*
const
typeLiteral
[
typeNum
] =
30
{
31
"assertion failed"
,
32
"assertion failed"
,
33
"assertion failed"
,
34
35
"requirement failed"
,
36
"requirement failed"
,
37
"requirement failed"
,
38
39
"postcondition violated"
,
40
"postcondition violated"
,
41
"postcondition violated"
,
42
43
"invariant violated"
44
};
45
46
47
48
const
bool
typeAbort
[
typeNum
] =
49
{
50
false
,
51
true
,
52
true
,
53
54
false
,
55
true
,
56
true
,
57
58
false
,
59
true
,
60
true
,
61
62
true
,
63
};
64
65
66
67
void
fail
(
const
char
*package,
const
char
*
file
,
unsigned
line
,
68
Type
type
,
const
char
*
error
)
69
{
70
RCU_REQUIRE
(
file
!= 0);
71
RCU_REQUIRE
(
line
!= 0);
72
RCU_REQUIRE
(
type
<
typeNum
);
73
RCU_REQUIRE
(
error
!= 0);
74
75
Message
msg
;
76
msg
.package = package;
77
msg
.file =
file
;
78
msg
.line =
line
;
79
msg
.type =
typeAbort
[
type
] ?
MESSAGE_ABORT
:
MESSAGE_EXCEPTION
;
80
81
std::string mymessage =
typeLiteral
[
type
];
82
mymessage +=
": "
;
83
mymessage +=
error
;
84
msg
.message = mymessage.c_str();
85
86
msg
.send();
87
}
88
89
90
91
TestInvariant ::
92
TestInvariant
(
TestInvariantFunction
function
,
93
const
void
*
object
)
94
: m_function (function), m_object (
object
)
95
{
96
(*m_function) (
m_object
);
97
}
98
99
100
101
TestInvariant ::
102
~TestInvariant
()
103
{
104
(*m_function) (
m_object
);
105
}
106
107
108
109
bool
testInvariantPrint
(
TestInvariantFunction
function
,
110
const
void
*
object
)
111
{
112
try
113
{
114
(*function) (
object
);
115
return
false
;
116
}
catch
(
std::exception
&
e
)
117
{
118
RCU_ERROR_MSG
(
e
.what());
119
return
true
;
120
};
121
}
122
}
123
}
RCU_ERROR_MSG
#define RCU_ERROR_MSG(message)
Definition:
PrintMsg.h:55
RCU::Check::TestInvariant::~TestInvariant
~TestInvariant()
Definition:
Assert.cxx:102
AllowedVariables::e
e
Definition:
AsgElectronSelectorTool.cxx:37
checkFileSG.line
line
Definition:
checkFileSG.py:75
RCU_REQUIRE
#define RCU_REQUIRE(x)
Definition:
Assert.h:208
RCU::Check::fail
void fail(const char *package, const char *file, unsigned line, Type type, const char *error)
effects: report the error and abort either by exception or assert like guarantee: all-fail failures: ...
Definition:
Assert.cxx:67
RCU::Check::typeLiteral
const char *const typeLiteral[typeNum]
Definition:
Assert.cxx:29
RCU
This module defines a variety of assert style macros.
Definition:
Assert.cxx:26
Assert.h
Message.h
RCU::Check::TestInvariant::TestInvariant
TestInvariant(TestInvariantFunction function, const void *object)
availability: experts only description: this class will perform an invariant test as the object goes ...
Definition:
Assert.cxx:92
calibdata.exception
exception
Definition:
calibdata.py:496
file
TFile * file
Definition:
tile_monitor.h:29
RCU::MESSAGE_EXCEPTION
@ MESSAGE_EXCEPTION
description: send out an exception
Definition:
MessageType.h:35
RCU::Check::typeAbort
const bool typeAbort[typeNum]
Definition:
Assert.cxx:48
xAODType
Definition:
ObjectType.h:13
RCU::Check::typeNum
const int typeNum
Definition:
Assert.h:75
RCU::Check::TestInvariantFunction
void(* TestInvariantFunction)(const void *object)
effects: apply the test invariant method on an object guarantee: no-fail availability: experts only r...
Definition:
Assert.h:98
RCU::Check::testInvariantPrint
bool testInvariantPrint(TestInvariantFunction function, const void *object)
Definition:
Assert.cxx:109
RCU::Message
Definition:
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:26
python.CaloScaleNoiseConfig.type
type
Definition:
CaloScaleNoiseConfig.py:78
RCU::MESSAGE_ABORT
@ MESSAGE_ABORT
description: print and abort
Definition:
MessageType.h:38
pickleTool.object
object
Definition:
pickleTool.py:30
RCU::Check::TestInvariant::m_object
const void * m_object
Definition:
Assert.h:119
get_generator_info.error
error
Definition:
get_generator_info.py:40
error
Definition:
IImpactPoint3dEstimator.h:70
python.AutoConfigFlags.msg
msg
Definition:
AutoConfigFlags.py:7
PrintMsg.h
Generated on Sun Dec 22 2024 21:07:07 for ATLAS Offline Software by
1.8.18