![]() |
ImFusion C++ SDK 4.4.0
|
Bundling Multiple Streams Together. More...
Bundling Multiple Streams Together.
Stream groups provide a mechanism to bundle multiple related streams into a single logical unit, enabling synchronized data handling and coordinated stream control across multiple data sources.
A StreamGroup consists of a proxy stream and an arbitrary number of substreams. The proxy stream acts as the representative and controller for all substreams, managing their lifecycle and coordinating their operation. This architecture is particularly useful when dealing with multi-sensor devices or systems that need to present multiple synchronized data streams.
Key characteristics:
The stream group architecture consists of several key components:
The proxy stream can be any class deriving from Stream (e.g., ImageStream, TrackingStream) or Stream itself. It serves as the main entry point for controlling the entire stream group. The proxy stream may represent the primary data source or serve as a purely organizational container. When implemented as a concrete stream type, the proxy stream can emit its own StreamData alongside the substream data.
Substreams are owned by the stream group and implement the SubstreamBase interface. They appear as child nodes in the data model, bundled under the proxy stream. While grouped together, they remain accessible individually or as a subset for processing. Substreams are tightly bound to the proxy stream lifecycle. There are two main types of substreams:
The CompoundStreamData class bundles StreamData from all streams in the group. It contains:
The stream group emits CompoundStreamData via signalNewStreamGroupData for processing all streams together, while individual stream data is also emitted through each stream's signalStreamData for individual access. This dual emission strategy allows receivers to work with the bundled stream group as a whole or access individual substreams as needed.
To create a custom stream group, inherit from both a Stream class and the StreamGroup template using CRTP: /
To bundle multiple independent streams, use SubstreamWrapper:
Substreams can be added or removed at any time after construction:
Stream groups are designed with thread safety in mind:
Example of safe usage in doWork():
Stream groups are particularly useful for:
The SDK provides several example implementations:
Classes | |
| class | ImFusion::CompoundStreamData |
| Container for StreamData from the individual Streams of a StreamGroup. More... | |
| class | ImFusion::SubstreamBase |
| Non-templated base class for substreams in a StreamGroup. More... | |
| class | ImFusion::StreamGroupBase |
| Non-templated base class for stream groups. More... | |
| class | ImFusion::StreamGroup< Proxy > |
| Templated stream group class for bundling multiple streams using the CRTP pattern. More... | |
| class | ImFusion::Substream< BaseStream > |
| Template class for creating dummy substreams fully controlled by the proxy stream. More... | |
| class | ImFusion::TrackingSubstream |
| Dummy tracking substream for use in StreamGroups. More... | |
| class | ImFusion::SubstreamWrapper |
| Generic wrapper to integrate an existing Stream into a StreamGroup as a substream. More... | |
Typedefs | |
| using | ImFusion::ImageSubstream = Substream<ImageStream> |
| Dummy image substream for use in StreamGroups. | |
| using ImFusion::ImageSubstream = Substream<ImageStream> |
#include <ImFusion/Stream/StreamGroup.h>
Dummy image substream for use in StreamGroups.
ImageSubstream is a specialization of Substream for ImageStream, providing a lightweight image stream that is fully controlled by the proxy stream. Use this when the proxy stream handles image acquisition and you need to expose the image data as a separate stream.