diff --git a/include/Observer.hpp b/include/Observer.hpp new file mode 100644 index 0000000..220bf42 --- /dev/null +++ b/include/Observer.hpp @@ -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 diff --git a/include/Subject.cpp b/include/Subject.cpp new file mode 100644 index 0000000..59057e7 --- /dev/null +++ b/include/Subject.cpp @@ -0,0 +1,23 @@ +#ifndef SUBJECT_HPP +#define SUBJECT_HPP + +#include + +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 \ No newline at end of file