diff options
author | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-03-17 13:41:49 +0000 |
---|---|---|
committer | Vadim Dashevskiy <watcherhd@gmail.com> | 2013-03-17 13:41:49 +0000 |
commit | 5e6e1e8838fe7637ef588e0fb080ad07fc5700aa (patch) | |
tree | 2cc32c95da0cf49f8361879eec1fa5a4a4b557d8 /plugins/!NotAdopted/WinterSpeak/general/observer/subject.cpp | |
parent | 561f00a7d38c61ec30c5898b90766314011d32d8 (diff) |
Winter Speak plugin added (not adopted)
git-svn-id: http://svn.miranda-ng.org/main/trunk@4076 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/!NotAdopted/WinterSpeak/general/observer/subject.cpp')
-rw-r--r-- | plugins/!NotAdopted/WinterSpeak/general/observer/subject.cpp | 77 |
1 files changed, 77 insertions, 0 deletions
diff --git a/plugins/!NotAdopted/WinterSpeak/general/observer/subject.cpp b/plugins/!NotAdopted/WinterSpeak/general/observer/subject.cpp new file mode 100644 index 0000000000..e28c66c44b --- /dev/null +++ b/plugins/!NotAdopted/WinterSpeak/general/observer/subject.cpp @@ -0,0 +1,77 @@ +//==============================================================================
+// General Code, © 2002 Ryan Winter
+//==============================================================================
+ +#include "subject.h" +
+#include <general/debug/debug.h> + +//------------------------------------------------------------------------------ +// public: +//------------------------------------------------------------------------------ +Subject::Subject() + :
+ m_observer_list() +{ + CLASSCERR("Subject::Subject"); +} + +//------------------------------------------------------------------------------ +Subject::~Subject() +{ + CLASSCERR("Subject::~Subject"); +} + +//------------------------------------------------------------------------------ +void +Subject::notify() +{ + CLASSCERR("Subject::notify"); + + // call update for all observers in the list + for (std::list<Observer *>::iterator iter = m_observer_list.begin();
+ iter != m_observer_list.end();
+ ++iter)
+ {
+ (*iter)->update(*this);
+ }
+} + +//------------------------------------------------------------------------------ +void +Subject::attach(Observer &observer) +{ + CLASSCERR("Subject::attach(" << &observer << ")"); + + for (std::list<Observer *>::iterator iter = m_observer_list.begin();
+ iter != m_observer_list.end();
+ ++iter)
+ {
+ if (*iter == &observer)
+ {
+ return;
+ }
+ }
+
+ m_observer_list.push_back(&observer);
+} + +//------------------------------------------------------------------------------ +void +Subject::detach(const Observer &observer) +{ + CLASSCERR("Subject::detach(" << &observer << ")"); +
+ for (std::list<Observer *>::iterator iter = m_observer_list.begin();
+ iter != m_observer_list.end();
+ ++iter)
+ {
+ if (*iter == &observer)
+ {
+ m_observer_list.erase(iter);
+ }
+ }
+}
+ +//============================================================================== + |