Stream handler for synchronous streams.
More...
#include <cvb/async/stream_handler_base.hpp>
|
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.
|
|
template<class STREAMTYPE>
class Cvb::Async::StreamHandlerBase< STREAMTYPE >
Stream handler for synchronous streams.
- Template Parameters
-
STREAMTYPE | Type of stream to be taken care of. |
- Examples
- Cvb/CppCompositeStreamHandler.
◆ StreamHandlerBase() [1/2]
Creates a stream handler object.
- Parameters
-
[in] | streamVector | List with synchronous streams. |
- Exceptions
-
Call this in a customized subclass to setup the handler.
◆ StreamHandlerBase() [2/2]
Creates a stream handler object.
- Parameters
-
[in] | stream | Synchronous stream. |
- Exceptions
-
Call this in a customized subclass to setup the handler.
◆ Begin()
|
inlineprotectedvirtualnoexcept |
Performs custom operations at the beginning of the acquisition thread.
- Exceptions
-
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.
◆ Create() [1/2]
Create a stream handler object.
- Parameters
-
[in] | stream | Synchronous stream. |
- Returns
- A stream handler object.
- Exceptions
-
This overload can be helpful if it is obvious that the number of streams is limited to one.
- Note
- You must not destroy a stream handler that is currently running. In order to prevent that you may use a StreamHandlerGuard.
◆ Create() [2/2]
Create a stream handler object.
- Parameters
-
[in] | streamVector | List with synchronous streams. |
- Returns
- A stream handler object.
- Exceptions
-
- Note
- You must not destroy a stream handler that is currently running. In order to prevent that you may use a StreamHandlerGuard.
- Examples
- Cvb/CppCompositeStreamHandler.
◆ End()
|
inlineprotectedvirtualnoexcept |
Performs custom operations just before the end of the acquisition thread.
- Exceptions
-
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().
◆ Finish()
Stop the handler.
- Exceptions
-
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.
- Note
- If the acquisition handler is destroyed it automatically finishes.
◆ HandleAsyncStream()
Asynchronously called for all registered streams.
- Parameters
-
[in] | streamVector | List with synchronous streams (provided at creation). |
- Exceptions
-
The default implementation just waits for the next image on each stream.
- Attention
- This method is called on a dedicated thread!
- Examples
- Cvb/CppCompositeStreamHandler.
◆ HandleAsyncWaitResult() [1/2]
void HandleAsyncWaitResult |
( |
const std::vector< WaitResult< typename Internal::DeliverableTraits< STREAMTYPE >::type > > & |
waitResultVector | ) |
|
|
inlineprotectedvirtual |
Asynchronously called for all acquired images.
- Parameters
-
[in] | waitResultVector | List with synchronous acquired WaitResults. |
- Exceptions
-
The default implementation does nothing.
- Attention
- This method is called on a dedicated thread!
- Examples
- Cvb/CppCompositeStreamHandler.
◆ HandleAsyncWaitResult() [2/2]
void HandleAsyncWaitResult |
( |
const std::vector< WaitResultTuple< typename Internal::DeliverableTraits< STREAMTYPE >::type > > & |
waitResultVector | ) |
|
|
inlineprotectedvirtual |
Asynchronously called for all acquired images.
- Parameters
-
[in] | waitResultVector | List with synchronous acquired WaitResults. |
- Exceptions
-
The default implementation does nothing.
- Attention
- This method is called on a dedicated thread!
◆ HandleError()
|
inlineprotectedvirtualnoexcept |
Handles standard exceptions in the acquisition thread.
- Parameters
-
[in] | &error | The exception thrown. |
- Exceptions
-
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.
- Note
- After this handler there will be no automatic call to TearDown(). So you have to call Finish() explicitly. If you reimplemented this handler you should call the default implementation so Finish() will deliver the error into the controlling thread, otherwise the error will be swallowed within the acquisition thread.
◆ IsActive()
Check if the acquisition thread is running.
- Returns
- True if running otherwise false.
- Exceptions
-
Does | not throw any exception. |
◆ Run()
Start the handler.
- Exceptions
-
This will call Setup() on the calling thread, before creating a dedicated acquisition thread. The acquisition thread will repeatedly call HandleAsyncStream().
◆ Setup()
Setup the streams for acquisition.
- Parameters
-
[in] | streamVector | List with synchronous streams (provided at creation). |
- Exceptions
-
The default implementation just calls Stream::Start() for each stream.
◆ StreamVector()
Get the streams associated with this handler.
- Returns
- Stream vector.
- Exceptions
-
Does | not throw any exception. |
◆ TearDown()
|
inlineprotectedvirtualnoexcept |
Tear down the streams after acquisition.
- Parameters
-
[in] | streamVector | List with synchronous streams (provided at creation). |
- Exceptions
-
Does | not throw any exception. |
The default implementation just calls Stream::TryAbort() for each stream.
◆ TryFinish()
Stop the handler.
- Returns
- True if no error occurred in the acquisition thread, otherwise.
- Exceptions
-
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.
- Note
- If the acquisition handler is destroyed it automatically finishes.