CVB++ 15.0
point_cloud_stream.hpp
1#pragma once
2
3#include <memory>
4
5#include "composite_stream_base.hpp"
6#include "../point_cloud.hpp"
7
8namespace Cvb
9{
10
11 CVB_BEGIN_INLINE_NS
12
13 namespace Driver
14 {
15
17
18 class PointCloudStream : public CompositeStreamBase
19 {
20 public:
21 using GuardType = HandleGuard<CompositeStreamBase>;
22
23 PointCloudStream(HandleGuard<CompositeStreamBase> &&guard, PrivateTag, const DevicePtr &device = {})
24 : CompositeStreamBase(device, std::move(guard))
25 {
26 }
27
29
35 template <class Rep, class Period>
37 const CancellationToken &token)
38 {
39 return CreateWaitResult<PointCloud>(InternalWaitFor<PointCloud>(timeSpan, token));
40 }
41
43
48 template <class Rep, class Period>
50 {
51 return CreateWaitResult<PointCloud>(InternalWaitFor<PointCloud>(timeSpan));
52 }
53
55
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
76 template <class T, class Rep, class Period>
78 {
79 static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
80 return CreateWaitResult<T>(InternalWaitFor<PointCloud>(timeSpan));
81 }
82
84
90 {
91 return CreateWaitResult<PointCloud>(InternalWait<PointCloud>(token));
92 }
93
95
100 {
101 return CreateWaitResult<PointCloud>(InternalWait<PointCloud>());
102 }
103
105
111 template <class T>
113 {
114 static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
115 return CreateWaitResult<T>(InternalWait<PointCloud>(token));
116 }
117
119
124 template <class T>
126 {
127 static_assert(std::is_base_of<PointCloud, T>::value, "CVB: PointCloud must be a base of T");
128 return CreateWaitResult<T>(InternalWait<PointCloud>());
129 }
130
131 private:
132 template <class T>
133 WaitResultTuple<T> CreateWaitResult(WaitResultBase<PointCloud> &&waitResultBase)
134 {
135 HandleGuard<PointCloud> guard(nullptr);
136 WaitStatus waitStatus = WaitStatus::Ok;
137 std::tie(guard, waitStatus) = std::move(waitResultBase);
138 if (!guard.Handle())
140 else
141 {
142 CExports::CVCCompositePurpose purpose = CExports::CVCCP_Custom;
143 CVB_CALL_CAPI_CHECKED(CVCCompositeGetPurpose(guard.Handle(), purpose))
144 if (purpose != CExports::CVCCP_PointCloud)
145 throw std::runtime_error("acquired composite is not a point cloud");
146 auto pointCloud = T::FromHandle(std::move(guard));
147 return std::make_tuple(pointCloud, waitStatus, NodeMapEnumerator::FromObject(*pointCloud));
148 }
149 }
150 };
151
152 } // namespace Driver
153
155
156 CVB_END_INLINE_NS
157
158} // namespace Cvb
A token to enable cancellation on wait operations.
Definition cancellation_token.hpp:20
Streams point clouds.
Definition point_cloud_stream.hpp:19
WaitResultTuple< PointCloud > Wait(const CancellationToken &token)
Waits for ever for the next acquired point cloud.
Definition point_cloud_stream.hpp:89
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:49
WaitResultTuple< T > Wait(const CancellationToken &token)
Waits for ever for the next acquired point cloud.
Definition point_cloud_stream.hpp:112
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:77
WaitResultTuple< PointCloud > Wait()
Waits for ever for the next acquired point cloud.
Definition point_cloud_stream.hpp:99
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< T > Wait()
Waits for ever for the next acquired point cloud.
Definition point_cloud_stream.hpp:125
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:36
Lazy enumeration of node maps.
Definition node_map_enumerator.hpp:30
static NodeMapEnumerator FromObject(const T &object)
Create a node map enumerator for a given object.
Definition node_map_enumerator.hpp:98
T make_tuple(T... args)
T move(T... args)
Namespace for driver or device related operations.
Definition decl_composite.hpp:27
std::tuple< std::shared_ptr< T >, WaitStatus, NodeMapEnumerator > WaitResultTuple
Tuple holding multiple return values after waiting for a specific payload data.
Definition driver.hpp:579
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
WaitStatus
Status after waiting for an image to be returned.
Definition global.hpp:396
@ Ok
Everything is fine, a new image arrived.
Definition global.hpp:398
std::shared_ptr< Device > DevicePtr
Convenience shared pointer for Device.
Definition global.hpp:98
T tie(T... args)