#include <ObserverEvent.h>
Public Types | |
typedef Unique::Value_t | ID_t |
Public Member Functions | |
ObserverEvent (int event) | |
ObserverEvent (const ObserverEvent &oe) | |
ObserverEvent & | operator= (const ObserverEvent &oe) |
virtual | ~ObserverEvent () |
int | event () const |
ID_t | ID () const |
Static Public Member Functions | |
static ID_t | nullID () |
In this pattern, there are two sets of objects:
When the Observer<T> is initialized, it should call the 'attach' method of all Observable<T> objects it needs to watch. When the Observable changes in some way, for example when it changes state is or is deleted, the Observable will call the 'notify' method of all the Obserers registered with it. An Observer<T> can stop watching an object, by calling the 'detach' method of that Observable.
ObserverEvent is the type of object passed to the notify method. It contains an integer indicating the event "code", that classes can examine and use to downcast the event if necessary. There is also a version of notify that just takes an integer; this is wrapped in an ObserverEvent, and passed on.
If you have an event that requires some more information beyond just an event code, make a subclass of ObserverEvent and have the Observer's that get that event cast the event object to the proper type.
ObserverEvent's also have a unique ID value, obtained via the ID() method, with type ObserverEvent::ID_t
typedef Unique::Value_t ObserverEvent::ID_t |
ObserverEvent::ObserverEvent | ( | int | event | ) | [inline] |
ObserverEvent::ObserverEvent | ( | const ObserverEvent & | oe | ) | [inline] |
virtual ObserverEvent::~ObserverEvent | ( | ) | [inline, virtual] |
ObserverEvent& ObserverEvent::operator= | ( | const ObserverEvent & | oe | ) | [inline] |
int ObserverEvent::event | ( | ) | const [inline] |
Referenced by operator=().
ID_t ObserverEvent::ID | ( | ) | const [inline] |
Referenced by operator=().
static ID_t ObserverEvent::nullID | ( | ) | [inline, static] |
Referenced by DataBlockPtr< IndirectionList< int > >::dynamicID().