MNE-CPP
0.1.9
A Framework for Electrophysiology
src
libraries
utils
generics
observerpattern.cpp
Go to the documentation of this file.
1
//=============================================================================================================
36
//=============================================================================================================
37
// INCLUDES
38
//=============================================================================================================
39
40
#include "
observerpattern.h
"
41
42
using namespace
UTILSLIB;
43
44
//=============================================================================================================
45
// DEFINE MEMBER METHODS
46
//=============================================================================================================
47
48
Subject::~Subject
()
49
{
50
}
51
52
//=============================================================================================================
53
54
void
Subject::attach
(
IObserver
* pObserver)
55
{
56
m_Observers.insert(pObserver);
57
}
58
59
//=============================================================================================================
60
61
void
Subject::detach
(
IObserver
* pObserver)
62
{
63
m_Observers.erase(m_Observers.find(pObserver));
64
//m_Observers.erase(observer); //C++ <set> STL implementation
65
}
66
67
//=============================================================================================================
68
69
void
Subject::notify
()
70
{
71
if
(
notifyEnabled
)
72
{
73
t_Observers::const_iterator it = m_Observers.begin();
74
for
( ; it != m_Observers.end(); ++it)
75
(*it)->update(
this
);
76
// for(auto observer : m_Observers){
77
// observer->update(this);
78
// }
79
}
80
}
81
82
//=============================================================================================================
83
// STATIC DEFINITIONS
84
//=============================================================================================================
85
86
bool
Subject::notifyEnabled
=
true
;
UTILSLIB::Subject::attach
void attach(IObserver *pObserver)
Definition:
observerpattern.cpp:54
UTILSLIB::IObserver
The IObserver interface provides the base class of every observer of the observer design pattern.
Definition:
observerpattern.h:72
UTILSLIB::Subject::~Subject
virtual ~Subject()
Definition:
observerpattern.cpp:48
UTILSLIB::Subject::notifyEnabled
static bool notifyEnabled
Definition:
observerpattern.h:141
UTILSLIB::Subject::notify
void notify()
Definition:
observerpattern.cpp:69
UTILSLIB::Subject::detach
void detach(IObserver *pObserver)
Definition:
observerpattern.cpp:61
observerpattern.h
Contains declarations of the observer design pattern: Subject class and IObserver interface.
Generated on Wed Aug 9 2023 17:55:42 for MNE-CPP by
1.8.17