BOSS 7.0.3
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(); }
19} // anonymous context
20
21/** Constructor used by deserialisation
22 */
23
25
26/** Constructor used by subclasses
27 * \param c context of the issue
28 * \param s severity_t of the issue
29 * \param c context of the issue
30 */
31
33
34/** Main constructor, it should be used for building Precondition Issues
35 * \param context context of the issue
36 * \param s severity_t of the issue
37 * \param condition text of the condition of the precondition
38 * \param msg message for condition
39 * \param constant_expression does compiler think expression is constant
40 */
41
42ers::Precondition::Precondition(const Context &context, severity_t s, const char*condition, const std::string &msg , bool constant_expression) : Assertion(context,s) {
43 this->setup(condition,msg,constant_expression);
44} // Precondition
45
46/** \return name key for the class */
47
48const char* ers::Precondition::get_class_name() const throw () { return PRECONDITION_CLASS ;}
49
50/** Builds the message associated with an assertion
51 * \param condition_text the condition in textual form
52 * \param msg the message associated with the condition
53 * \param constant_expression is the condition constant (as detected by compiler).
54 * \return message describing the failure of the assertion
55 */
56
57std::string ers::Precondition::build_message(const char* condition_text, const std::string &msg, bool constant_expression) throw() {
58 std::ostringstream m ;
59 m << "Precondition '" << condition_text << "' failed: " << msg ;
60 if (constant_expression) {
61 m << " (this condition is constant)" ;
62 } // constant expression
63 return m.str();
64} // build_message
XmlRpcServer s
Definition: HelloServer.cpp:11
This Issue represents a basic assertion.
void setup(const char *condition, const std::string &message, bool constant_expression)
Source context for Issue.
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
static IssueFactory * instance()
method to access singleton
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