Class CObservable

Class Documentation

class CObservable

Inherit from this class for those objects capable of being observed by a CObserver class.

The only thing to do in your child class is to call CObservable::publishEvent() whenever needed and all the observer classes will be notified.

See also

CObserver, mrptEvent

Note

The pairs CObservable / CObserver automatically notify each other the destruction of any of them, effectively ending the subscription of events.

Public Functions

CObservable()
virtual ~CObservable()

Protected Functions

void publishEvent(const mrptEvent &e) const

Called when you want this object to emit an event to all the observers currently subscribed to this object.

inline bool hasSubscribers() const

Can be called by a derived class before preparing an event for publishing with publishEvent to determine if there is no one subscribed, so it can save the wasted time preparing an event that will be not read.