ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
D3PDTools
RootCoreUtils
Root
Assert.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
6
7
//
8
// includes
9
//
10
11
#include <
RootCoreUtils/Assert.h
>
12
13
#include <cstdlib>
14
#include <string>
15
#include <
RootCoreUtils/Message.h
>
16
#include <
RootCoreUtils/PrintMsg.h
>
17
18
//
19
// method implementations
20
//
21
22
namespace
RCU
23
{
24
namespace
Check
25
{
26
const
char
*
const
typeLiteral
[
typeNum
] =
27
{
28
"assertion failed"
,
29
"assertion failed"
,
30
"assertion failed"
,
31
32
"requirement failed"
,
33
"requirement failed"
,
34
"requirement failed"
,
35
36
"postcondition violated"
,
37
"postcondition violated"
,
38
"postcondition violated"
,
39
40
"invariant violated"
41
};
42
43
44
45
const
bool
typeAbort
[
typeNum
] =
46
{
47
false
,
48
true
,
49
true
,
50
51
false
,
52
true
,
53
true
,
54
55
false
,
56
true
,
57
true
,
58
59
true
,
60
};
61
62
63
64
void
fail
(
const
char
*package,
const
char
*
file
,
unsigned
line,
65
Type
type
,
const
char
*
error
)
66
{
67
RCU_REQUIRE
(
file
!= 0);
68
RCU_REQUIRE
(line != 0);
69
RCU_REQUIRE
(
type
<
typeNum
);
70
RCU_REQUIRE
(
error
!= 0);
71
72
Message
msg
;
73
msg
.package = package;
74
msg
.file =
file
;
75
msg
.line = line;
76
msg
.type =
typeAbort
[
type
] ?
MESSAGE_ABORT
:
MESSAGE_EXCEPTION
;
77
78
std::string mymessage =
typeLiteral
[
type
];
79
mymessage +=
": "
;
80
mymessage +=
error
;
81
msg
.message = mymessage.c_str();
82
83
msg
.send();
84
}
85
86
87
88
TestInvariant ::
89
TestInvariant (
TestInvariantFunction
function,
90
const
void
*
object
)
91
:
m_function
(function),
m_object
(object)
92
{
93
(*m_function) (
m_object
);
94
}
95
96
97
98
TestInvariant ::
99
~TestInvariant ()
100
{
101
(*m_function) (
m_object
);
102
}
103
104
105
106
bool
testInvariantPrint
(
TestInvariantFunction
function,
107
const
void
*
object
)
108
{
109
try
110
{
111
(*function) (object);
112
return
false
;
113
}
catch
(std::exception& e)
114
{
115
RCU_ERROR_MSG
(e.what());
116
return
true
;
117
};
118
}
119
}
120
}
Assert.h
RCU_REQUIRE
#define RCU_REQUIRE(x)
Definition
Assert.h:203
Message.h
PrintMsg.h
RCU_ERROR_MSG
#define RCU_ERROR_MSG(message)
Definition
PrintMsg.h:50
RCU::Check
Definition
Assert.cxx:25
RCU::Check::typeAbort
const bool typeAbort[typeNum]
Definition
Assert.cxx:45
RCU::Check::typeNum
const int typeNum
Definition
Assert.h:70
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:64
RCU::Check::testInvariantPrint
bool testInvariantPrint(TestInvariantFunction function, const void *object)
Definition
Assert.cxx:106
RCU::Check::Type
Type
Definition
Assert.h:51
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:93
RCU::Check::typeLiteral
const char *const typeLiteral[typeNum]
Definition
Assert.cxx:26
RCU
This module defines a variety of assert style macros.
Definition
Assert.cxx:23
RCU::MESSAGE_ABORT
@ MESSAGE_ABORT
description: print and abort
Definition
MessageType.h:33
RCU::MESSAGE_EXCEPTION
@ MESSAGE_EXCEPTION
description: send out an exception
Definition
MessageType.h:30
error
Definition
IImpactPoint3dEstimator.h:72
type
RCU::Check::TestInvariant::m_object
const void * m_object
Definition
Assert.h:114
RCU::Check::TestInvariant::m_function
TestInvariantFunction m_function
Definition
Assert.h:113
RCU::Message
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:17
msg
MsgStream & msg
Definition
testRead.cxx:32
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0