wip
parent
4a2bd133e0
commit
bf1844a2f5
|
@ -3,14 +3,15 @@
|
||||||
#include "watcher.h"
|
#include "watcher.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cassert>
|
#include <cassert>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
//namespace celutil
|
//namespace celutil
|
||||||
//{
|
//{
|
||||||
template<typename T> class Watchable
|
template<typename T> class Watchable
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void addWatcher(Watcher<T>* watcher);
|
inline void addWatcher(Watcher<T>* watcher);
|
||||||
void removeWatcher(Watcher<T>* watcher);
|
inline void removeWatcher(Watcher<T>* watcher);
|
||||||
void notifyWatchers(int) const;
|
void notifyWatchers(int) const;
|
||||||
private:
|
private:
|
||||||
std::vector<Watcher<T>*> watchers;
|
std::vector<Watcher<T>*> watchers;
|
||||||
|
@ -24,9 +25,8 @@ template<typename T> void Watchable<T>::addWatcher(Watcher<T>* watcher)
|
||||||
|
|
||||||
template<typename T> void Watchable<T>::removeWatcher(Watcher<T>* watcher)
|
template<typename T> void Watchable<T>::removeWatcher(Watcher<T>* watcher)
|
||||||
{
|
{
|
||||||
auto iter = find(watchers.begin(), watchers.end(), watcher);
|
std::remove_if(watchers.begin(), watchers.end(),
|
||||||
if (iter != watchers.end())
|
[&watcher](Watcher<T>* w) { return w == watcher; });
|
||||||
watchers.erase(iter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T> void Watchable<T>::notifyWatchers(int property) const
|
template<typename T> void Watchable<T>::notifyWatchers(int property) const
|
||||||
|
|
Loading…
Reference in New Issue