#include <Observer.hpp>
Inheritance diagram for Observer:
This class has only one method: the update() method. It is called by the Subject subclasses to which the Observer subclass was attached. It contains a pointer to the subject, so that the subject which sent the update can be itentified. The message is a message code from the Message class. The message should always be checked for, because the update method will be called for all events in the Subject subclass. There is no guarantee that there will always be only the currently specified Messages.
An example implementation of the update method in a subclass of the Observer class could look like this:
// Subject* graph1, Subject* graph2 void update(Subject *sub, long msg, Item item) { if( sub == graph1 ) { if( msg == Message::new_node ) { // do something with item.node } else if( msg == Message::del_node ) { // do something with item.node before it's deleted } else if( msg == Message:del_node_done ) { // item has no valid members } } else if( sub == graph2 ) { // see above } }
Public Member Functions | |
Observer () | |
Empty Constructor. | |
virtual | ~Observer () |
Virtual destructor. | |
virtual void | update (Subject *sub, long msg, Item item)=0 |
Notification about an update. |
|
Empty Constructor.
|
|
Virtual destructor.
|
|
Notification about an update.
|