environment.h
Go to the documentation of this file.
1 // License: Apache 2.0. See LICENSE file in root directory.
2 // Copyright(c) 2015 Intel Corporation. All Rights Reserved.
3 
4 #pragma once
5 #include "core/streaming.h"
6 #include "types.h"
7 #include <memory>
8 #include <mutex>
9 
10 namespace librealsense
11 {
13  {
14  public:
17  void register_extrinsics(const stream_interface& from, const stream_interface& to, std::weak_ptr<lazy<rs2_extrinsics>> extr);
19  void override_extrinsics(const stream_interface& from, const stream_interface& to, rs2_extrinsics const & extr);
20  bool try_fetch_extrinsics(const stream_interface& from, const stream_interface& to, rs2_extrinsics* extr);
21 
23  {
25  : _owner(owner)
26  {
28  _owner._locks_count.fetch_add(1);
29  }
30 
32  : _owner(lock._owner)
33  {
34  _owner._locks_count = lock._owner._locks_count.load();
35  _owner._locks_count.fetch_add(1);
36  }
37 
39  _owner._locks_count.fetch_sub(1);
40  }
41 
43  };
44 
46 
47  private:
48  std::mutex _mutex;
49  std::shared_ptr<lazy<rs2_extrinsics>> _id;
50  // Required by current implementation to hold the reference instead of the device for certain types. TODO
51  std::vector<std::shared_ptr<lazy<rs2_extrinsics>>> _external_extrinsics;
52 
54  std::shared_ptr<lazy<rs2_extrinsics>> fetch_edge(int from, int to);
55  bool try_fetch_extrinsics(int from, int to, std::set<int>& visited, rs2_extrinsics* extr);
56  void cleanup_extrinsics();
57  int find_stream_profile(const stream_interface& p, bool add_if_not_there = true);
58 
59  std::atomic<int> _locks_count;
60  std::map<int, std::map<int, std::weak_ptr<lazy<rs2_extrinsics>>>> _extrinsics;
61 
62  std::map<int, std::weak_ptr<const stream_interface>> _streams;
63 
64  };
65 
66 
68  {
69  public:
70  static environment& get_instance();
71 
72  extrinsics_graph& get_extrinsics_graph();
73 
74  int generate_stream_id() { return _stream_id.fetch_add(1); }
75 
76  void set_time_service(std::shared_ptr<platform::time_service> ts);
77  std::shared_ptr<platform::time_service> get_time_service();
78 
79  environment(const environment&) = delete;
80  environment(const environment&&) = delete;
81  environment operator=(const environment&) = delete;
82  environment operator=(const environment&&) = delete;
83  private:
84 
86  std::atomic<int> _stream_id;
87  std::shared_ptr<platform::time_service> _ts;
88 
89  environment(){_stream_id = 0;}
90 
91  };
92 }
std::vector< std::shared_ptr< lazy< rs2_extrinsics > > > _external_extrinsics
Definition: environment.h:51
std::map< int, std::map< int, std::weak_ptr< lazy< rs2_extrinsics > > > > _extrinsics
Definition: environment.h:60
GLfloat GLfloat p
Definition: glext.h:12687
std::shared_ptr< platform::time_service > _ts
Definition: environment.h:87
std::atomic< int > _locks_count
Definition: environment.h:59
void register_same_extrinsics(const stream_interface &from, const stream_interface &to)
Definition: environment.cpp:23
std::map< int, std::weak_ptr< const stream_interface > > _streams
Definition: environment.h:62
#define PRIVATE_TESTABLE
Definition: src/types.h:264
void override_extrinsics(const stream_interface &from, const stream_interface &to, rs2_extrinsics const &extr)
Definition: environment.cpp:55
void register_extrinsics(const stream_interface &from, const stream_interface &to, std::weak_ptr< lazy< rs2_extrinsics >> extr)
Definition: environment.cpp:28
PRIVATE_TESTABLE int to
Definition: environment.h:54
extrinsics_graph _extrinsics
Definition: environment.h:85
Cross-stream extrinsics: encodes the topology describing how the different devices are oriented...
Definition: rs_sensor.h:96
int find_stream_profile(const stream_interface &p, bool add_if_not_there=true)
std::shared_ptr< lazy< rs2_extrinsics > > _id
Definition: environment.h:49
rs2_extrinsics extr
Definition: test-pose.cpp:258
bool try_fetch_extrinsics(const stream_interface &from, const stream_interface &to, rs2_extrinsics *extr)
std::atomic< int > _stream_id
Definition: environment.h:86
extrinsics_lock(const extrinsics_lock &lock)
Definition: environment.h:31


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