Observer design pattern's Observer & Subject abstract classes

master
Denes Matetelki 13 years ago
parent a03968e42e
commit 970cb092d1

@ -0,0 +1,15 @@
#ifndef OBSERVER_HPP
#define OBSERVER_HPP
class Subject;
class Observer
{
public:
virtual ~Observer();
virtual void update( Subject* ) = 0;
};
#endif // OBSERVER_HPP

@ -0,0 +1,23 @@
#ifndef SUBJECT_HPP
#define SUBJECT_HPP
#include <list>
class Observer;
class Subject
{
public:
virtual ~Subject();
virtual void attach( Observer* );
virtual void detach( Observer* );
virtual void notify();
private:
std::list< Observer* > m_observers;
};
#endif // SUBJECT_HPP
Loading…
Cancel
Save