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
14const char* const ers::Precondition::PRECONDITION_CLASS = "ers::Precondition";
15
16namespace {
17 ers::Issue* create_issue() { return new ers::Precondition(); }
20} // namespace
21
22/** Constructor used by deserialisation
23 */
24
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
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
43ers::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
51const 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
60std::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
XmlRpcServer s
void setup(const char *condition, const std::string &message, bool constant_expression)
Assertion(const Context &context, severity_t s)
Source context for Issue.
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
static IssueFactory * instance()
method to access singleton
Root Issue class.
virtual std::string build_message(const char *condition_text, const std::string &message, bool constant_expression=false)
virtual const char * get_class_name() const
static const char *const PRECONDITION_CLASS
enum ers::_severity_t severity_t