ATLAS Offline Software
Loading...
Searching...
No Matches
RCU::Check Namespace Reference

Classes

struct  TestInvariant

Typedefs

typedef void(* TestInvariantFunction) (const void *object)
 effects: apply the test invariant method on an object guarantee: no-fail availability: experts only rationale: this is a templated wrapper for the class specific invariant testers

Enumerations

enum  Type {
  assert_soft , assert_hard , assert_noimp , require_soft ,
  require_hard , require_noimp , provide_soft , provide_hard ,
  provide_noimp , invariant
}

Functions

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: as requested requires: file != 0 requires: line != 0 requires: type < typeNum requires: error != 0 availability: experts only
bool testInvariantPrint (TestInvariantFunction function, const void *object)
template<class T>
void testInvariantVoid (const void *object)
template<class T>
TestInvariant invariant_tester (T *object)
 effects: create the right invariant testing object returns: the tester

Variables

const char *const typeLiteral [typeNum]
const bool typeAbort [typeNum]
const int typeNum = invariant + 1

Typedef Documentation

◆ TestInvariantFunction

typedef void(* RCU::Check::TestInvariantFunction) (const void *object)

effects: apply the test invariant method on an object guarantee: no-fail availability: experts only rationale: this is a templated wrapper for the class specific invariant testers

Definition at line 90 of file Assert.h.

Enumeration Type Documentation

◆ Type

Enumerator
assert_soft 

regular old style assertion

assert_hard 
assert_noimp 
require_soft 

function parameter requirement

require_hard 
require_noimp 
provide_soft 

function postcondition

provide_hard 
provide_noimp 
invariant 

invariant violation

Definition at line 47 of file Assert.h.

48 {
53
58
63
66 };
@ require_hard
Definition Assert.h:56
@ provide_noimp
Definition Assert.h:62
@ require_soft
function parameter requirement
Definition Assert.h:55
@ invariant
invariant violation
Definition Assert.h:65
@ require_noimp
Definition Assert.h:57
@ assert_hard
Definition Assert.h:51
@ assert_noimp
Definition Assert.h:52
@ assert_soft
regular old style assertion
Definition Assert.h:50
@ provide_soft
function postcondition
Definition Assert.h:60
@ provide_hard
Definition Assert.h:61

Function Documentation

◆ fail()

void RCU::Check::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: as requested requires: file != 0 requires: line != 0 requires: type < typeNum requires: error != 0 availability: experts only

Definition at line 64 of file Assert.cxx.

66 {
67 RCU_REQUIRE (file != 0);
68 RCU_REQUIRE (line != 0);
70 RCU_REQUIRE (error != 0);
71
73 msg.file = file;
74 msg.line = line;
76
77 std::string mymessage = typeLiteral[type];
78 mymessage += ": ";
79 mymessage += error;
80 msg.message = mymessage.c_str();
81
82 msg.send();
83 }
#define RCU_REQUIRE(x)
Definition Assert.h:196
const bool typeAbort[typeNum]
Definition Assert.cxx:45
const int typeNum
Definition Assert.h:67
const char *const typeLiteral[typeNum]
Definition Assert.cxx:26
@ MESSAGE_ABORT
description: print and abort
Definition MessageType.h:31
@ MESSAGE_EXCEPTION
description: send out an exception
Definition MessageType.h:28
MsgStream & msg
Definition testRead.cxx:32
TFile * file

◆ invariant_tester()

template<class T>
TestInvariant RCU::Check::invariant_tester ( T * object)
inline

effects: create the right invariant testing object returns: the tester

Definition at line 118 of file Assert.h.

119 {
120 return TestInvariant (testInvariantVoid<T>, object);
121 }
void testInvariantVoid(const void *object)
Definition Assert.h:92

◆ testInvariantPrint()

bool RCU::Check::testInvariantPrint ( TestInvariantFunction function,
const void * object )

Definition at line 105 of file Assert.cxx.

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 }
#define ANA_MSG_ERROR(xmsg)
Macro printing error messages.

◆ testInvariantVoid()

template<class T>
void RCU::Check::testInvariantVoid ( const void * object)

Definition at line 92 of file Assert.h.

93 {
94 static_cast<const T *>(object)->testInvariant ();
95 }

Variable Documentation

◆ typeAbort

const bool RCU::Check::typeAbort
Initial value:
=
{
false,
true,
true,
false,
true,
true,
false,
true,
true,
true,
}

Definition at line 45 of file Assert.cxx.

45 {
46 false,
47 true,
48 true,
49
50 false,
51 true,
52 true,
53
54 false,
55 true,
56 true,
57
58 true,
59 };

◆ typeLiteral

const char *const RCU::Check::typeLiteral
Initial value:
=
{
"assertion failed",
"assertion failed",
"assertion failed",
"requirement failed",
"requirement failed",
"requirement failed",
"postcondition violated",
"postcondition violated",
"postcondition violated",
"invariant violated"
}

Definition at line 26 of file Assert.cxx.

26 {
27 "assertion failed",
28 "assertion failed",
29 "assertion failed",
30
31 "requirement failed",
32 "requirement failed",
33 "requirement failed",
34
35 "postcondition violated",
36 "postcondition violated",
37 "postcondition violated",
38
39 "invariant violated"
40 };

◆ typeNum

const int RCU::Check::typeNum = invariant + 1

Definition at line 67 of file Assert.h.