17 #ifndef KATABATIC_OBSERVER_H 18 #define KATABATIC_OBSERVER_H 20 #include "hurricane/Error.h" 31 virtual void notify (
unsigned int flags );
39 inline T* getOwner ()
const;
43 static int _ownerOffset;
55 throw Hurricane::Error(
"Observer::Observer(), attempt to create with NULL owner." );
58 _ownerOffset = (
unsigned long)
this - (
unsigned long)owner;
72 template<
typename T >
73 inline T* getObserver ();
76 inline void notify (
unsigned int flags );
89 template<
typename T >
92 if (_observer)
return (
dynamic_cast< Observer<T>*
>( _observer ))->getOwner();
99 throw Hurricane::Error(
"Observable::addObserver(), trying to add a second observer which is unsupported." );
100 _observer = observer;
105 if (_observer != observer)
106 throw Hurricane::Error(
"Observable::removeObserver(), trying to remove wrong observer." );
113 if (_observer) _observer->
notify( flags );
void removeObserver(BaseObserver *)
Definition: Observer.h:103
virtual void notify(unsigned int flags)
Definition: Observer.cpp:26
Observer Design Pattern, Subject part.
Definition: Observer.h:69
Observable()
Definition: Observer.h:84
The namespace dedicated to Katabatic.
Definition: Katabatic.dox:13
Observer(const T *owner)
Definition: Observer.h:51
void notify(unsigned int flags)
Definition: Observer.h:111
T * getOwner() const
Definition: Observer.h:63
void addObserver(BaseObserver *)
Definition: Observer.h:96
Observer Design Pattern, Observer part.
Definition: Observer.h:29
Observer Design Pattern, Observer part.
Definition: Observer.h:36
T * getObserver()
Definition: Observer.h:90