GIFT-Grab  1708
Copyright (c) 2015-7, University College London (UCL)
gg::IObservable Class Reference

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>

Inheritance diagram for gg::IObservable:
IVideoSource

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
 

Detailed Description

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).

Attention
In Python: an intermediate node in a video processing pipeline should extend the IObservableObserver class (not available in C++) instead of IObservable and IObserver. Below is the source code for a sample processing node in Python.
from pygiftgrab import IObservableObserver
class MyProcNode(IObservableObserver):
def __init__(self):
super(MyProcNode, self).__init__()
def update(self, frame):
# Implement gg::IObserver::update(frame)
pass

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.

Constructor & Destructor Documentation

§ ~IObservable()

gg::IObservable::~IObservable ( )
virtual

Member Function Documentation

§ attach()

void gg::IObservable::attach ( IObserver observer)
virtual

Attach given observer to this observable. If observer already attached, no action is taken, no action is taken.

Parameters
observer
Exceptions
ObserverErrorwith a detailed message if attach attempt unsuccessful

§ attached()

bool gg::IObservable::attached ( const IObserver observer) const
protectednoexcept

Check whether passed observer is already attached. Because this function is protected, no thread-safety operation is performed inside it.

Parameters
observer
Returns
See also
_observers_lock

§ detach()

void gg::IObservable::detach ( IObserver observer)
virtual

Detach given observer from this observable.

Parameters
observer
Exceptions
ObserverErrorwith a detailed message if detach attempt unsuccessful

§ notify()

void gg::IObservable::notify ( VideoFrame frame)
virtualnoexcept

Notify all attached observers of new data.

Attention
In Python: This function is not available yet.
Parameters
frame

Member Data Documentation

§ _observers

std::vector< IObserver * > gg::IObservable::_observers
protected

§ _observers_lock

std::mutex gg::IObservable::_observers_lock
protected

The documentation for this class was generated from the following files: