exception-abstract.hh
Go to the documentation of this file.
1 /*
2  * Copyright 2010,
3  * François Bleibel,
4  * Olivier Stasse,
5  *
6  * CNRS/AIST
7  *
8  */
9 
10 #ifndef __SOT_ABSTRACT_EXCEPTION_H
11 #define __SOT_ABSTRACT_EXCEPTION_H
12 
13 /* --------------------------------------------------------------------- */
14 /* --- INCLUDE --------------------------------------------------------- */
15 /* --------------------------------------------------------------------- */
16 
17 /* Classes standards. */
18 #include <exception>
19 #include <ostream> /* Classe ostream. */
20 #include <string> /* Classe string. */
21 
22 #include "sot/core/api.hh"
23 #include <sot/core/fwd.hh>
24 
25 // Uncomment this macros to have lines parameter on the throw display
26 // #define SOT_EXCEPTION_PASSING_PARAM
27 
28 /* --------------------------------------------------------------------- */
29 /* --- CLASS ----------------------------------------------------------- */
30 /* --------------------------------------------------------------------- */
31 
32 namespace dynamicgraph {
33 namespace sot {
34 
35 /* \class ExceptionAbstract
36  */
37 class SOT_CORE_EXPORT ExceptionAbstract : public std::exception {
38  public:
40  ABSTRACT = 0,
41  SIGNAL = 100,
42  TASK = 200,
43  FEATURE = 300,
44  FACTORY = 400,
45  DYNAMIC = 500,
46  TRACES = 600,
47  TOOLS = 700,
48  PATTERN_GENERATOR = 800
49  };
50 
51  static const std::string EXCEPTION_NAME;
52  virtual const std::string &getExceptionName(void) const {
53  return EXCEPTION_NAME;
54  }
55 
56  protected:
60 
62  std::string message;
63 
64  private:
66  ExceptionAbstract(void);
67 
68  public:
69  ExceptionAbstract(const size_type &code, const std::string &msg = "");
70  virtual ~ExceptionAbstract(void) throw() {}
71 
73  size_type getCode(void);
74 
76  const std::string &getStringMessage(void);
77 
81  const char *getMessage(void);
82  const char *what() const throw();
83 
85  SOT_CORE_EXPORT friend std::ostream &operator<<(std::ostream &os,
86  const ExceptionAbstract &err);
87 
88 #ifdef SOT_EXCEPTION_PASSING_PARAM
89  public:
90  class Param {
91  public:
92  static const size_type BUFFER_SIZE = 80;
93 
94  const char *functionPTR;
95  char function[BUFFER_SIZE];
97  const char *filePTR;
98  char file[BUFFER_SIZE];
99  bool pointersSet, set;
100 
101  public:
102  Param(const size_type &_line, const char *_function, const char *_file);
103  Param(void) : pointersSet(false), set(false) {}
104  Param &initCopy(const Param &p);
105  };
106 
107  protected:
108  mutable Param p;
109 
110  template <class Exc>
111  friend const Exc &operator+(const ExceptionAbstract::Param &p, const Exc &e) {
112  e.p.initCopy(p);
113  return e;
114  }
115  template <class Exc>
116  friend Exc &operator+(const ExceptionAbstract::Param &p, Exc &e) {
117  e.p.initCopy(p);
118  return e;
119  }
120 #endif // #ifdef SOT_EXCEPTION_PASSING_PARAM
121 };
122 
123 #define SOT_RETHROW \
124  (const ExceptionAbstract &err) { throw err; }
125 
126 #ifdef SOT_EXCEPTION_PASSING_PARAM
127 #define SOT_THROW \
128  throw ExceptionAbstract::Param(__LINE__, __FUNCTION__, __FILE__) +
129 #else // #ifdef SOT_EXCEPTION_PASSING_PARAM
130 #define SOT_THROW throw
131 #endif // #ifdef SOT_EXCEPTION_PASSING_PARAM
132 
133 } /* namespace sot */
134 } /* namespace dynamicgraph */
135 
136 #endif /* #ifndef __SOT_ABSTRACT_EXCEPTION_H */
137 
138 /*
139  * Local variables:
140  * c-basic-offset: 2
141  * End:
142  */
SOT_CORE_EXPORT
#define SOT_CORE_EXPORT
Definition: api.hh:20
dynamicgraph
dynamicgraph::sot::ExceptionAbstract::code
size_type code
Definition: exception-abstract.hh:59
fwd.hh
p
p
dynamicgraph::ExceptionAbstract
api.hh
dynamicgraph::sot::ExceptionAbstract::ExceptionEnum
ExceptionEnum
Definition: exception-abstract.hh:39
set
void set(bool ownStorage, Vec3f *points_, unsigned int num_points_)
dynamicgraph::sot::ExceptionAbstract::getExceptionName
virtual const std::string & getExceptionName(void) const
Definition: exception-abstract.hh:52
dynamicgraph::size_type
Matrix::Index size_type
operator+
KDOP< N > operator+(const KDOP< N > &other) const
dynamicgraph::sot::ExceptionAbstract::~ExceptionAbstract
virtual ~ExceptionAbstract(void)
Definition: exception-abstract.hh:70
dynamicgraph::sot::ExceptionAbstract::message
std::string message
Definition: exception-abstract.hh:62
dynamicgraph::sot::ExceptionAbstract::EXCEPTION_NAME
static const std::string EXCEPTION_NAME
Definition: exception-abstract.hh:51
line
int line


sot-core
Author(s): Olivier Stasse, ostasse@laas.fr
autogenerated on Tue Oct 24 2023 02:26:31