Intel® RealSense™ Cross Platform API
Intel Realsense Cross-platform API
rs_net.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 #ifndef LIBREALSENSE_RS2_NET_HPP
5 #define LIBREALSENSE_RS2_NET_HPP
6 
7 #include <librealsense2/rs.hpp>
8 #include "rs_net.h"
9 
10 #include <memory>
11 
12 namespace rs2
13 {
14  class net_device : public rs2::device
15  {
16  public:
17  net_device(const std::string& address) : rs2::device(init(address)) { }
18 
26  void add_to(context& ctx)
27  {
28  rs2_error* e = nullptr;
29  rs2_context_add_software_device(((std::shared_ptr<rs2_context>)ctx).get(), _dev.get(), &e);
30  error::handle(e);
31  }
32 
33 
34  private:
35  std::shared_ptr<rs2_device> init(const std::string& address)
36  {
37  rs2_error* e = nullptr;
38  auto dev = std::shared_ptr<rs2_device>(
39  rs2_create_net_device(RS2_API_VERSION, address.c_str(), &e),
41  error::handle(e);
42 
43  return dev;
44  }
45  };
46 }
47 #endif // LIBREALSENSE_RS2_NET_HPP
void add_to(context &ctx)
Definition: rs_net.hpp:26
#define RS2_API_VERSION
Definition: rs.h:41
Definition: rs_net.hpp:14
net_device(const std::string &address)
Definition: rs_net.hpp:17
void rs2_delete_device(rs2_device *device)
Definition: rs_context.hpp:11
rs2_device * rs2_create_net_device(int api_version, const char *address, rs2_error **error)
Definition: rs_context.hpp:96
std::shared_ptr< rs2_device > _dev
Definition: rs_device.hpp:146
static void handle(rs2_error *e)
Definition: rs_types.hpp:137
void rs2_context_add_software_device(rs2_context *ctx, rs2_device *dev, rs2_error **error)
struct rs2_error rs2_error
Definition: rs_types.h:217
Definition: rs_device.hpp:18