blob: ff523b8113a3e0286ecd3d158f89b3c74904964f (
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
|
#include <iostream>
#include "Observer.h"
void Observer::update(){
std::cout << 'a' << std::endl;
}
void Subject::attach(Observer * obs){
std::cout << "added" << std::endl;
this->observers.push_back(obs);
}
void Subject::detach(Observer *){
}
int Subject::size() {
std::cout << "subject list size " << this->observers.size() << std::endl;
return this->observers.size();
}
// TODO possibly add foo input as update value?
void Subject::notify() {
for (int i = 0; i < this->observers.size(); i++)
this->observers[i]->update();
}
|