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