BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
InvalidReferenceIssue.cxx
Go to the documentation of this file.
1/*
2 * InvalidReferenceIssue.cxx
3 * ers
4 *
5 * Created by Matthias Wiesmann on 04.01.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
11#include <sstream>
12
13const char * const ers::InvalidReferenceIssue::CLASS_NAME = "ers::InvalidReferenceIssue" ;
14
15const char * const ers::InvalidReferenceIssue::REFERENCE_VALUE_KEY = "REFERENCE_VALUE" ;
16const char * const ers::InvalidReferenceIssue::REFERENCE_TYPE_KEY = "REFERENCE_TYPE" ;
17const char * const ers::InvalidReferenceIssue::REFERENCE_NAME_KEY = "REFERENCE_NAME" ;
18const char * const ers::InvalidReferenceIssue::REFERENCE_C_PTR_TYPE = "C Pointer" ;
19
20namespace {
21 ers::Issue *create_issue() { return new ers::InvalidReferenceIssue(); }
23} // anonymous context
24
26
28
29ers::InvalidReferenceIssue::InvalidReferenceIssue(const Context &context, severity_t s, const void* p, const std::string &msg, responsibility_t r) : Issue(context,s) {
30 severity(s);
31 pointer(p);
32 responsibility(r) ;
33 finish_setup(msg);
34} // InvalidReferenceIssue
35
36
37const char* ers::InvalidReferenceIssue::get_class_name() const throw() {
39} // get_class_name
40
41
43 char buffer[sizeof(void *)+1] ; // space needed to print a pointer
44 snprintf(buffer,sizeof(buffer),"%p",p);
45 set_value(REFERENCE_VALUE_KEY,buffer) ;
46 set_value(REFERENCE_TYPE_KEY,REFERENCE_C_PTR_TYPE) ;
47} // pointer
48
49void ers::InvalidReferenceIssue::check_reference(const Context &context, severity_t s, const void* p, const char* ptr_name, responsibility_t r) {
50 if (p==0) {
51 std::ostringstream message ;
52 message << "pointer '" << ptr_name << "' is null" ;
53 ers::InvalidReferenceIssue issue(context,s,p,message.str(),r) ;
54 issue.m_value_table[REFERENCE_NAME_KEY] = ptr_name ;
55 throw issue ;
56 } // if
57} // check
58
59
60
61
XmlRpcServer s
Definition: HelloServer.cpp:11
Source context for Issue.
Definition: Context.h:42
static const char *const REFERENCE_C_PTR_TYPE
static const char *const CLASS_NAME
static const char *const REFERENCE_NAME_KEY
virtual const char * get_class_name() const
Get key for class (used for serialisation)
static const char *const REFERENCE_TYPE_KEY
static void check_reference(const Context &context, severity_t s, const void *pointer, const char *ptr_name, responsibility_t r)
static const char *const REFERENCE_VALUE_KEY
bool register_issue(const std::string &name, CreateIssueCallback creator)
register an issue factory
static IssueFactory * instance()
method to access singleton
Root Issue class.
responsibility_t responsibility() const
get the responsability level of the issue
severity_t severity() const
severity_t of the issue
void finish_setup(const std::string &message)
Finishes the setup of the Issue.
string_map_type m_value_table
Optional properties.
enum ers::_responsibility_t responsibility_t
enum ers::_severity_t severity_t