#include <Subject.hpp>
Inheritance diagram for Subject:
This abstract class contains methods for the attachment and detachment of observers to itself. When a class is a subclass of the Subject class, subclasses of the Observer class can register and unregister themselves as observers for the Subject subclass. The Subject subclass can then call the notify method to send notice about special events to all the observing classes.
The observers do not register for special events, instead, they are notified of all events and have to decide themselves if the triggered event is of interest to them or not.
Public Member Functions | |
Subject () | |
Constructor. | |
virtual | ~Subject () |
Destructor. | |
virtual void | attach (Observer *obs) |
Attach an observer. | |
virtual void | detach (Observer *obs) |
Detach an observer. | |
virtual void | notify (long msg, Item item=Item()) |
Notify observers of an event. | |
virtual std::list< Observer * > | get_observers () |
Get observer list. | |
Protected Attributes | |
std::list< Observer * > | observers |
A list of all registered observers. |
|
Constructor.
|
|
Destructor.
|
|
Attach an observer.
|
|
Detach an observer.
|
|
Get observer list.
|
|
Notify observers of an event. Usage example: Subject::notify(Message::new_node, Item(node));
|
|
A list of all registered observers.
|