-
Notifications
You must be signed in to change notification settings - Fork 0
/
StatNotifier.cpp
34 lines (27 loc) · 886 Bytes
/
StatNotifier.cpp
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
34
#include "DEBUG.h"
#include "StatNotifier.h"
#include "WalkStat.h"
#include "Events.h"
void StatNotifier::addStatObserver(WalkStat* O){
// add O to the list of StatObservers (to be notified)
StatObservers.insert(O);
}
void StatNotifier::unsubscribeFromAll(){
StatObservers.clear();
}
void StatNotifier::notifyEvent(Event& ev){
//DER("@@ notifying event...\n");
// notifies the StatObservers: let them noticeEvent()
typedef std::set<WalkStat*>::iterator soi;
for(soi it=StatObservers.begin(); it!=StatObservers.end(); ++it){
(*it)->noticeEvent(ev);
}
}
void StatNotifier::notifyRegeneration(){
//DER("@@ notifying regeneration!\n");
// notifies the StatObservers: let them update()
typedef std::set<WalkStat*>::iterator soi;
for(soi it=StatObservers.begin(); it!=StatObservers.end(); ++it){
(*it)->update();
}
}