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/MessageCheck.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
*
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
.file =
file
;
74
msg
.line = line;
75
msg
.type =
typeAbort
[
type
] ?
MESSAGE_ABORT
:
MESSAGE_EXCEPTION
;
76
77
std::string mymessage =
typeLiteral
[
type
];
78
mymessage +=
": "
;
79
mymessage +=
error
;
80
msg
.message = mymessage.c_str();
81
82
msg
.send();
83
}
84
85
86
87
TestInvariant ::
88
TestInvariant (
TestInvariantFunction
function,
89
const
void
*
object
)
90
:
m_function
(function),
m_object
(object)
91
{
92
(*m_function) (
m_object
);
93
}
94
95
96
97
TestInvariant ::
98
~TestInvariant ()
99
{
100
(*m_function) (
m_object
);
101
}
102
103
104
105
bool
testInvariantPrint
(
TestInvariantFunction
function,
106
const
void
*
object
)
107
{
108
using namespace
msgRootCoreUtils;
109
110
try
111
{
112
(*function) (object);
113
return
false
;
114
}
catch
(std::exception& e)
115
{
116
ANA_MSG_ERROR
(
"caught exception in invariant test: "
<< e.what());
117
return
true
;
118
};
119
}
120
}
121
}
Assert.h
RCU_REQUIRE
#define RCU_REQUIRE(x)
Definition
Assert.h:196
ANA_MSG_ERROR
#define ANA_MSG_ERROR(xmsg,...)
Macro printing error messages.
Definition
Control/AthToolSupport/AsgMessaging/AsgMessaging/MessageCheck.h:295
MessageCheck.h
Message.h
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:67
RCU::Check::testInvariantPrint
bool testInvariantPrint(TestInvariantFunction function, const void *object)
Definition
Assert.cxx:105
RCU::Check::Type
Type
Definition
Assert.h:48
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:90
RCU::Check::typeLiteral
const char *const typeLiteral[typeNum]
Definition
Assert.cxx:26
RCU::Check::fail
void fail(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
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:31
RCU::MESSAGE_EXCEPTION
@ MESSAGE_EXCEPTION
description: send out an exception
Definition
MessageType.h:28
error
Definition
IImpactPoint3dEstimator.h:72
type
RCU::Check::TestInvariant::m_object
const void * m_object
Definition
Assert.h:111
RCU::Check::TestInvariant::m_function
TestInvariantFunction m_function
Definition
Assert.h:110
RCU::Message
Definition
PhysicsAnalysis/D3PDTools/RootCoreUtils/RootCoreUtils/Message.h:15
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