rs_types.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2017 Intel Corporation. All Rights Reserved.
3 
4 #ifndef LIBREALSENSE_RS2_TYPES_HPP
5 #define LIBREALSENSE_RS2_TYPES_HPP
6 
7 #include "../rs.h"
8 #include "../h/rs_context.h"
9 #include "../h/rs_device.h"
10 #include "../h/rs_frame.h"
11 #include "../h/rs_processing.h"
12 #include "../h/rs_record_playback.h"
13 #include "../h/rs_sensor.h"
14 #include "../h/rs_pipeline.h"
15 
16 #include <string>
17 #include <vector>
18 #include <memory>
19 #include <functional>
20 #include <exception>
21 #include <iterator>
22 #include <sstream>
23 #include <chrono>
24 
26 {
27  virtual void on_frame(rs2_frame * f) = 0;
28  virtual void release() = 0;
29  virtual ~rs2_frame_callback() {}
30 };
31 
33 {
34  virtual void on_frame(rs2_frame * f, rs2_source * source) = 0;
35  virtual void release() = 0;
37 };
38 
40 {
41  virtual void on_notification(rs2_notification* n) = 0;
42  virtual void release() = 0;
44 };
45 
47 
49 {
50  virtual void on_destruction() = 0;
51  virtual void release() = 0;
53 };
54 
56 {
57  virtual void on_log( rs2_log_severity severity, rs2_log_message const & msg ) noexcept = 0;
58  virtual void release() = 0;
59  virtual ~rs2_log_callback() {}
60 };
61 
63 {
64  virtual void on_calibration_change( rs2_calibration_status ) noexcept = 0;
65  virtual void release() = 0;
67 };
68 
70 {
71  virtual void on_devices_changed(rs2_device_list* removed, rs2_device_list* added) = 0;
72  virtual void release() = 0;
74 };
75 
77 {
78  virtual void on_playback_status_changed(rs2_playback_status status) = 0;
79  virtual void release() = 0;
81 };
82 
84 {
85  virtual void on_update_progress(const float update_progress) = 0;
86  virtual void release() = 0;
88 };
89 
90 namespace rs2
91 {
92  class error : public std::runtime_error
93  {
94  std::string function, args;
96  public:
97  explicit error(rs2_error* err) : runtime_error(rs2_get_error_message(err))
98  {
99  function = (nullptr != rs2_get_failed_function(err)) ? rs2_get_failed_function(err) : std::string();
100  args = (nullptr != rs2_get_failed_args(err)) ? rs2_get_failed_args(err) : std::string();
102  rs2_free_error(err);
103  }
104 
105  explicit error(const std::string& message) : runtime_error(message.c_str())
106  {
107  function = "";
108  args = "";
110  }
111 
113  {
114  return function;
115  }
116 
118  {
119  return args;
120  }
121 
122  rs2_exception_type get_type() const { return type; }
123 
124  static void handle(rs2_error* e);
125  };
126 
127  #define RS2_ERROR_CLASS(name, base) \
128  class name : public base\
129  {\
130  public:\
131  explicit name(rs2_error* e) noexcept : base(e) {}\
132  }
133 
134  RS2_ERROR_CLASS(recoverable_error, error);
135  RS2_ERROR_CLASS(unrecoverable_error, error);
136  RS2_ERROR_CLASS(camera_disconnected_error, unrecoverable_error);
137  RS2_ERROR_CLASS(backend_error, unrecoverable_error);
138  RS2_ERROR_CLASS(device_in_recovery_mode_error, unrecoverable_error);
139  RS2_ERROR_CLASS(invalid_value_error, recoverable_error);
140  RS2_ERROR_CLASS(wrong_api_call_sequence_error, recoverable_error);
141  RS2_ERROR_CLASS(not_implemented_error, recoverable_error);
142  #undef RS2_ERROR_CLASS
143 
144  inline void error::handle(rs2_error* e)
145  {
146  if (e)
147  {
149  switch (h) {
151  throw camera_disconnected_error(e);
153  throw backend_error(e);
155  throw invalid_value_error(e);
157  throw wrong_api_call_sequence_error(e);
159  throw not_implemented_error(e);
161  throw device_in_recovery_mode_error(e);
162  default:
163  throw error(e);
164  }
165  }
166  }
167 
168  class context;
169  class device;
170  class device_list;
171  class syncer;
172  class device_base;
173  class roi_sensor;
174  class frame;
175 
177  {
178  float min;
179  float max;
180  float def;
181  float step;
182  };
183 
185  {
186  int min_x;
187  int min_y;
188  int max_x;
189  int max_y;
190  };
191 }
192 
193 inline std::ostream & operator << (std::ostream & o, rs2_vector v) { return o << v.x << ", " << v.y << ", " << v.z; }
194 inline std::ostream & operator << (std::ostream & o, rs2_quaternion q) { return o << q.x << ", " << q.y << ", " << q.z << ", " << q.w; }
195 
196 #endif // LIBREALSENSE_RS2_TYPES_HPP
GLenum GLuint GLenum GLsizei const GLchar * message
#define RS2_ERROR_CLASS(name, base)
Definition: rs_types.hpp:127
rs2_exception_type
Exception types are the different categories of errors that RealSense API might return.
Definition: rs_types.h:30
GLenum GLuint GLenum severity
typedef void(APIENTRY *GLDEBUGPROC)(GLenum source
void rs2_free_error(rs2_error *error)
Definition: rs.cpp:1256
std::ostream & operator<<(std::ostream &o, rs2_vector v)
Definition: rs_types.hpp:193
virtual ~rs2_log_callback()
Definition: rs_types.hpp:59
virtual void on_frame(rs2_frame *f)=0
float z
Definition: rs_types.h:131
GLuint64 GLenum void * handle
Definition: glext.h:7785
virtual ~rs2_notifications_callback()
Definition: rs_types.hpp:43
virtual ~rs2_calibration_change_callback()
Definition: rs_types.hpp:66
Definition: cah-model.h:10
GLsizei const GLchar *const * string
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:1960
GLdouble n
Definition: glext.h:1966
rs2_exception_type type
Definition: rs_types.hpp:95
e
Definition: rmse.py:177
status
Defines return codes that SDK interfaces use. Negative values indicate errors, a zero value indicates...
virtual void release()=0
Quaternion used to represent rotation.
Definition: rs_types.h:135
const std::string & get_failed_args() const
Definition: rs_types.hpp:117
float y
Definition: rs_types.h:131
GLdouble f
void(* log_callback_function_ptr)(rs2_log_severity severity, rs2_log_message const *msg)
Definition: rs_types.hpp:46
virtual ~rs2_update_progress_callback()
Definition: rs_types.hpp:87
error(rs2_error *err)
Definition: rs_types.hpp:97
rs2_calibration_status
Definition: rs_device.h:356
const char * rs2_get_error_message(const rs2_error *error)
Definition: rs.cpp:1259
rs2_playback_status
struct rs2_log_message rs2_log_message
Definition: rs_types.h:259
virtual ~rs2_devices_changed_callback()
Definition: rs_types.hpp:73
rs2_exception_type rs2_get_librealsense_exception_type(const rs2_error *error)
Definition: rs.cpp:1260
float x
Definition: rs_types.h:131
rs2_exception_type get_type() const
Definition: rs_types.hpp:122
3D vector in Euclidean coordinate space
Definition: rs_types.h:129
GLdouble GLdouble GLdouble q
error(const std::string &message)
Definition: rs_types.hpp:105
GLenum type
virtual ~rs2_frame_processor_callback()
Definition: rs_types.hpp:36
virtual ~rs2_frame_callback()
Definition: rs_types.hpp:29
GLsizei GLsizei GLchar * source
rs2_log_severity
Severity of the librealsense logger.
Definition: rs_types.h:153
const char * rs2_get_failed_function(const rs2_error *error)
Definition: rs.cpp:1257
const char * rs2_get_failed_args(const rs2_error *error)
Definition: rs.cpp:1258
GLdouble v
const std::string & get_failed_function() const
Definition: rs_types.hpp:112
struct rs2_frame rs2_frame
Definition: rs_types.h:261


librealsense2
Author(s): Sergey Dorodnicov , Doron Hirshberg , Mark Horn , Reagan Lopez , Itay Carpis
autogenerated on Mon May 3 2021 02:47:41