Every IVideoSource that broadcasts video frames needs to implement this interface, which defines the observable (subject / publisher) part of the observer design pattern (aka subscriber-publisher). More...
#include <iobservable.h>
Public Member Functions | |
virtual | ~IObservable () |
virtual void | attach (IObserver &observer) |
Attach given observer to this observable. If observer already attached, no action is taken, no action is taken. More... | |
virtual void | detach (IObserver &observer) |
Detach given observer from this observable. More... | |
virtual void | notify (VideoFrame &frame) noexcept |
Notify all attached observers of new data. More... | |
Protected Member Functions | |
bool | attached (const IObserver &observer) const noexcept |
Check whether passed observer is already attached. Because this function is protected, no thread-safety operation is performed inside it. More... | |
Protected Attributes | |
std::vector< IObserver *> | _observers |
std::mutex | _observers_lock |
Every IVideoSource that broadcasts video frames needs to implement this interface, which defines the observable (subject / publisher) part of the observer design pattern (aka subscriber-publisher).
IObservableObserver
class (not available in C++) instead of IObservable and IObserver. Below is the source code for a sample processing node in Python.Note that no new buffer is created when broadcasting data, i.e. every IObserver is responsible for ensuring data is promptly copied to their own data buffer.
|
virtual |
|
virtual |
Attach given observer to this observable. If observer already attached, no action is taken, no action is taken.
observer |
ObserverError | with a detailed message if attach attempt unsuccessful |
|
protectednoexcept |
Check whether passed observer is already attached. Because this function is protected, no thread-safety operation is performed inside it.
observer |
|
virtual |
Detach given observer from this observable.
observer |
ObserverError | with a detailed message if detach attempt unsuccessful |
|
virtualnoexcept |
Notify all attached observers of new data.
frame |
|
protected |
|
protected |