observable |
The os_observable class implements the Observer pattern. It represents an observable object which can have one or more observers. An observer can be any class object which can register a callback function with the observable object. When an observable object changes, an application calling notify_observers()
method on the observable, will cause all of its observers to be notified of the change by a call to the callback function registered by the observers. The order in which the observers are notified is unspecified. The observer object does not have to inherit from any specific class in order to become an observer.
Use of member template feature in the add, remove, and notify observer methods gives the flexibility of not having the observer and observable classes to inherit from a specific interface
class. Therefore, the compiler must be able to support member templates and OS_ENABLE_MEMBER_TEMPLATE_FEATURES
must be defined to use these classes.
Framework<ToolKit>
#include <ospace/framework/observable.h>
template< class Observable >
class os_observable
notify_observers() method should be invoked to inform the observers.notify_observers() method is called. This observable object will be passed as the first argument to the callback function.notify_observers( Arg ) method is called.
When the
callback function is invoked, this observable object will be passed as
its first argument and the second argument will be the first argument passed
to the notify_observers( Arg ) method.Copyright©1994-2026 Recursion
Software LLC
All Rights Reserved - For use by licensed users only.