3#include "../../global.hpp"
4#include "../../async/_decl/decl_stream_handler_base.hpp"
16 struct TpedStreamHandlerTraits<ImageStream>
18 using type = StreamHandlerBase<ImageStream>;
22 struct TpedStreamHandlerTraits<CompositeStream>
24 using type = StreamHandlerBase<CompositeStream>;
28 struct TpedStreamHandlerTraits<PointCloudStream>
30 using type = StreamHandlerBase<PointCloudStream>;
34 struct TpedStreamHandlerTraits<
Stream>
36 using type = StreamHandlerBase<Stream>;
41 template <
class STREAMTYPE>
42 inline StreamHandlerBase<STREAMTYPE>::~StreamHandlerBase()
44 assert((
"stream must be finished prior to destruction", !IsActive()));
47 template <
class STREAMTYPE>
57 thread_ = std::make_unique<std::thread>(
std::ref(*
this));
60 template <
class STREAMTYPE>
77 template <
class STREAMTYPE>
82 if (thread_ && thread_->joinable())
92 template <
class STREAMTYPE>
93 inline void StreamHandlerBase<STREAMTYPE>::operator()()
99 HandleAsyncStream(streamVector_);
115 std::vector<Driver::WaitResult<Driver::StreamImage>> waitResultVector;
116 waitResultVector.reserve(streamVector.size());
117 for (
auto &stream : streamVector)
118 waitResultVector.emplace_back(stream->Wait());
120 HandleAsyncWaitResult(waitResultVector);
122 catch (
const std::exception &error)
130 template <
class STREAMTYPE>
136 waitResultVector.reserve(streamVector.size());
137 for (
auto &stream : streamVector)
138 waitResultVector.emplace_back(stream->Wait());
150 template <
class STREAMTYPE>
157 template <
class STREAMTYPE>
164 template <
class STREAMTYPE>
167 for (
auto &stream : streamVector)
171 template <
class STREAMTYPE>
174 for (
auto &stream : streamVector)
178 template <
class STREAMTYPE>
184 template <
class STREAMTYPE>
185 inline StreamHandlerBase<STREAMTYPE>::StreamHandlerBase(
const StreamPtrType &stream)
189 streamVector[0] = stream;
190 streamVector.swap(streamVector_);
185 inline StreamHandlerBase<STREAMTYPE>::StreamHandlerBase(
const StreamPtrType &stream) {
…}
193 template <
class STREAMTYPE>
194 inline StreamHandlerBase<STREAMTYPE>::StreamHandlerBase(
const StreamVectorType &streamVector)
194 inline StreamHandlerBase<STREAMTYPE>::StreamHandlerBase(
const StreamVectorType &streamVector) {
…}
200 template <
class STREAMTYPE>
201 inline void StreamHandlerBase<STREAMTYPE>::BeginFinish()
205 TearDown(streamVector_);
208 template <
class STREAMTYPE>
209 inline void StreamHandlerBase<STREAMTYPE>::EndFinish()
std::shared_ptr< StreamType > StreamPtrType
Shorthand notation of the shared pointer of the specified stream.
Definition decl_stream_handler_base.hpp:98
bool TryFinish() noexcept
Stop the handler.
Definition detail_stream_handler_base.hpp:61
virtual void TearDown(const StreamVectorType streamVector) noexcept
Tear down the streams after acquisition.
Definition detail_stream_handler_base.hpp:172
virtual void HandleAsyncWaitResult(const std::vector< WaitResult< typename Internal::DeliverableTraits< STREAMTYPE >::type > > &waitResultVector)
Asynchronously called for all acquired images.
Definition detail_stream_handler_base.hpp:151
virtual void Setup(const StreamVectorType streamVector)
Setup the streams for acquisition.
Definition detail_stream_handler_base.hpp:165
std::vector< StreamPtrType > StreamVectorType
Shorthand notation of the container of the stream shared pointer.
Definition decl_stream_handler_base.hpp:101
void Run()
Start the handler.
Definition detail_stream_handler_base.hpp:48
bool IsActive() const noexcept
Check if the acquisition thread is running.
Definition decl_stream_handler_base.hpp:205
virtual void HandleError(const std::exception &error) noexcept
Handles standard exceptions in the acquisition thread.
Definition detail_stream_handler_base.hpp:179
void Finish()
Stop the handler.
Definition detail_stream_handler_base.hpp:78
virtual void HandleAsyncStream(const StreamVectorType &streamVector)
Asynchronously called for all registered streams.
Definition detail_stream_handler_base.hpp:131
T current_exception(T... args)
Convenience classes for asynchronous image acquisition.
Definition decl_multi_stream_handler.hpp:11
@ Stream
Definition driver.hpp:430
std::tuple< std::shared_ptr< T >, WaitStatus, NodeMapEnumerator > WaitResultTuple
Tuple holding multiple return values after waiting for a specific payload data.
Definition driver.hpp:577
Root namespace for the Image Manager interface.
Definition c_bayer_to_rgb.h:17
T rethrow_exception(T... args)
A combined result returned after waiting for a image.
Definition driver.hpp:391