aboutsummaryrefslogtreecommitdiff
path: root/Observer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Observer.cpp')
-rw-r--r--Observer.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/Observer.cpp b/Observer.cpp
new file mode 100644
index 0000000..adc2f8d
--- /dev/null
+++ b/Observer.cpp
@@ -0,0 +1,19 @@
+#include "Observer.h"
+#include <iostream>
+
+void Observer::update(){
+ std::cout << 'a' << std::endl;
+}
+
+void Subject::attach(Observer* obs){
+ observers.push_back(obs);
+}
+void Subject::detach(Observer*){
+
+}
+
+// TODO possibly add foo input as update value?
+void Subject::notify() {
+ for (int i = 0; i < observers.size(); i++)
+ observers.at(i)->update();
+}