CVB++ 15.0
image_stream.hpp
1#pragma once
2
3#include <memory>
4
5#include "composite_stream_base.hpp"
6#include "multi_part_image.hpp"
7
8namespace Cvb
9{
10
11 CVB_BEGIN_INLINE_NS
12
13 namespace Driver
14 {
15
17
18 class ImageStream : public CompositeStreamBase
19 {
20 public:
21 using GuardType = HandleGuard<CompositeStreamBase>;
22
23 ImageStream(HandleGuard<CompositeStreamBase> &&guard, PrivateTag, const DevicePtr &device = {})
24 : CompositeStreamBase(device, std::move(guard))
25 {
26 }
27
29
35 template <class Rep, class Period>
37 CancellationToken &token)
38 {
39 return CreateWaitResult(InternalWaitFor<Image>(timeSpan, token));
40 }
41
43
48 template <class Rep, class Period>
50 {
51 return CreateWaitResult(InternalWaitFor<Image>(timeSpan));
52 }
53
55
61 {
62 return CreateWaitResult(InternalWait<Image>(token));
63 }
64
66
71 {
72 return CreateWaitResult(InternalWait<Image>());
73 }
74
75 private:
76 WaitResultTuple<MultiPartImage> CreateWaitResult(WaitResultBase<Image> &&waitResultBase)
77 {
78 HandleGuard<Image> guard(nullptr);
79 WaitStatus waitStatus = WaitStatus::Ok;
80 std::tie(guard, waitStatus) = std::move(waitResultBase);
81 if (!guard.Handle())
83 else
84 {
85 if (!CVB_CALL_CAPI(IsImage(guard.Handle())))
86 throw std::runtime_error("acquired composite is not an image");
88 return std::make_tuple(image, waitStatus, NodeMapEnumerator::FromObject(*image));
89 }
90 }
91 };
92
93 } // namespace Driver
94
96
97 CVB_END_INLINE_NS
98
99} // namespace Cvb
A token to enable cancellation on wait operations.
Definition cancellation_token.hpp:20
Streams images.
Definition image_stream.hpp:19
WaitResultTuple< MultiPartImage > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan, CancellationToken &token)
Waits for the given time span for the next acquired image.
Definition image_stream.hpp:36
WaitResultTuple< MultiPartImage > Wait(const CancellationToken &token)
Waits for ever for the next acquired image.
Definition image_stream.hpp:60
WaitResultTuple< MultiPartImage > Wait()
Waits for ever for the next acquired image.
Definition image_stream.hpp:70
WaitResultTuple< MultiPartImage > WaitFor(const std::chrono::duration< Rep, Period > &timeSpan)
Waits for the given time span for the next acquired image.
Definition image_stream.hpp:49
Lazy enumeration of node maps.
Definition node_map_enumerator.hpp:30
static std::unique_ptr< Image > FromHandle(HandleGuard< Image > &&guard)
Creates an image from a classic API handle.
Definition decl_image.hpp:155
static NodeMapEnumerator FromObject(const T &object)
Create a node map enumerator for a given object.
Definition node_map_enumerator.hpp:98
cvbbool_t IsImage(IMG Image)
T make_tuple(T... args)
T move(T... args)
Namespace for driver or device related operations.
Definition decl_composite.hpp:26
std::shared_ptr< MultiPartImage > MultiPartImagePtr
Convenience shared pointer for StreamImage.
Definition driver.hpp:88
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_barcode.h:15
WaitStatus
Status after waiting for an image to be returned.
Definition global.hpp:375
@ Ok
Everything is fine, a new image arrived.
Definition global.hpp:377
std::shared_ptr< Device > DevicePtr
Convenience shared pointer for Device.
Definition global.hpp:94
T tie(T... args)