BOSS 7.0.8
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#include <cstdio>
13
14const char * const ers::InvalidReferenceIssue::CLASS_NAME = "ers::InvalidReferenceIssue" ;
15
16const char * const ers::InvalidReferenceIssue::REFERENCE_VALUE_KEY = "REFERENCE_VALUE" ;
17const char * const ers::InvalidReferenceIssue::REFERENCE_TYPE_KEY = "REFERENCE_TYPE" ;
18const char * const ers::InvalidReferenceIssue::REFERENCE_NAME_KEY = "REFERENCE_NAME" ;
19const char * const ers::InvalidReferenceIssue::REFERENCE_C_PTR_TYPE = "C Pointer" ;
20
21namespace {
22 ers::Issue *create_issue() { return new ers::InvalidReferenceIssue(); }
24} // anonymous context
25
27
29
30ers::InvalidReferenceIssue::InvalidReferenceIssue(const Context &context, severity_t s, const void* p, const std::string &msg, responsibility_t r) : Issue(context,s) {
31 severity(s);
32 pointer(p);
33 responsibility(r) ;
34 finish_setup(msg);
35} // InvalidReferenceIssue
36
37
38const char* ers::InvalidReferenceIssue::get_class_name() const throw() {
40} // get_class_name
41
42
44 char buffer[sizeof(void *)+1] ; // space needed to print a pointer
45 snprintf(buffer,sizeof(buffer),"%p",p);
46 set_value(REFERENCE_VALUE_KEY,buffer) ;
47 set_value(REFERENCE_TYPE_KEY,REFERENCE_C_PTR_TYPE) ;
48} // pointer
49
50void ers::InvalidReferenceIssue::check_reference(const Context &context, severity_t s, const void* p, const char* ptr_name, responsibility_t r) {
51 if (p==0) {
52 std::ostringstream message ;
53 message << "pointer '" << ptr_name << "' is null" ;
54 ers::InvalidReferenceIssue issue(context,s,p,message.str(),r) ;
55 issue.m_value_table[REFERENCE_NAME_KEY] = ptr_name ;
56 throw issue ;
57 } // if
58} // check
59
60
61
62
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