CVB++ 15.0

Handler object for multiple synchronous streams. More...

#include <cvb/async/multi_stream_handler.hpp>

Inherits StreamHandlerBase< Stream >.

Inherited by SingleStreamHandler.

Static Public Member Functions

static std::unique_ptr< MultiStreamHandlerCreate (const std::vector< Driver::StreamPtr > &streamVector)
 Create a stream handler object.
 
- Static Public Member Functions inherited from StreamHandlerBase< Stream >
static std::unique_ptr< StreamHandlerBaseCreate (const StreamVectorType &streamVector)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamPtrType &stream)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamVectorType &streamVector)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamPtrType &stream)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamVectorType &streamVector)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamPtrType &stream)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamVectorType &streamVector)
 Create a stream handler object.
 
static std::unique_ptr< StreamHandlerBaseCreate (const StreamPtrType &stream)
 Create a stream handler object.
 

Protected Member Functions

 MultiStreamHandler (const std::vector< Driver::StreamPtr > &streamVector)
 Creates a stream handler object.
 
- Protected Member Functions inherited from StreamHandlerBase< Stream >
virtual void HandleAsyncStream (const StreamVectorType &streamVector)
 Asynchronously called for all registered streams.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResult< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResultTuple< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void Setup (const StreamVectorType streamVector)
 Setup the streams for acquisition.
 
virtual void TearDown (const StreamVectorType streamVector) noexcept
 Tear down the streams after acquisition.
 
virtual void HandleError (const std::exception &error) noexcept
 Handles standard exceptions in the acquisition thread.
 
virtual void Begin () noexcept
 Performs custom operations at the beginning of the acquisition thread.
 
virtual void End () noexcept
 Performs custom operations just before the end of the acquisition thread.
 
 StreamHandlerBase (const StreamVectorType &streamVector)
 Creates a stream handler object.
 
 StreamHandlerBase (const StreamPtrType &stream)
 Creates a stream handler object.
 
std::vector< StreamPtrTypeStreamVector () const noexcept
 Get the streams associated with this handler.
 
 StreamHandlerBase (const StreamVectorType &streamVector)
 Creates a stream handler object.
 
 StreamHandlerBase (const StreamPtrType &stream)
 Creates a stream handler object.
 
virtual void HandleAsyncStream (const StreamVectorType &streamVector)
 Asynchronously called for all registered streams.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResult< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResultTuple< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void Setup (const StreamVectorType streamVector)
 Setup the streams for acquisition.
 
virtual void TearDown (const StreamVectorType streamVector) noexcept
 Tear down the streams after acquisition.
 
virtual void HandleError (const std::exception &error) noexcept
 Handles standard exceptions in the acquisition thread.
 
virtual void Begin () noexcept
 Performs custom operations at the beginning of the acquisition thread.
 
virtual void End () noexcept
 Performs custom operations just before the end of the acquisition thread.
 
std::vector< StreamPtrTypeStreamVector () const noexcept
 Get the streams associated with this handler.
 
 StreamHandlerBase (const StreamVectorType &streamVector)
 Creates a stream handler object.
 
 StreamHandlerBase (const StreamPtrType &stream)
 Creates a stream handler object.
 
virtual void HandleAsyncStream (const StreamVectorType &streamVector)
 Asynchronously called for all registered streams.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResult< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResultTuple< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void Setup (const StreamVectorType streamVector)
 Setup the streams for acquisition.
 
virtual void TearDown (const StreamVectorType streamVector) noexcept
 Tear down the streams after acquisition.
 
virtual void HandleError (const std::exception &error) noexcept
 Handles standard exceptions in the acquisition thread.
 
virtual void Begin () noexcept
 Performs custom operations at the beginning of the acquisition thread.
 
virtual void End () noexcept
 Performs custom operations just before the end of the acquisition thread.
 
std::vector< StreamPtrTypeStreamVector () const noexcept
 Get the streams associated with this handler.
 
 StreamHandlerBase (const StreamVectorType &streamVector)
 Creates a stream handler object.
 
 StreamHandlerBase (const StreamPtrType &stream)
 Creates a stream handler object.
 
virtual void HandleAsyncStream (const StreamVectorType &streamVector)
 Asynchronously called for all registered streams.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResult< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void HandleAsyncWaitResult (const std::vector< WaitResultTuple< typename Internal::DeliverableTraits< Stream >::type > > &waitResultVector)
 Asynchronously called for all acquired images.
 
virtual void Setup (const StreamVectorType streamVector)
 Setup the streams for acquisition.
 
virtual void TearDown (const StreamVectorType streamVector) noexcept
 Tear down the streams after acquisition.
 
virtual void HandleError (const std::exception &error) noexcept
 Handles standard exceptions in the acquisition thread.
 
virtual void Begin () noexcept
 Performs custom operations at the beginning of the acquisition thread.
 
virtual void End () noexcept
 Performs custom operations just before the end of the acquisition thread.
 
std::vector< StreamPtrTypeStreamVector () const noexcept
 Get the streams associated with this handler.
 

Additional Inherited Members

