Commit a011caa4 authored by Guillaume Roguez's avatar Guillaume Roguez
Browse files

#29564: video: rename Observator to Observer

parent 352db40f
...@@ -57,7 +57,7 @@ enum VideoPixelFormat { ...@@ -57,7 +57,7 @@ enum VideoPixelFormat {
namespace sfl_video { namespace sfl_video {
template <typename T> class Observator; template <typename T> class Observer;
template <typename T> class Observable; template <typename T> class Observable;
class VideoFrame; class VideoFrame;
...@@ -74,39 +74,39 @@ template <typename T> ...@@ -74,39 +74,39 @@ template <typename T>
class Observable class Observable
{ {
public: public:
Observable() : observators_(), mutex_() {} Observable() : observers_(), mutex_() {}
virtual ~Observable() {}; virtual ~Observable() {};
void attach(Observator<T>* o) { void attach(Observer<T>* o) {
std::unique_lock<std::mutex> lk(mutex_); std::unique_lock<std::mutex> lk(mutex_);
observators_.insert(o); observers_.insert(o);
} }
void detach(Observator<T>* o) { void detach(Observer<T>* o) {
std::unique_lock<std::mutex> lk(mutex_); std::unique_lock<std::mutex> lk(mutex_);
observators_.erase(o); observers_.erase(o);
} }
void notify(T& data) { void notify(T& data) {
std::unique_lock<std::mutex> lk(mutex_); std::unique_lock<std::mutex> lk(mutex_);
for (auto observator : observators_) for (auto observer : observers_)
observator->update(this, data); observer->update(this, data);
} }
private: private:
NON_COPYABLE(Observable<T>); NON_COPYABLE(Observable<T>);
std::set<Observator<T>*> observators_; std::set<Observer<T>*> observers_;
std::mutex mutex_; // lock observators_ std::mutex mutex_; // lock observers_
}; };
/*=== Observator =============================================================*/ /*=== Observer =============================================================*/
template <typename T> template <typename T>
class Observator class Observer
{ {
public: public:
virtual ~Observator() {}; virtual ~Observer() {};
virtual void update(Observable<T>*, T&) = 0; virtual void update(Observable<T>*, T&) = 0;
}; };
...@@ -196,7 +196,7 @@ class VideoFrameActiveWriter : ...@@ -196,7 +196,7 @@ class VideoFrameActiveWriter :
{}; {};
class VideoFramePassiveReader : class VideoFramePassiveReader :
public Observator<VideoFrameSP>, public Observer<VideoFrameSP>,
public VideoNode public VideoNode
{}; {};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment