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, ...);
registerObserverArgs(Observer observer, *list<auto> event_ids);
registerObserverArgs(object observer, *list<auto> event_ids);
registerObserverWithFilter(Observer observer, AbstractEventFilter filter, ...);
registerObserverWithFilter(object observer, AbstractEventFilter filter, ...);
registerObserverWithFilterArgs(Observer observer, AbstractEventFilter filter, *list<auto> event_ids);
registerObserverWithFilter(object observer, AbstractEventFilter filter, list<auto> event_ids);
bool deregisterObserver(Observer observer);
bool deregisterObserver(object observer);
notifyObservers(string event_id, hash<auto> data_);
log(int level, string fmt, ...);
bool isActive();
protected:
hash<ObserverEventInfo> registerObserverEventsArgs(hash<ObserverEventInfo> info, list<auto> events);
public:
};
class DelayedObservable : public Observable {
public:
abstract observersReady();
stopEvents();
};
class AbstractEventFilter : public Qore::Serializable {
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:180
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:164
DataProvider::DelayedObservable::observersReady
abstract observersReady()
Called when all observers have been added to the object.
DataProvider::DelayedObservable::stopEvents
stopEvents()
Called to stop generating events.
DataProvider::Observable
This class represents an observable subject that will notify all of its registered observers.
Definition Observable.qc.dox.h:28
DataProvider::Observable::registerObserverWithFilter
registerObserverWithFilter(object observer, AbstractEventFilter filter,...)
The method registers the given observer.
DataProvider::Observable::registerObserverEventsArgs
hash< ObserverEventInfo > registerObserverEventsArgs(hash< ObserverEventInfo > info, list< auto > events)
Registers observer events.
DataProvider::Observable::registerObserverArgs
registerObserverArgs(object observer, *list< auto > event_ids)
The method registers the given observer.
DataProvider::Observable::registerObserverWithFilter
registerObserverWithFilter(object observer, AbstractEventFilter filter, list< auto > event_ids)
The method registers the given observer.
DataProvider::Observable::registerObserverWithFilterArgs
registerObserverWithFilterArgs(Observer observer, AbstractEventFilter filter, *list< auto > event_ids)
The method registers the given observer.
DataProvider::Observable::registerObserver
registerObserver(Observer observer,...)
The method registers the given observer.
DataProvider::Observable::registerObserverArgs
registerObserverArgs(Observer observer, *list< auto > event_ids)
The method registers the given observer.
DataProvider::Observable::log
log(int level, string fmt,...)
Reimplement this method to implement logging.
DataProvider::Observable::registerObserver
registerObserver(object observer,...)
The method registers the given observer.
DataProvider::Observable::registerObserverWithFilter
registerObserverWithFilter(Observer observer, AbstractEventFilter filter,...)
The method registers the given observer.
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::isActive
bool isActive()
Is this object still generating events.
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
Priv
Private definitions.
Definition AbstractDataProviderType.qc.dox.h:454