50 #ifndef _OBSERVABLE_H_
51 #define _OBSERVABLE_H_
61 set<Observer*> observers;
66 pthread_mutex_lock(&vM);
68 pthread_mutex_unlock(&vM);
69 pthread_mutex_destroy(&vM);
73 void createObserversVector() {
74 pthread_mutex_init(&vM, NULL);
80 pthread_mutex_lock(&vM);
81 observers.insert(
object);
82 pthread_mutex_unlock(&vM);
85 void removeObserver(
Observer*
object) {
86 set<Observer*>::iterator i;
88 pthread_mutex_lock(&vM);
89 i = observers.find(
object);
90 if (i != observers.end()) {
93 pthread_mutex_unlock(&vM);
96 virtual void notifyObservers(
void*
object) {
97 set<Observer*>::iterator i;
99 pthread_mutex_lock(&vM);
100 i = observers.begin();
101 while (i != observers.end()) {
102 (*i)->update(
this,
object);
105 pthread_mutex_unlock(&vM);
109 #endif //_OBSERVABLE_H_
Definition: Observable.h:59
Definition: Observer.h:53