#include <observable.h>
Public Member Functions | |
void | addObserver (Observer< O, A > *o) |
int | countObservers () const |
void | deleteObserver (Observer< O, A > *o) |
void | deleteObservers () |
bool | hasChanged () const |
void | notifyObservers (A arg) |
Protected Member Functions | |
void | clearChanged () |
void | setChanged () |
Classes can report updates to a list of decoupled Observers by extending this class.
The O class parameter should be a pointer to the class of the observable itself, so it can be passed in a typesafe manner to the observers update method.
The A class can be any additional information to pass to observers. Observables that don't need to pass an argument when they update observers should use the default "NoArg" class for the second template parameter and pass nullptr to notifyObservers.