Loading...
Searching...
No Matches
Observable.qc.dox.h
// -*- mode: c++; indent-tabs-mode: nil -*-
namespace DataProvider {
class Observable {
public:
protected:
hash<string, hash<ObserverEventInfo>> observer_map;
public:
registerObserver(Observer observer);
registerObserver(object observer);
registerObserverWithFilter(Observer observer, AbstractEventFilter filter);
registerObserverWithFilter(object observer, AbstractEventFilter filter);
bool deregisterObserver(Observer observer);
bool deregisterObserver(object observer);
notifyObservers(string event_id, hash<auto> data_);
log(int level, string fmt);
protected:
hash<ObserverEventInfo> registerObserverEventsArgs(hash<ObserverEventInfo> info, list<auto> events);
public:
};
class DelayedObservable : public Observable {
public:
abstract observersReady();
};
class AbstractEventFilter {
public:
abstract bool filter(string event_id, hash<auto> event);
};
};
// private namespace; not exported
namespace Priv {
// Stores an observer with any subscribed events
hashdecl ObserverEventInfo {
// Observer
Observer observer;
# event filter object
*AbstractEventFilter filter;
# Map of subscribed event IDs; if the map is empty, then all events are registered
hash<string, bool> event_map;
}
// wraps a foreign observer object as an Observer
class ObserverWrapper : public Observer {
public:
protected:
object obj;
public:
// creates the wrapper object
constructor(object obj);
// calls the wrapped object's update method
update(string event_id, hash<auto> data_);
};
};
DataProvider::AbstractEventFilter
This abstract class can be used to filter events that are raised on an Observer.
Definition: Observable.qc.dox.h:130
DataProvider::AbstractEventFilter::filter
abstract bool filter(string event_id, hash< auto > event)
If this returns True, then the event is raised.
DataProvider::DelayedObservable
This class represents an observable subject that waits for external confirmation before raising event...
Definition: Observable.qc.dox.h:120
DataProvider::DelayedObservable::observersReady
abstract observersReady()
Called when all observers have been added to the object.
DataProvider::Observable
This class represents an observable subject that will notify all of its registered observers.
Definition: Observable.qc.dox.h:28
DataProvider::Observable::registerObserverEventsArgs
hash< ObserverEventInfo > registerObserverEventsArgs(hash< ObserverEventInfo > info, list< auto > events)
Registers observer events.
DataProvider::Observable::registerObserverWithFilter
registerObserverWithFilter(object observer, AbstractEventFilter filter)
The method registers the given observer.
DataProvider::Observable::registerObserver
registerObserver(object observer)
The method registers the given observer.
DataProvider::Observable::registerObserver
registerObserver(Observer observer)
The method registers the given observer.
DataProvider::Observable::registerObserverWithFilter
registerObserverWithFilter(Observer observer, AbstractEventFilter filter)
The method registers the given observer.
DataProvider::Observable::log
log(int level, string fmt)
Reimplement this method to implement logging.
DataProvider::Observable::observer_map
hash< string, hash< ObserverEventInfo > > observer_map
maps from object hash -> object
Definition: Observable.qc.dox.h:33
DataProvider::Observable::deregisterObserver
bool deregisterObserver(Observer observer)
The method deregisters the given observer.
DataProvider::Observable::deregisterObserver
bool deregisterObserver(object observer)
The method deregisters the given observer.
DataProvider::Observable::notifyObservers
notifyObservers(string event_id, hash< auto > data_)
The method notifies all subscribed observers.
DataProvider::Observer
This abstract class represents an observer that will get notified by the subject it observes.
Definition: Observer.qc.dox.h:26
DataProvider
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27