ImFusion SDK 4.3
StreamGroup< Proxy > Class Template Reference

#include <ImFusion/Stream/StreamGroup.h>

Templated stream group class to extend a proxy stream to a StreamGroup with the CRTP pattern. More...

+ Inheritance diagram for StreamGroup< Proxy >:

Detailed Description

template<class Proxy>
class ImFusion::StreamGroup< Proxy >

Templated stream group class to extend a proxy stream to a StreamGroup with the CRTP pattern.

The proxy stream can be any class deriving from Stream (e.g., ImageStream, TrackingStream, etc.) or Stream itself. The StreamGroup handles an arbitrary set of Substream#s implementing the SubstreamBase interface, whereby the proxy stream owns and controls the substreams and may serve as representative of all streams. Substreams can be added, removed or moved at any time after construction.

Example implementation for a tracking stream with two image streams as substreams

class ExampleStreamGroup : public TrackingStream, public StreamGroup<ExampleStreamGroup>
{
ExampleStreamGroup::ExampleStreamGroup()
: TrackingStream("Example Tracking Proxy Stream")
{
addSubstream(std::make_unique<ImageSubstream>(this, "Example Image Substream (1)"));
addSubstream(std::make_unique<ImageSubstream>(this, "Example Image Substream (2)"));
}
}
bool addSubstream(std::unique_ptr< SubstreamBase > substream) override
Adds a substream to the stream group.
Definition StreamGroup.h:247
Specialization of Stream for streams producing tracking data for spatial localization.
Definition TrackingStream.h:28
T make_unique(T... args)
See also
Substream, SubstreamWrapper

Public Member Functions

 StreamGroup (StreamGroup &&) noexcept
 
StreamGroupoperator= (StreamGroup &&other) noexcept
 
StreamproxyStream () override
 Convenience method to cast the stream group to the proxy stream.
 
DataList children () const override
 Returns substreams as a non-owning data list implementing the CompoundData interface.
 
std::vector< Stream * > substreams () const override
 Returns the substreams.
 
- Public Member Functions inherited from SignalReceiver
 SignalReceiver ()=default
 Default constructor.
 
 SignalReceiver (const SignalReceiver &other)
 Copy constructor, does not copy any existing signal connections from other.
 
SignalReceiveroperator= (SignalReceiver rhs)
 Assignment operator, disconnects all existing connections, does not copy any existing signal connections from rhs.
 
virtual ~SignalReceiver ()
 Virtual destructor disconnects from all connected signals.
 

Protected Member Functions

bool addSubstream (std::unique_ptr< SubstreamBase > substream) override
 Adds a substream to the stream group.
 
bool removeSubstream (Stream *substream) override
 Removes a substream from the stream group.
 
void emitMainAndSubSignals (std::shared_ptr< const CompoundStreamData > tuple, bool emitSubstreamSignals=true)
 
- Protected Member Functions inherited from StreamGroupBase
void reassignSubstream (SubstreamBase *substream)
 Reassigns child to this (needed for move operator)
 
- Protected Member Functions inherited from NotCopyable
 NotCopyable (NotCopyable &&) noexcept=default
 
NotCopyableoperator= (NotCopyable &&) noexcept=default
 
 NotCopyable (const NotCopyable &)=delete
 
NotCopyableoperator= (const NotCopyable &)=delete
 
- Protected Member Functions inherited from SignalReceiver
void disconnectAll ()
 Disconnects all existing connections.
 

Additional Inherited Members

- Public Attributes inherited from StreamGroupBase
ProtectedSignal< std::shared_ptr< const CompoundStreamData > > signalNewStreamGroupData
 Signal contains all StreamData from the substreams.
 
- Public Attributes inherited from CompoundData
Signal< Data * > signalChildAdded
 Signal emitted when a new Data instance has been added to children()
 
Signal< Data * > signalChildMoved
 Signal emitted when a Data instance has changed its position in children()
 
Signal< Data * > signalChildAboutToBeRemoved
 Signal emitted when a Data instance is about to be removed or taken from children()
 

Member Function Documentation

◆ proxyStream()

template<class Proxy>
Stream * proxyStream ( )
overridevirtual

Convenience method to cast the stream group to the proxy stream.

Implements StreamGroupBase.

◆ children()

template<class Proxy>
DataList children ( ) const
overridevirtual

Returns substreams as a non-owning data list implementing the CompoundData interface.

See the documentation of substreams for details on thread safety.

See also
CompoundData

Implements CompoundData.

◆ substreams()

template<class Proxy>
std::vector< Stream * > substreams ( ) const
overridevirtual

Returns the substreams.

It is guaranteed that the substreams are not deleted within a doWork call until emitMainAndSubSignals has finished, even if some of the substreams are removed from the substream list already during the method execution. The following code is fully safe:

doWork()
{
auto streams = substreams(); // Get a local copy of the substreams
// Here, another thread might remove a substream and the local copy is outdated: streams != substreams()
for (auto& s : streams())
{
// Do stuff with all the streams to prepare stream data.
}
CompoundStreamData sdt(proxyStreamData, streamData);
emitMainAndSubSignals(sdt); // The actual deletion of the removed substream occurs at the end of this call.
return WorkContinuation{nextIterationTime};
}
Container for StreamData from the individual Stream#s of a StreamGroup.
Definition CompoundStreamData.h:20
std::vector< Stream * > substreams() const override
Returns the substreams.
Definition StreamGroup.h:231

Implements StreamGroupBase.

◆ addSubstream()

template<class Proxy>
bool addSubstream ( std::unique_ptr< SubstreamBase > substream)
overrideprotectedvirtual

Adds a substream to the stream group.

Implements StreamGroupBase.

◆ removeSubstream()

template<class Proxy>
bool removeSubstream ( Stream * substream)
overrideprotectedvirtual

Removes a substream from the stream group.

The removal is always executed on the main thread since the data model cannot handle removal calls from any other thread. If this method is called on another thread the actual removal is invoked on the main thread.

Implements StreamGroupBase.


The documentation for this class was generated from the following file:
Search Tab / S to search, Esc to close