Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
rs_serializable_device.hpp
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2020 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 #include "rs_types.hpp"
6 #include "rs_device.hpp"
7 #include <array>
8 #include <string>
9 
10 namespace rs2
11 {
13  {
14  public:
16  : rs2::device(d.get())
17  {
18  rs2_error* e = nullptr;
20  {
21  _dev = nullptr;
22  }
24  }
25 
26  std::string serialize_json() const
27  {
28  std::string results;
29 
30  rs2_error* e = nullptr;
31  std::shared_ptr<rs2_raw_data_buffer> json_data(
32  rs2_serialize_json(_dev.get(), &e),
35 
36  auto size = rs2_get_raw_data_size(json_data.get(), &e);
38 
39  auto start = rs2_get_raw_data(json_data.get(), &e);
41 
42  results.insert(results.begin(), start, start + size);
43 
44  return results;
45  }
46 
47  void load_json(const std::string& json_content) const
48  {
49  rs2_error* e = nullptr;
50  rs2_load_json(_dev.get(),
51  json_content.data(),
52  (unsigned int)json_content.size(),
53  &e);
55  }
56  };
57 }
void load_json(const std::string &json_content) const
Definition: rs_serializable_device.hpp:47
const unsigned char * rs2_get_raw_data(const rs2_raw_data_buffer *buffer, rs2_error **error)
void rs2_load_json(rs2_device *dev, const void *json_content, unsigned content_size, rs2_error **error)
Definition: rs_context.hpp:11
void rs2_delete_raw_data(const rs2_raw_data_buffer *buffer)
int rs2_get_raw_data_size(const rs2_raw_data_buffer *buffer, rs2_error **error)
std::string serialize_json() const
Definition: rs_serializable_device.hpp:26
rs2_raw_data_buffer * rs2_serialize_json(rs2_device *dev, rs2_error **error)
int rs2_is_device_extendable_to(const rs2_device *device, rs2_extension extension, rs2_error **error)
const std::shared_ptr< rs2_device > & get() const
Definition: rs_device.hpp:162
std::shared_ptr< rs2_device > _dev
Definition: rs_device.hpp:207
serializable_device(rs2::device d)
Definition: rs_serializable_device.hpp:15
static void handle(rs2_error *e)
Definition: rs_types.hpp:162
Definition: rs_types.h:184
struct rs2_error rs2_error
Definition: rs_types.h:229
Definition: rs_device.hpp:19
Definition: rs_serializable_device.hpp:12