Stream handler for synchronous streams. More...
#include <cvb/async/stream_handler_base.hpp>
Public Types | |
using | StreamType = STREAMTYPE |
Shorthand notation of the stream type. | |
using | StreamPtrType = std::shared_ptr<StreamType> |
Shorthand notation of the shared pointer of the specified stream. | |
using | StreamVectorType = std::vector<StreamPtrType> |
Shorthand notation of the container of the stream shared pointer. | |
using | DeliverableType = typename Internal::DeliverableTraits<STREAMTYPE>::type |
Shorthand notation of the stream deliverable type of the specified stream. | |
using | DeliverablePtrType = std::shared_ptr<typename Internal::DeliverableTraits<STREAMTYPE>::type> |
Shorthand notation of the shared pointer of the stream deliverable. | |
using | DeliverablePtrVectorType = std::vector<DeliverablePtrType> |
Shorthand notation of the container of the stream deliverable shared pointers. | |
using | EventHandlerType = std::function<void(DeliverablePtrType, Cvb::WaitStatus)> |
Shorthand notation of the event handler, a callable, type. | |
using | EventHandlerVectorType = std::vector<EventHandlerType> |
Shorthand notation of the container of the event handler. | |
Public Member Functions | |
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. | |
Static Public Member Functions | |
static std::unique_ptr< StreamHandlerBase > | Create (const StreamVectorType &streamVector) |
Create a stream handler object. | |
static std::unique_ptr< StreamHandlerBase > | Create (const StreamPtrType &stream) |
Create a stream handler object. | |
Protected Member Functions | |
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< STREAMTYPE >::type > > &waitResultVector) |
Asynchronously called for all acquired images. | |
virtual void | HandleAsyncWaitResult (const std::vector< WaitResultTuple< typename Internal::DeliverableTraits< STREAMTYPE >::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< StreamPtrType > | StreamVector () const noexcept |
Get the streams associated with this handler. | |
Stream handler for synchronous streams.
STREAMTYPE | Type of stream to be taken care of. |
|
inlineexplicitprotected |
Creates a stream handler object.
[in] | streamVector | List with synchronous streams. |
Any | exception derived from std::exception including CvbException. |
Call this in a customized subclass to setup the handler.
|
inlineexplicitprotected |
Creates a stream handler object.
[in] | stream | Synchronous stream. |
Any | exception derived from std::exception including CvbException. |
Call this in a customized subclass to setup the handler.
|
inlineprotectedvirtualnoexcept |
Performs custom operations at the beginning of the acquisition thread.
Does | not throw any exception. |
The default implementation does nothing. Be aware, that this method is called from the acquisition thread. Reimplemented it to setup resources that require the acquisition thread up and running. This is useful for interaction with Qt. E.g. you may create QObject derived classes here to archive correct thread affinity.
|
inlinestatic |
Create a stream handler object.
[in] | stream | Synchronous stream. |
Any | exception derived from std::exception including CvbException. |
This overload can be helpful if it is obvious that the number of streams is limited to one.
|
inlinestatic |
Create a stream handler object.
[in] | streamVector | List with synchronous streams. |
Any | exception derived from std::exception including CvbException. |
|
inlineprotectedvirtualnoexcept |
Performs custom operations just before the end of the acquisition thread.
Does | not throw any exception. |
The default implementation does nothing. Be aware, that this method is called from the acquisition thread. Reimplemented it to free resources that have been allocated in Begin().
|
inline |
Stop the handler.
Any | exception derived from std::exception including CvbException this also includes the last error on the acquisition thread. |
This will stop the acquisition thread and call TearDown() on the calling thread. This blocks until the acquisition thread has finished, so blocking in a customized HandleAsyncStream() method can lead to deadlocks.
|
inlineprotectedvirtual |
Asynchronously called for all registered streams.
[in] | streamVector | List with synchronous streams (provided at creation). |
Any | exception derived from std::exception including CvbException. |
The default implementation just waits for the next image on each stream.
|
inlineprotectedvirtual |
Asynchronously called for all acquired images.
[in] | waitResultVector | List with synchronous acquired WaitResults. |
Any | exception derived from std::exception including CvbException. |
The default implementation does nothing.
|
inlineprotectedvirtual |
Asynchronously called for all acquired images.
[in] | waitResultVector | List with synchronous acquired WaitResults. |
Any | exception derived from std::exception including CvbException. |
The default implementation does nothing.
|
inlineprotectedvirtualnoexcept |
Handles standard exceptions in the acquisition thread.
[in] | &error | The exception thrown. |
Does | not throw any exception. |
This handler is called for all not explicitly handled standard exception in the acquisition thread. After the handler returned the acquisition thread may finish, but remain in the active state. Be aware that this handler is by default called from the acquisition thread.
|
inlinenoexcept |
Check if the acquisition thread is running.
Does | not throw any exception. |
|
inline |
Start the handler.
Any | exception derived from std::exception including CvbException. |
This will call Setup() on the calling thread, before creating a dedicated acquisition thread. The acquisition thread will repeatedly call HandleAsyncStream().
|
inlineprotectedvirtual |
Setup the streams for acquisition.
[in] | streamVector | List with synchronous streams (provided at creation). |
Any | exception derived from std::exception including CvbException. |
The default implementation just calls Stream::Start() for each stream.
|
inlineprotectednoexcept |
Get the streams associated with this handler.
Does | not throw any exception. |
|
inlineprotectedvirtualnoexcept |
Tear down the streams after acquisition.
[in] | streamVector | List with synchronous streams (provided at creation). |
Does | not throw any exception. |
The default implementation just calls Stream::TryAbort() for each stream.
|
inlinenoexcept |
Stop the handler.
Does | not throw any exception. |
This will stop the acquisition thread and call TearDown() on the calling thread. This blocks until the acquisition thread has finished, so blocking in a customized HandleAsyncStream() method can lead to deadlocks.
We use cookies to improve your experience. By using this documentation, you agree to our use of cookies.