BOSS
8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Precondition.cxx
Go to the documentation of this file.
1
/*
2
* Precondition.cxx
3
* ers
4
*
5
* Created by Matthias Wiesmann on 08.12.04.
6
* Copyright 2004 CERN. All rights reserved.
7
*
8
*/
9
10
#include "ers/Precondition.h"
11
#include <iostream>
12
#include <sstream>
13
14
const
char
*
const
ers::Precondition::PRECONDITION_CLASS
=
"ers::Precondition"
;
15
16
namespace
{
17
ers::Issue
* create_issue() {
return
new
ers::Precondition
(); }
18
bool
registered =
ers::IssueFactory::instance
()->
register_issue
(
19
ers::Precondition::PRECONDITION_CLASS
, create_issue );
20
}
// namespace
21
22
/** Constructor used by deserialisation
23
*/
24
25
ers::Precondition::Precondition
() :
Assertion
() {}
26
27
/** Constructor used by subclasses
28
* \param c context of the issue
29
* \param s severity_t of the issue
30
* \param c context of the issue
31
*/
32
33
ers::Precondition::Precondition
(
const
Context
& c,
severity_t
s
) :
Assertion
( c,
s
) {}
34
35
/** Main constructor, it should be used for building Precondition Issues
36
* \param context context of the issue
37
* \param s severity_t of the issue
38
* \param condition text of the condition of the precondition
39
* \param msg message for condition
40
* \param constant_expression does compiler think expression is constant
41
*/
42
43
ers::Precondition::Precondition
(
const
Context
& context,
severity_t
s
,
const
char
* condition,
44
const
std::string& msg,
bool
constant_expression )
45
:
Assertion
( context,
s
) {
46
this->
setup
( condition, msg, constant_expression );
47
}
// Precondition
48
49
/** \return name key for the class */
50
51
const
char
*
ers::Precondition::get_class_name
()
const
throw() {
return
PRECONDITION_CLASS
; }
52
53
/** Builds the message associated with an assertion
54
* \param condition_text the condition in textual form
55
* \param msg the message associated with the condition
56
* \param constant_expression is the condition constant (as detected by compiler).
57
* \return message describing the failure of the assertion
58
*/
59
60
std::string
ers::Precondition::build_message
(
const
char
* condition_text,
61
const
std::string& msg,
62
bool
constant_expression )
throw
() {
63
std::ostringstream m;
64
m <<
"Precondition '"
<< condition_text <<
"' failed: "
<< msg;
65
if
( constant_expression ) { m <<
" (this condition is constant)"
; }
// constant expression
66
return
m.str();
67
}
// build_message
s
XmlRpcServer s
Definition
HelloServer.cpp:11
ers::Assertion::setup
void setup(const char *condition, const std::string &message, bool constant_expression)
Definition
Event/ers/src/Assertion.cxx:58
ers::Assertion::Assertion
Assertion(const Context &context, severity_t s)
Definition
Event/ers/src/Assertion.cxx:39
ers::Context
Source context for Issue.
Definition
Event/ers/include/ers/Context.h:41
ers::IssueFactory::register_issue
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
Definition
IssueFactory.cxx:44
ers::IssueFactory::instance
static IssueFactory * instance()
method to access singleton
Definition
IssueFactory.cxx:28
ers::Issue
Root Issue class.
Definition
Event/ers/include/ers/Issue.h:37
ers::Precondition
Precondition issue.
Definition
Event/ers/include/ers/Precondition.h:22
ers::Precondition::Precondition
Precondition()
Definition
Precondition.cxx:25
ers::Precondition::build_message
virtual std::string build_message(const char *condition_text, const std::string &message, bool constant_expression=false)
Definition
Precondition.cxx:60
ers::Precondition::get_class_name
virtual const char * get_class_name() const
Definition
Precondition.cxx:51
ers::Precondition::PRECONDITION_CLASS
static const char *const PRECONDITION_CLASS
Definition
Event/ers/include/ers/Precondition.h:29
ers::severity_t
enum ers::_severity_t severity_t
8.0.0
BOSS_Source
Event
ers
src
Precondition.cxx
Generated by
1.16.1