CVB++ 14.1
composite_stream.hpp
1#pragma once
2
3#include <memory>
4
5#include "composite_stream_base.hpp"
6#include "../composite.hpp"
7
8
9namespace Cvb
10{
11
12CVB_BEGIN_INLINE_NS
13
14namespace Driver
15{
16
18
20 : public CompositeStreamBase
21{
22 public:
23
24 using GuardType = HandleGuard<CompositeStreamBase>;
25
26 CompositeStream(HandleGuard<CompositeStreamBase>&& guard, PrivateTag, const DevicePtr& device)
27 : CompositeStreamBase(device, std::move(guard))
28 {
29 }
30
32
38 template<class Rep, class Period>
40 {
41 return CreateWaitResult(InternalWaitFor<Composite>(timeSpan, token));
42 }
43
45
50 template<class Rep, class Period>
52 {
53 return CreateWaitResult(InternalWaitFor<Composite>(timeSpan));
54 }
55
57
63 {
64 return CreateWaitResult(InternalWait<Composite>(token));
65 }
66
68
73 {
74 return CreateWaitResult(InternalWait<Composite>());
75 }
76
77 private:
78
79 WaitResultTuple<Composite> CreateWaitResult(WaitResultBase<Composite>&& waitResultBase)
80 {
81 HandleGuard<Composite> guard(nullptr);
82 WaitStatus waitStatus = WaitStatus::Ok;
83 std::tie(guard, waitStatus) = std::move(waitResultBase);
84 if (!guard.Handle())
85 return std::make_tuple(CompositePtr(), waitStatus, NodeMapEnumerator());
86 else
87 {
88 CompositePtr composite = Composite::FromHandle(std::move(guard));
89 return std::make_tuple(composite, waitStatus, NodeMapEnumerator::FromObject(*composite));
90 }
91 }
92};
93
94}
95
96using Driver::CompositeStream;
97
98CVB_END_INLINE_NS
99
100}
101
A token to enable cancellation on wait operations.
Definition: cancellation_token.hpp:20
static std::unique_ptr< Composite > FromHandle(HandleGuard< Composite > &&guard)
Creates a composite from a classic API handle.
Definition: decl_composite.hpp:104
Base class of all composite based streams.
Definition: decl_composite_stream_base.hpp:32
Streams composites.
Definition: composite_stream.hpp:21
WaitResultTuple< Composite > Wait()
Waits for ever for the next acquired composite.
Definition: composite_stream.hpp:72
WaitResultTuple< Composite > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan)
Waits for the given time span for the next acquired composite.
Definition: composite_stream.hpp:51
WaitResultTuple< Composite > Wait(const CancellationToken &token)
Waits for ever for the next acquired composite.
Definition: composite_stream.hpp:62
WaitResultTuple< Composite > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan, const CancellationToken &token)
Waits for the given time span for the next acquired composite.
Definition: composite_stream.hpp:39
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:88
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:376
@ Ok
Everything is fine, a new image arrived.
std::shared_ptr< Composite > CompositePtr
Convenience shared pointer for Composite.
Definition: global.hpp:100