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 *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: 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 93 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 50 of file Assert.h.

51 {
56
61
66
69 };
@ require_hard
Definition Assert.h:59
@ provide_noimp
Definition Assert.h:65
@ require_soft
function parameter requirement
Definition Assert.h:58
@ invariant
invariant violation
Definition Assert.h:68
@ require_noimp
Definition Assert.h:60
@ assert_hard
Definition Assert.h:54
@ assert_noimp
Definition Assert.h:55
@ assert_soft
regular old style assertion
Definition Assert.h:53
@ provide_soft
function postcondition
Definition Assert.h:63
@ provide_hard
Definition Assert.h:64

Function Documentation

◆ fail()

void RCU::Check::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: 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.package = package;
74 msg.file = file;
75 msg.line = line;
77
78 std::string mymessage = typeLiteral[type];
79 mymessage += ": ";
80 mymessage += error;
81 msg.message = mymessage.c_str();
82
83 msg.send();
84 }
#define RCU_REQUIRE(x)
Definition Assert.h:203
const bool typeAbort[typeNum]
Definition Assert.cxx:45
const int typeNum
Definition Assert.h:70
const char *const typeLiteral[typeNum]
Definition Assert.cxx:26
@ MESSAGE_ABORT
description: print and abort
Definition MessageType.h:33
@ MESSAGE_EXCEPTION
description: send out an exception
Definition MessageType.h:30
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 121 of file Assert.h.

122 {
123 return TestInvariant (testInvariantVoid<T>, object);
124 }
void testInvariantVoid(const void *object)
Definition Assert.h:95

◆ testInvariantPrint()

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

Definition at line 106 of file Assert.cxx.

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 }
#define RCU_ERROR_MSG(message)
Definition PrintMsg.h:50

◆ testInvariantVoid()

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

Definition at line 95 of file Assert.h.

96 {
97 static_cast<const T *>(object)->testInvariant ();
98 }

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 70 of file Assert.h.