blob: 6ff8f3b47e6324ffb5edd5c8e73dc6107c96c240 (
plain)
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
|
#pragma once
#include <vector>
class Observer {
private:
public:
virtual void update();
};
class Subject {
private:
std::vector<Observer*> observers;
public:
// virtual void attach(Observer* obs) { observers.push_back(obs);}
virtual void attach(Observer* obs);
virtual void detach(Observer*);
virtual int size() { return this->observers.size(); }
// TODO possibly add foo input as update value?
virtual void notify();
// virtual void notify() {
// for (int i = 0; i < observers.size(); i++)
// observers.at(i)->update();
// }
};
|