CVB++ 14.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
11CVB_BEGIN_INLINE_NS
12
13namespace 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
152using Driver::PointCloudStream;
153
154CVB_END_INLINE_NS
155
156}
157
A token to enable cancellation on wait operations.
Definition: cancellation_token.hpp:20
Base class of all composite based streams.
Definition: decl_composite_stream_base.hpp:32
Streams point clouds.
Definition: point_cloud_stream.hpp:20
WaitResultTuple< PointCloud > Wait(const CancellationToken &token)
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:88
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< T > Wait(const CancellationToken &token)
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:110
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()
Waits for ever for the next acquired point cloud.
Definition: point_cloud_stream.hpp:98
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:122
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
Lazy enumeration of node maps.
Definition: node_map_enumerator.hpp:31
static NodeMapEnumerator FromObject(const T &object)
Create a node map enumerator for a given object.
Definition: node_map_enumerator.hpp:71
Root namespace for the Image Manager interface.
Definition: c_barcode.h:24
WaitStatus
Status after waiting for an image to be returned.
Definition: global.hpp:351