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

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

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 67 of file Assert.cxx.

69 {
70 RCU_REQUIRE (file != 0);
71 RCU_REQUIRE (line != 0);
73 RCU_REQUIRE (error != 0);
74
76 msg.package = package;
77 msg.file = file;
78 msg.line = line;
80
81 std::string mymessage = typeLiteral[type];
82 mymessage += ": ";
83 mymessage += error;
84 msg.message = mymessage.c_str();
85
86 msg.send();
87 }
#define RCU_REQUIRE(x)
Definition Assert.h:208
const bool typeAbort[typeNum]
Definition Assert.cxx:48
const int typeNum
Definition Assert.h:75
const char *const typeLiteral[typeNum]
Definition Assert.cxx:29
@ MESSAGE_ABORT
description: print and abort
Definition MessageType.h:38
@ MESSAGE_EXCEPTION
description: send out an exception
Definition MessageType.h:35
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 126 of file Assert.h.

127 {
128 return TestInvariant (testInvariantVoid<T>, object);
129 }
void testInvariantVoid(const void *object)
Definition Assert.h:100

◆ testInvariantPrint()

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

Definition at line 109 of file Assert.cxx.

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

◆ testInvariantVoid()

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

Definition at line 100 of file Assert.h.

101 {
102 static_cast<const T *>(object)->testInvariant ();
103 }

Variable Documentation

◆ typeAbort

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

Definition at line 48 of file Assert.cxx.

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 };

◆ 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 29 of file Assert.cxx.

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 };

◆ typeNum

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

Definition at line 75 of file Assert.h.