BOSS 6.6.4.p01
BESIII Offline Software System
Loading...
Searching...
No Matches
ers/ers-00-00-02/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 <string>
15#include <stdint.h>
16
17#include "ers/Core.h"
18#include "ers/Stream.h"
19#include "ers/Context.h"
20#include "ers/IssueFactory.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 hashmap
26 * as key - value paris (both strings).
27 * The object contains utility methods to allow the manipulation of those key / values and
28 * code to insert common values into it, like time, compilation information, host information etc.
29 * For an example of how to build an actual subclass of issue look at the source of ExampleIssue.
30 * \author Matthias Wiesmann
31 * \version 1.1
32 * \note Issue chaining is handled by copying the cause issue on the stack and keeping a pointer to it.
33 * When the object is destroyed, it destroys the pointed issue. This means we can only chain issues that
34 * correctly implement the factory methods required by the IssueFactory class
35 * \see ers::IssueFactory
36 * \see ExampleIssue
37 * \brief Root Issue class
38 */
39
40 class Issue : public std::exception {
41 friend class Stream ;
42 friend class IssueFactory ;
43public:
44 static const char *const CLASS_KEY ; /**< \brief key for class information */
45 static const char *const COMPILATION_TIME_KEY ; /**< \brief key for compilation time */
46 static const char *const COMPILATION_TARGET_KEY ; /**< \brief key for compilation target */
47 static const char *const COMPILER_KEY ; /**< \brief key for compilator type */
48 static const char *const COMPILATION_DEBUG_LVL_KEY ;
49 static const char *const CPP_CLASS_KEY ; /**< \brief key for c++ class (might be mangled) */
50 static const char *const ERS_VERSION_KEY ; /**< \brief key for ERS version */
51 static const char *const HOST_NAME_KEY ; /**< \brief key for hostname */
52 static const char *const HOST_TYPE_KEY ; /**< \brief key for host type (architecture / os) */
53 static const char *const HOST_IP_ADDR_KEY ; /**< \brief key for host ip address */
54 static const char *const MESSAGE_KEY ; /**< \brief key for human readable */
55 static const char *const PROCESS_ID_KEY ; /**< \brief key for the process id (number)*/
56 static const char *const PROCESS_PWD_KEY ; /**< \brief key for the process working directory */
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 issue (text) */
59 static const char *const SEVERITY_KEY ; /**< \brief key for the severity_t of the issue */
60 static const char *const SOURCE_POSITION_KEY ; /**<�\brief key for position in the source code */
61 static const char *const SOURCE_PACKAGE_KEY ; /**< \brief package name associated with source code */
62 static const char *const TIME_KEY ; /**< \brief key for the time of the issue (text) */
63 static const char *const TRANSIENCE_KEY ; /**< \brief key for the transience of the issue (text) */
64 static const char *const USER_ID_KEY ; /**< \brief key for the user-id of the owner of the process */
65 static const char *const USER_NAME_KEY ; /**< \brief key for the user-name of the owner of the process */
66 static const char *const CAUSE_PSEUDO_KEY ; /**< \brief key used when serializing the cause issue, this key is not used in the value table */
67 static const char *const CAUSE_TEXT_KEY ; /**< \brief key used to store the cause issue's message */
68 static const char *const QUALIFIER_LIST_KEY ; /**<�\brief key used to store the qualifier list */
69 static const char *const EXIT_VALUE_KEY ; /**< \brief key used to store the exit value */
70 static const char *const ISSUE_CLASS_NAME ; /**< \brief name of the class, used for serialisation */
71
72protected:
73 Issue *m_cause ; /**< \brief Issue that caused the current issue */
74 mutable std::string m_class_name ; /**< \brief class name */
75 mutable std::string m_human_description ; /**< \brief Human readable description (cache)*/
76 string_map_type m_value_table ; /**< \brief Optional properties. */
77 void insert(const Context *context) throw() ; /**< \brief Inserts the context */
78 void insert_time() throw() ; /**< \brief Inserts current time */
79 void setup_common(const Context *context) throw() ; /**< \brief Sets up the common fields. */
80 void finish_setup(const std::string &message) throw() ; /**< \brief Finishes the setup of the Issue */
81 Issue(const Context &context, severity_t s); /**< \brief Constructor for subclasses */
82 void set_values(const string_map_type &values) throw(); /**< \brief sets the value table */
83public:
84 Issue();
85 Issue(const Issue &issue);
86 Issue(const string_map_type &values);
87 Issue(const Context &context, severity_t s, const std::string &message);
88 Issue(const Context &context, severity_t s, const std::exception *cause);
89 virtual ~Issue() throw() ;
90 Issue *clone() const ;
91
92 const Issue *cause() const throw() ; /**< \brief return the cause Issue of this Issue */
93 void cause(const std::exception *cause=0); /**< \brief Initialises the cause field */
94 operator std::string() const ; /**< \brief Converts the issue into a string */
95
96 Issue operator=(const Issue &issue); /**< \brief Affectation operator */
97 bool operator==(const Issue &other) const throw(); /**< \brief Equality operator */
98 const std::string& operator[](const std::string &key) const throw();
99
100 const std::string &get_value(const std::string &key, const std::string &def) const throw() ; /**< \brief Reads the property list. */
101 const std::string &get_value(const std::string &key) const throw();
102 int get_int_value(const std::string &key, int def=0) const throw() ; /**< \brief Get a value of the table as an integer */
103 long get_long_value(const std::string &key, long def=0) const throw() ; /**< \brief Get a value of the table as a long integer */
104 double get_double_value(const std::string key, double def) const throw() ; /**< \brief Get a value of the table as double */
105 void set_value(const std::string &key, uint8_t value) throw() ; /**< \brief Sets a value 8 bit unsigned */
106 void set_value(const std::string &key, uint16_t value) throw() ;
107 void set_value(const std::string &key, uint32_t value) throw() ;
108 void set_value(const std::string &key, uint64_t value) throw() ;
109 void set_value(const std::string &key, int8_t value) throw() ;
110 void set_value(const std::string &key, int16_t value) throw() ;
111 void set_value(const std::string &key, int32_t value) throw() ;
112 void set_value(const std::string &key, int64_t value) throw() ;
113 void set_value(const std::string &key, double value) throw() ; /**< \brief Sets a value (double float) */
114 void set_value(const std::string &key, const std::string &value) throw() ; /**< \brief Sets a value (string) */
115 void set_value(const std::string &key, const char* value) throw() ; /**< \brief Sets a value (c-string) */
116 void set_value(const std::string &key, const void* ptr) throw() ;
117 int values_number() const ; /**< \brief How many key / values */
118
119 virtual const char *get_class_name() const throw() ; /**< \brief Get key for class (used for serialisation)*/
120 const string_map_type* get_value_table() const ; /**< \brief extract value table */
121 severity_t severity() const throw() ; /**< \brief severity_t of the issue */
122 void severity(severity_t s) ; /**< \brief sets the severity_t of the issue */
123 bool is_error(); /**< \brief is the issue an error (or fatal). */
124 std::string severity_message() const ; /**< \brief message associated with the severity_t of the issue */
125 void responsibility(responsibility_t r) ; /**< \brief set the responsability of the issue */
126 responsibility_t responsibility() const throw() ; /**< \brief get the responsability level of the issue */
127 void transience(bool tr); /**< \brief sets if the issue is transient */
128 int transience() const throw() ; /**< \brief is the issue transient */
129 const std::string &human_description() const throw() ; /**< \brief Human description message. */
130 const char* what() const throw() ; /**< \brief Human description message. */
131 const std::string &message() const throw() ; /**< \brief Message */
132 virtual int exit_value() const throw(); /**< \brief value to pass to exit */
133 void add_qualifier(const std::string &qualif) ; /**< \brief adds a qualifier to the issue */
134 std::vector<std::string> qualifiers() const ; /**< \brief return array of qualifiers */
135 } ; // Issue
136
137std::ostream& operator<<(std::ostream&, const Issue&);
138Stream& operator<<(Stream&, const Issue&);
139} // ers
140
141// This macro suppresses assertion if N_DEBUG is defined
142//
143
144#if defined(N_DEBUG)
145#define N_ERS_STATIC_ASSERT
146#define N_ERS_ASSERT
147#endif
148
149#endif
150
XmlRpcServer s
Definition: HelloServer.cpp:11
*************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.
Definition: Context.h:42
Factory for all Issues.
Definition: IssueFactory.h:31
Root Issue class.
static const char *const HOST_TYPE_KEY
key for host type (architecture / os)
responsibility_t responsibility() const
get the responsability level of the issue
void set_values(const string_map_type &values)
sets the value table
int values_number() const
How many key / values.
static const char *const USER_NAME_KEY
key for the user-name of the owner of the process
static const char *const PROGRAM_NAME_KEY
key for the name of the program
static const char *const ERS_VERSION_KEY
key for ERS version
std::string m_class_name
class name
static const char *const CPP_CLASS_KEY
key for c++ class (might be mangled)
const std::string & get_value(const std::string &key, const std::string &def) const
Reads the property list.
static const char *const COMPILATION_TARGET_KEY
key for compilation target
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 MESSAGE_KEY
key for human readable
void set_value(const std::string &key, uint8_t value)
Sets a value 8 bit unsigned.
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
void insert_time()
Inserts current time.
std::string m_human_description
Human readable description (cache)
static const char *const EXIT_VALUE_KEY
key used to store the exit value
static const char *const COMPILATION_TIME_KEY
key for compilation time
severity_t severity() const
severity_t of the issue
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.
void finish_setup(const std::string &message)
Finishes the setup of the Issue.
static const char *const RESPONSIBILITY_KEY
key for the responsibility of the issue (text)
static const char *const TRANSIENCE_KEY
key for the transience of the issue (text)
static const char *const TIME_KEY
key for the time of the issue (text)
const std::string & human_description() const
Human description message.
static const char *const COMPILATION_DEBUG_LVL_KEY
static const char *const CAUSE_TEXT_KEY
key used to store the cause issue's message
static const char *const SOURCE_POSITION_KEY
key for position in the source code
Issue * m_cause
Issue that caused the current issue.
const Issue * cause() const
return the cause Issue of this Issue
static const char *const PROCESS_PWD_KEY
key for the process working directory
static const char *const CAUSE_PSEUDO_KEY
key used when serializing the cause issue, this key is not used in the value table
const char * what() const
Human description message.
static const char *const COMPILER_KEY
key for compilator type
static const char *const HOST_NAME_KEY
key for hostname
static const char *const QUALIFIER_LIST_KEY
key used to store the qualifier list
const string_map_type * get_value_table() const
extract value table
static const char *const CLASS_KEY
key for class information
void add_qualifier(const std::string &qualif)
adds a qualifier to the issue
static const char *const SOURCE_PACKAGE_KEY
package name associated with source code
int transience() const
is the issue transient
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 HOST_IP_ADDR_KEY
key for host ip address
void insert(const Context *context)
Inserts the context.
static const char *const ISSUE_CLASS_NAME
name of the class, used for serialisation
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.
static const char *const PROCESS_ID_KEY
key for the process id (number)
Root/Null issue stream.
Definition: Stream.h:35
enum ers::_responsibility_t responsibility_t
std::map< std::string, std::string > string_map_type
Definition: Core.h:26
enum ers::_severity_t severity_t