BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
InstallArea/include/ers/ers/InvalidReferenceIssue.h
Go to the documentation of this file.
1/*
2 * InvalidReferenceIssue.h
3 * ers
4 *
5 * Created by Matthias Wiesmann on 04.01.05.
6 * Copyright 2005 CERN. All rights reserved.
7 *
8 */
9
10#ifndef ERS_INVALID_REFERENCE
11#define ERS_INVALID_REFERENCE
12
13#include "ers/Issue.h"
14
15namespace ers {
16
17 /** This issue represents an invalid reference.
18 * This class can be used for any type of reference,
19 * but most of the present mechanisms are designed for C/C++ memory references,
20 * aka. pointers.
21 * \author Matthias Wiesmann
22 * \version 1.0
23 * \brief Invalid pointer issue.
24 */
25
26 class InvalidReferenceIssue : public Issue {
27protected:
28 void pointer(const void *p);
30public:
31 static const char* const CLASS_NAME ;
32 static const char* const REFERENCE_VALUE_KEY ;
33 static const char* const REFERENCE_TYPE_KEY ;
34 static const char* const REFERENCE_NAME_KEY ;
35 static const char* const REFERENCE_C_PTR_TYPE ;
37 InvalidReferenceIssue(const Context &context, severity_t s, const void* pointer, const std::string &message, responsibility_t r = resp_unknown) ;
38 virtual const char*get_class_name() const throw() ;
39 static void check_reference(const Context &context, severity_t s, const void* pointer, const char* ptr_name, responsibility_t r);
40 } ; // InvalidReferenceIssue
41
42} // ers
43
44/** \def ERS_PRE_CHECK_PTR(p) checks that C/C++ pointer \c p is valid (non null) and throws an ers::InvalidReferenceIssue if not
45 * If the pointer is invalid, this is considered as a client responsibility.
46 * \note Do not use this to check constant pointers, as the check is compiled out if the pointer is constant
47 */
48
49#if (!defined(N_ERS_ASSERT))
50#if (defined(__GNUC__))
51#define ERS_PRE_CHECK_PTR(p) if (! __builtin_constant_p(p)) ers::InvalidReferenceIssue::check_reference(ERS_HERE,ers::error,p,#p,ers::resp_client) ;
52#else
53#define ERS_PRE_CHECK_PTR(p) ers::InvalidReferenceIssue::check_reference(ERS_HERE,ers::error,p,#p,ers::resp_client)
54#endif
55#else
56#define ERS_PRE_CHECK_PTR(p)
57#endif
58
59/** \def ERS_CHECK_PTR(p) checks that C/C++ pointer \c p is valid (non null) and throws an ers::InvalidReferenceIssue if not
60 * If the pointer is invalid, this is considered as a server responsibility.
61 * \note Do not use this to check constant pointers, as the check is compiled out if the pointer is constant
62 */
63
64#if (!defined(N_ERS_ASSERT))
65#if (defined(__GNUC__))
66#define ERS_CHECK_PTR(p) if (! __builtin_constant_p(p)) ers::InvalidReferenceIssue::check_reference(ERS_HERE,ers::error,p,#p,ers::resp_server)
67#else
68#define ERS_CHECK_PTR(p) ers::InvalidReferenceIssue::check_reference(ERS_HERE,ers::error,p,#p,ers::resp_server)
69#endif
70#else
71#define ERS_CHECK_PTR(p)
72#endif
73
74#endif
75
XmlRpcServer s
Definition: HelloServer.cpp:11
Source context for Issue.
virtual const char * get_class_name() const
Get key for class (used for serialisation)
InvalidReferenceIssue(const Context &context, severity_t s, const void *pointer, const std::string &message, responsibility_t r=resp_unknown)
void pointer(const void *p)
static void check_reference(const Context &context, severity_t s, const void *pointer, const char *ptr_name, responsibility_t r)
InvalidReferenceIssue(const Context &context, severity_t s)
const std::string & message() const
Message.
enum ers::_responsibility_t responsibility_t
enum ers::_severity_t severity_t