point_cloud_stream.hpp
1 #pragma once
2 
3 #include <memory>
4 
5 #include "composite_stream_base.hpp"
6 #include "../point_cloud.hpp"
7 
8 namespace Cvb
9 {
10 
11 CVB_BEGIN_INLINE_NS
12 
13 namespace Driver
14 {
15 
17 
19  : public CompositeStreamBase
20 {
21  public:
22 
23  using GuardType = HandleGuard<CompositeStreamBase>;
24 
25  PointCloudStream(HandleGuard<CompositeStreamBase>&& guard, PrivateTag, const DevicePtr& device)
26  : CompositeStreamBase(device, std::move(guard))
27  {
28  }
29 
31 
37  template<class Rep, class Period>
39  {
40  return CreateWaitResult<PointCloud>(InternalWaitFor<PointCloud>(timeSpan, token));
41  }
42 
44 
49  template<class Rep, class Period>
51  {
52  return CreateWaitResult<PointCloud>(InternalWaitFor<PointCloud>(timeSpan));
53  }
54 
56 
62  template<class T, class Rep, class Period>
64  {
65  static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
66  return CreateWaitResult<T>(InternalWaitFor<PointCloud>(timeSpan, token));
67  }
68 
70 
75  template<class T, class Rep, class Period>
77  {
78  static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
79  return CreateWaitResult<T>(InternalWaitFor<PointCloud>(timeSpan));
80  }
81 
83 
89  {
90  return CreateWaitResult<PointCloud>(InternalWait<PointCloud>(token));
91  }
92 
94 
99  {
100  return CreateWaitResult<PointCloud>(InternalWait<PointCloud>());
101  }
102 
104 
109  template <class T>
111  {
112  static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
113  return CreateWaitResult<T>(InternalWait<PointCloud>(token));
114  }
115 
117 
121  template <class T>
123  {
124  static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
125  return CreateWaitResult<T>(InternalWait<PointCloud>());
126  }
127 
128  private:
129 
130  template<class T>
131  WaitResultTuple<T> CreateWaitResult(WaitResultBase<PointCloud>&& waitResultBase)
132  {
133  HandleGuard<PointCloud> guard(nullptr);
134  WaitStatus waitStatus;
135  std::tie(guard, waitStatus) = std::move(waitResultBase);
136  if (!guard.Handle())
137  return std::make_tuple(std::shared_ptr<T>(), waitStatus, NodeMapEnumerator());
138  else
139  {
140  CExports::CVCCompositePurpose purpose = CExports::CVCCP_Custom;
141  CVB_CALL_CAPI_CHECKED(CVCCompositeGetPurpose(guard.Handle(), purpose))
142  if (purpose != CExports::CVCCP_PointCloud)
143  throw std::runtime_error("acquired composite is not a point cloud");
144  auto pointCloud = T::FromHandle(std::move(guard));
145  return std::make_tuple(pointCloud, waitStatus, NodeMapEnumerator::FromObject(*pointCloud));
146  }
147  }
148 };
149 
150 }
151 
152 using Driver::PointCloudStream;
153 
154 CVB_END_INLINE_NS
155 
156 }
157 
WaitStatus
Status after waiting for an image to be returned.
Definition: global.hpp:350
Streams point clouds.
Definition: point_cloud_stream.hpp:18
WaitResultTuple< T > Wait(const CancellationToken &token)
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:110
Base class of all composite based streams.
Definition: decl_composite_stream_base.hpp:30
WaitResultTuple< T > Wait()
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:122
Root namespace for the Image Manager interface.
Definition: version.hpp:11
Lazy enumeration of node maps.
Definition: node_map_enumerator.hpp:30
WaitResultTuple< T > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan)
Waits for the given time span for the next acquired point cloud.
Definition: point_cloud_stream.hpp:76
WaitResultTuple< PointCloud > Wait(const CancellationToken &token)
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:88
WaitResultTuple< T > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan, const CancellationToken &token)
Waits for the given time span for the next acquired point cloud.
Definition: point_cloud_stream.hpp:63
WaitResultTuple< PointCloud > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan, const CancellationToken &token)
Waits for the given time span for the next acquired point cloud.
Definition: point_cloud_stream.hpp:38
A token to enable cancellation on wait operations.
Definition: cancellation_token.hpp:19
WaitResultTuple< PointCloud > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan)
Waits for the given time span for the next acquired point cloud.
Definition: point_cloud_stream.hpp:50
WaitResultTuple< PointCloud > Wait()
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:98