- Public Types inherited from StreamHandlerBase< Stream >
using StreamType
 Shorthand notation of the stream type.
 
using StreamPtrType
 Shorthand notation of the shared pointer of the specified stream.
 
using StreamVectorType
 Shorthand notation of the container of the stream shared pointer.
 
using DeliverableType
 Shorthand notation of the stream deliverable type of the specified stream.
 
using DeliverablePtrType
 Shorthand notation of the shared pointer of the stream deliverable.
 
using DeliverablePtrVectorType
 Shorthand notation of the container of the stream deliverable shared pointers.
 
using EventHandlerType
 Shorthand notation of the event handler, a callable, type.
 
using EventHandlerVectorType
 Shorthand notation of the container of the event handler.
 
using StreamType
 Shorthand notation of the stream type.
 
using StreamPtrType
 Shorthand notation of the shared pointer of the specified stream.
 
using StreamVectorType
 Shorthand notation of the container of the stream shared pointer.
 
using DeliverableType
 Shorthand notation of the stream deliverable type of the specified stream.
 
using DeliverablePtrType
 Shorthand notation of the shared pointer of the stream deliverable.
 
using DeliverablePtrVectorType
 Shorthand notation of the container of the stream deliverable shared pointers.
 
using EventHandlerType
 Shorthand notation of the event handler, a callable, type.
 
using EventHandlerVectorType
 Shorthand notation of the container of the event handler.
 
using StreamType
 Shorthand notation of the stream type.
 
using StreamPtrType
 Shorthand notation of the shared pointer of the specified stream.
 
using StreamVectorType
 Shorthand notation of the container of the stream shared pointer.
 
using DeliverableType
 Shorthand notation of the stream deliverable type of the specified stream.
 
using DeliverablePtrType
 Shorthand notation of the shared pointer of the stream deliverable.
 
using DeliverablePtrVectorType
 Shorthand notation of the container of the stream deliverable shared pointers.
 
using EventHandlerType
 Shorthand notation of the event handler, a callable, type.
 
using EventHandlerVectorType
 Shorthand notation of the container of the event handler.
 
- Public Member Functions inherited from StreamHandlerBase< Stream >
void Run ()
 Start the handler.
 
bool TryFinish () noexcept
 Stop the handler.
 
void Finish ()
 Stop the handler.
 
bool IsActive () const noexcept
 Check if the acquisition thread is running.
 
void Run ()
 Start the handler.
 
bool TryFinish () noexcept
 Stop the handler.
 
void Finish ()
 Stop the handler.
 
bool IsActive () const noexcept
 Check if the acquisition thread is running.
 
void Run ()
 Start the handler.
 
bool TryFinish () noexcept
 Stop the handler.
 
void Finish ()
 Stop the handler.
 
bool IsActive () const noexcept
 Check if the acquisition thread is running.
 
void Run ()
 Start the handler.
 
bool TryFinish () noexcept
 Stop the handler.
 
void Finish ()
 Stop the handler.
 
bool IsActive () const noexcept
 Check if the acquisition thread is running.
 

Detailed Description

Handler object for multiple synchronous streams.

This handler provides a convenient way to acquire images from multiple synchronous streams within a dedicated thread. All streams for this handler must be synchronously (exactly the same frame rate). If this is not the case you will loose images. Please be aware, that there is no way for the application to verify, that the streams are synchronized. For multiple devices usually an external electrical synchronizations mechanism is provided.

For a single stream see SingleStreamHandler.

Example:
class MyMultiStreamHandler
{
public:
MyMultiStreamHandler(const std::vector<Cvb::StreamPtr> & streamVector)
:MultiStreamHandler(streamVector)
{
}
private:
void HandleAsyncStream(const std::vector<Cvb::StreamPtr> &streamVector) override
{
auto readData = 0;
for (auto & stream : streamVector)
{
auto result = stream->WaitFor<Cvb::RingBufferImage>(std::chrono::milliseconds(500));
// Do something.
}
}
};
Handler object for multiple synchronous streams.
Definition decl_multi_stream_handler.hpp:58
virtual void HandleAsyncStream(const StreamVectorType &streamVector)
Stream image that is returned, when the ring buffer interface is available on a device.
Definition decl_ring_buffer_image.hpp:24

Constructor & Destructor Documentation

◆ MultiStreamHandler()

MultiStreamHandler ( const std::vector< Driver::StreamPtr > & streamVector)
inlineexplicitprotected

Creates a stream handler object.

Parameters
[in]streamVectorList with synchronous streams.
Exceptions
Anyexception derived from std::exception including CvbException.

Call this in a customized subclass to setup the handler.

Member Function Documentation

◆ Create()

static std::unique_ptr< MultiStreamHandler > Create ( const std::vector< Driver::StreamPtr > & streamVector)
inlinestatic

Create a stream handler object.

Parameters
[in]streamVectorList with synchronous streams.
Returns
A stream handler object.
Exceptions
Anyexception derived from std::exception including CvbException.
Note
You must not destroy a stream handler that is currently running. In order to prevent that you may use a StreamHandlerGuard.