/home/bes3soft/bes3soft/Boss/7.0.2/dist/7.0.2/Event/ers/ers-00-00-03/src/Assertion.cxx

Go to the documentation of this file.
00001 /*
00002  *  Assertion.cxx
00003  *  ers
00004  *
00005  *  Created by Matthias Wiesmann on 26.11.04.
00006  *  Copyright 2004 CERN. All rights reserved.
00007  *
00008  */
00009 
00010 
00011 #include <iostream>
00012 #include <sstream>
00013 #include <sysexits.h>
00014 
00015 #include "ers/Assertion.h"
00016 #include "ers/Issue.h"
00017 
00018 
00019 namespace {
00020     ers::Issue *create_issue() { return new ers::Assertion(); } 
00021     bool registered = ers::IssueFactory::instance()->register_issue(ers::Assertion::CLASS_NAME,create_issue) ;
00022 } 
00023 
00027 const char * const ers::Assertion::ASSERT_CONDITION_KEY = "ASSERTION_CONDITION" ; 
00028 const char * const ers::Assertion::CLASS_NAME = "ers::Assertion" ;
00029 const  char * const ers::Assertion::MESSAGE_ELEMENTS[] = { "Assertion '", "' failed: ", " (this condition is constant)" } ;  
00030 
00034 ers::Assertion::Assertion() : Issue() {} 
00035 
00039 ers::Assertion::Assertion(const Context &context, severity_t s) : Issue(context,s) {} 
00040 
00049 ers::Assertion::Assertion(const Context &context, severity_t s, const char* condition_text, const std::string &msg, bool constant_expression) : Issue(context,s) {
00050     setup(condition_text,msg,constant_expression);
00051 } // Assertion
00052 
00056 void ers::Assertion::setup(const char *condition_text, const std::string &msg, bool constant_expression)  {
00057     m_value_table[ASSERT_CONDITION_KEY] = *condition_text ;
00058     responsibility(resp_server); 
00059     set_value(EXIT_VALUE_KEY,EX_SOFTWARE);
00060     transience( ! constant_expression); 
00061     finish_setup(build_message(condition_text,msg,constant_expression));
00062 } // setup
00063 
00064 const char* ers::Assertion::get_class_name() const throw (){
00065     return CLASS_NAME ; 
00066 } // get_class_name
00067 
00076 std::string ers::Assertion::build_message(const char* condition_text, const std::string &msg, bool constant_expression) throw() {
00077     std::ostringstream m ;
00078     m << MESSAGE_ELEMENTS[0] << condition_text << MESSAGE_ELEMENTS[1]  << msg ;
00079     if (constant_expression) {
00080         m << MESSAGE_ELEMENTS[2]  ; 
00081     } // constant expression 
00082     return m.str();
00083 } // build_message
00084 

Generated on Tue Nov 29 22:57:56 2016 for BOSS_7.0.2 by  doxygen 1.4.7