GIFT-Grab  1708
Copyright (c) 2015-7, University College London (UCL)
iobservable.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "iobserver.h"
4 #include <vector>
5 #include <mutex>
6 
7 namespace gg
8 {
9 
43 {
44 protected:
48  std::vector< IObserver * > _observers;
49 
53  std::mutex _observers_lock;
54 
55 public:
59  virtual ~IObservable();
60 
61 public:
70  virtual void attach(IObserver & observer);
71 
78  virtual void detach(IObserver & observer);
79 
88  virtual void notify(VideoFrame & frame) noexcept;
89 
90 protected:
99  bool attached(const IObserver & observer) const noexcept;
100 };
101 
102 }
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.
Definition: iobservable.cpp:53
virtual ~IObservable()
Definition: iobservable.cpp:11
virtual void detach(IObserver &observer)
Detach given observer from this observable.
Definition: iobservable.cpp:27
std::mutex _observers_lock
Definition: iobservable.h:53
Definition: broadcastdaemon.cpp:7
virtual void notify(VideoFrame &frame) noexcept
Notify all attached observers of new data.
Definition: iobservable.cpp:44
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).
Definition: iobservable.h:42
virtual void attach(IObserver &observer)
Attach given observer to this observable. If observer already attached, no action is taken...
Definition: iobservable.cpp:16
A class to represent a video frame.
Definition: videoframe.h:47
Every observer interested in listening to IVideoSource data must implement this interface, which defines the observer (subscriber) part of the observer design pattern (aka subscriber-publisher).
Definition: iobserver.h:35
std::vector< IObserver *> _observers
Definition: iobservable.h:48