- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathObserverPattern.h
More file actions
Latest commit
33 lines (30 loc) · 700 Bytes
/
Copy pathObserverPattern.h
File metadata and controls
33 lines (30 loc) · 700 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef OBSERVERPATTERN_H_INCLUDED
#defineOBSERVERPATTERN_H_INCLUDED
#include<iostream>
#include<set>
classObserver {
protected:
public:
virtualvoidNotify(int &receive) = 0;
};
classObservable {
protected:
static Observable *iInstance;
std::set<Observer*> observers;
Observable(){}
public:
static Observable *GetInstance();
voidAddObserver(Observer &observer);
voidRemoveObserver(Observer &observer);
voidNotifyObservers();
voidTriggerObservable();
};
classTestObserver : publicObserver {
protected:
Observable *observable;
public:
TestObserver();
~TestObserver();
voidNotify(int &receive);
};
#endif// OBSERVERPATTERN_H_INCLUDED