BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
Event/ers/include/ers/Issue.h
Go to the documentation of this file.
1/*
2 * Issue.h
3 * ers
4 *
5 * Created by Matthias Wiesmann on 08.12.04.
6 * Copyright 2004 CERN. All rights reserved.
7 *
8 */
9
10#ifndef ERS_Issue_
11#define ERS_Issue_
12
13#include <map>
14#include <stdint.h>
15#include <string>
16
17#include "ers/Context.h"
18#include "ers/Core.h"
19#include "ers/IssueFactory.h"
20#include "ers/Stream.h"
21
22namespace ers {
23
24 /** This class is the root Issue object.
25 * The class does not contain any fields with information, instead everything is stored in a
26 * hashmap as key - value paris (both strings). The object contains utility methods to allow
27 * the manipulation of those key / values and code to insert common values into it, like
28 * time, compilation information, host information etc. For an example of how to build an
29 * actual subclass of issue look at the source of ExampleIssue. \author Matthias Wiesmann
30 * \version 1.1
31 * \note Issue chaining is handled by copying the cause issue on the stack and keeping a
32 * pointer to it. When the object is destroyed, it destroys the pointed issue. This means we
33 * can only chain issues that correctly implement the factory methods required by the
34 * IssueFactory class \see ers::IssueFactory \see ExampleIssue \brief Root Issue class
35 */
36
37 class Issue : public std::exception {
38 friend class Stream;
39 friend class IssueFactory;
40
41 public:
42 static const char* const CLASS_KEY; /**< \brief key for class information */
43 static const char* const COMPILATION_TIME_KEY; /**< \brief key for compilation time */
44 static const char* const COMPILATION_TARGET_KEY; /**< \brief key for compilation target */
45 static const char* const COMPILER_KEY; /**< \brief key for compilator type */
46 static const char* const COMPILATION_DEBUG_LVL_KEY;
47 static const char* const CPP_CLASS_KEY; /**< \brief key for c++ class (might be mangled) */
48 static const char* const ERS_VERSION_KEY; /**< \brief key for ERS version */
49 static const char* const HOST_NAME_KEY; /**< \brief key for hostname */
50 static const char* const HOST_TYPE_KEY; /**< \brief key for host type (architecture / os)
51 */
52 static const char* const HOST_IP_ADDR_KEY; /**< \brief key for host ip address */
53 static const char* const MESSAGE_KEY; /**< \brief key for human readable */
54 static const char* const PROCESS_ID_KEY; /**< \brief key for the process id (number)*/
55 static const char* const PROCESS_PWD_KEY; /**< \brief key for the process working directory
56 */
57 static const char* const PROGRAM_NAME_KEY; /**< \brief key for the name of the program */
58 static const char* const RESPONSIBILITY_KEY; /**< \brief key for the responsibility of the
59 issue (text) */
60 static const char* const SEVERITY_KEY; /**< \brief key for the severity_t of the issue */
61 static const char* const SOURCE_POSITION_KEY; /**< \brief key for position in the source
62 code */
63 static const char* const SOURCE_PACKAGE_KEY; /**< \brief package name associated with
64 source code */
65 static const char* const TIME_KEY; /**< \brief key for the time of the issue (text) */
66 static const char* const TRANSIENCE_KEY; /**< \brief key for the transience of the issue
67 (text) */
68 static const char* const USER_ID_KEY; /**< \brief key for the user-id of the owner of the
69 process */
70 static const char* const USER_NAME_KEY; /**< \brief key for the user-name of the owner of
71 the process */
72 static const char* const CAUSE_PSEUDO_KEY; /**< \brief key used when serializing the cause
73 issue, this key is not used in the value
74 table */
75 static const char* const CAUSE_TEXT_KEY; /**< \brief key used to store the cause issue's
76 message */
77 static const char* const QUALIFIER_LIST_KEY; /**<Ê\brief key used to store the qualifier
78 list */
79 static const char* const EXIT_VALUE_KEY; /**< \brief key used to store the exit value */
80 static const char* const ISSUE_CLASS_NAME; /**< \brief name of the class, used for
81 serialisation */
82
83 protected:
84 Issue* m_cause; /**< \brief Issue that caused the current issue */
85 mutable std::string m_class_name; /**< \brief class name */
86 mutable std::string m_human_description; /**< \brief Human readable description (cache)*/
87 string_map_type m_value_table; /**< \brief Optional properties. */
88 void insert( const Context* context ) throw(); /**< \brief Inserts the context */
89 void insert_time() throw(); /**< \brief Inserts current time */
90 void setup_common( const Context* context ) throw(); /**< \brief Sets up the common fields.
91 */
92 void finish_setup( const std::string& message ) throw(); /**< \brief Finishes the setup of
93 the Issue */
94 Issue( const Context& context, severity_t s ); /**< \brief Constructor for subclasses */
95 void set_values( const string_map_type& values ) throw(); /**< \brief sets the value table
96 */
97 public:
98 Issue();
99 Issue( const Issue& issue );
100 Issue( const string_map_type& values );
101 Issue( const Context& context, severity_t s, const std::string& message );
102 Issue( const Context& context, severity_t s, const std::exception* cause );
103 virtual ~Issue() throw();
104 Issue* clone() const;
105
106 const Issue* cause() const throw(); /**< \brief return the cause Issue of this Issue */
107 void cause( const std::exception* cause = 0 ); /**< \brief Initialises the cause field */
108 operator std::string() const; /**< \brief Converts the issue into a string */
109
110 Issue operator=( const Issue& issue ); /**< \brief Affectation operator */
111 bool operator==( const Issue& other ) const throw(); /**< \brief Equality operator */
112 const std::string& operator[]( const std::string& key ) const throw();
113
114 const std::string& get_value( const std::string& key, const std::string& def ) const
115 throw(); /**< \brief Reads the property list. */
116 const std::string& get_value( const std::string& key ) const throw();
117 int get_int_value( const std::string& key, int def = 0 ) const
118 throw(); /**< \brief Get a value of the table as an integer */
119 long get_long_value( const std::string& key, long def = 0 ) const
120 throw(); /**< \brief Get a value of the table as a long integer */
121 double get_double_value( const std::string key, double def ) const
122 throw(); /**< \brief Get a value of the table as double */
123 void set_value( const std::string& key,
124 uint8_t value ) throw(); /**< \brief Sets a value 8 bit unsigned */
125 void set_value( const std::string& key, uint16_t value ) throw();
126 void set_value( const std::string& key, uint32_t value ) throw();
127 void set_value( const std::string& key, uint64_t value ) throw();
128 void set_value( const std::string& key, int8_t value ) throw();
129 void set_value( const std::string& key, int16_t value ) throw();
130 void set_value( const std::string& key, int32_t value ) throw();
131 void set_value( const std::string& key, int64_t value ) throw();
132 void set_value( const std::string& key,
133 double value ) throw(); /**< \brief Sets a value (double float) */
134 void set_value( const std::string& key,
135 const std::string& value ) throw(); /**< \brief Sets a value (string) */
136 void set_value( const std::string& key,
137 const char* value ) throw(); /**< \brief Sets a value (c-string) */
138 void set_value( const std::string& key, const void* ptr ) throw();
139 int values_number() const; /**< \brief How many key / values */
140
141 virtual const char* get_class_name() const
142 throw(); /**< \brief Get key for class (used for serialisation)*/
143 const string_map_type* get_value_table() const; /**< \brief extract value table */
144 severity_t severity() const throw(); /**< \brief severity_t of the issue */
145 void severity( severity_t s ); /**< \brief sets the severity_t of the issue */
146 bool is_error(); /**< \brief is the issue an error (or fatal). */
147 std::string severity_message() const; /**< \brief message associated with the severity_t of
148 the issue */
149 void responsibility( responsibility_t r ); /**< \brief set the responsability of the issue
150 */
152 throw(); /**< \brief get the responsability level of the issue */
153 void transience( bool tr ); /**< \brief sets if the issue is transient */
154 int transience() const throw(); /**< \brief is the issue transient */
155 const std::string& human_description() const
156 throw(); /**< \brief Human description message. */
157 const char* what() const throw(); /**< \brief Human description message. */
158 const std::string& message() const throw(); /**< \brief Message */
159 virtual int exit_value() const throw(); /**< \brief value to pass to exit */
160 void add_qualifier( const std::string& qualif ); /**< \brief adds a qualifier to the issue
161 */
162 std::vector<std::string> qualifiers() const; /**< \brief return array of qualifiers */
163 }; // Issue
164
165 std::ostream& operator<<( std::ostream&, const Issue& );
166 Stream& operator<<( Stream&, const Issue& );
167} // namespace ers
168
169// This macro suppresses assertion if N_DEBUG is defined
170//
171
172#if defined( N_DEBUG )
173# define N_ERS_STATIC_ASSERT
174# define N_ERS_ASSERT
175#endif
176
177#endif
DOUBLE_PRECISION tr[3]
XmlRpcServer s
*************DOUBLE PRECISION m_pi *DOUBLE PRECISION m_HvecTau2 DOUBLE PRECISION m_HvClone2 DOUBLE PRECISION m_gamma1 DOUBLE PRECISION m_gamma2 DOUBLE PRECISION m_thet1 DOUBLE PRECISION m_thet2 INTEGER m_IFPHOT *COMMON c_Taupair $ !Spin Polarimeter vector first Tau $ !Spin Polarimeter vector second Tau $ !Clone Spin Polarimeter vector first Tau $ !Clone Spin Polarimeter vector second Tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning st tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !Random Euler angle for cloning nd tau $ !phi of HvecTau1 $ !theta of HvecTau1 $ !phi of HvecTau2 $ !theta of HvecTau2 $ !super key
Definition Taupair.h:42
Source context for Issue.
static const char *const PROCESS_PWD_KEY
key for the process working directory
void set_values(const string_map_type &values)
sets the value table
static const char *const COMPILATION_TARGET_KEY
key for compilation target
int values_number() const
How many key / values.
static const char *const ERS_VERSION_KEY
key for ERS version
static const char *const HOST_TYPE_KEY
key for host type (architecture / os)
std::string m_class_name
class name
const std::string & get_value(const std::string &key, const std::string &def) const
Reads the property list.
std::string severity_message() const
message associated with the severity_t of the issue
long get_long_value(const std::string &key, long def=0) const
Get a value of the table as a long integer.
static const char *const SOURCE_PACKAGE_KEY
package name associated with source code
static const char *const COMPILER_KEY
key for compilator type
void set_value(const std::string &key, uint8_t value)
Sets a value 8 bit unsigned.
static const char *const QUALIFIER_LIST_KEY
key used to store the qualifier list
static const char *const CAUSE_PSEUDO_KEY
key used when serializing the cause issue, this key is not used in the value table
void insert_time()
Inserts current time.
std::string m_human_description
Human readable description (cache).
Issue * m_cause
Issue that caused the current issue.
static const char *const CAUSE_TEXT_KEY
key used to store the cause issue's message
severity_t severity() const
severity_t of the issue
Issue * clone() const
static const char *const TIME_KEY
key for the time of the issue (text)
bool is_error()
is the issue an error (or fatal).
std::vector< std::string > qualifiers() const
return array of qualifiers
const std::string & message() const
Message.
int get_int_value(const std::string &key, int def=0) const
Get a value of the table as an integer.
static const char *const HOST_IP_ADDR_KEY
key for host ip address
static const char *const CPP_CLASS_KEY
key for c++ class (might be mangled)
void finish_setup(const std::string &message)
Finishes the setup of the Issue.
static const char *const USER_ID_KEY
key for the user-id of the owner of the process
static const char *const SEVERITY_KEY
key for the severity_t of the issue
const std::string & human_description() const
Human description message.
static const char *const PROGRAM_NAME_KEY
key for the name of the program
const Issue * cause() const
return the cause Issue of this Issue
static const char *const TRANSIENCE_KEY
key for the transience of the issue (text)
const char * what() const
Human description message.
void transience(bool tr)
sets if the issue is transient
Issue(const Context &context, severity_t s)
Constructor for subclasses.
static const char *const EXIT_VALUE_KEY
key used to store the exit value
const string_map_type * get_value_table() const
extract value table
static const char *const USER_NAME_KEY
key for the user-name of the owner of the process
static const char *const RESPONSIBILITY_KEY
key for the responsibility of the issue (text)
static const char *const HOST_NAME_KEY
key for hostname
void add_qualifier(const std::string &qualif)
adds a qualifier to the issue
static const char *const SOURCE_POSITION_KEY
key for position in the source code
static const char *const COMPILATION_DEBUG_LVL_KEY
static const char *const MESSAGE_KEY
key for human readable
void responsibility(responsibility_t r)
set the responsability of the issue
static const char *const COMPILATION_TIME_KEY
key for compilation time
static const char *const CLASS_KEY
key for class information
string_map_type m_value_table
Optional properties.
virtual const char * get_class_name() const
Get key for class (used for serialisation).
static const char *const ISSUE_CLASS_NAME
name of the class, used for serialisation
static const char *const PROCESS_ID_KEY
key for the process id (number)
void insert(const Context *context)
Inserts the context.
virtual int exit_value() const
value to pass to exit
double get_double_value(const std::string key, double def) const
Get a value of the table as double.
void setup_common(const Context *context)
Sets up the common fields.
enum ers::_responsibility_t responsibility_t
std::map< std::string, std::string > string_map_type
enum ers::_severity_t severity_t