| Qore DataProvider Module Reference 2.7.1

Observable.qc.dox.h
1 // -*- mode: c++; indent-tabs-mode: nil -*-
3
26 namespace DataProvider {
28 class Observable {
29
30 public:
31 protected:
33 hash<string, hash<ObserverEventInfo>> observer_map;
34
35 public:
36
38
44 registerObserver(Observer observer);
45
46
48
54 registerObserver(object observer);
55
56
58
65 registerObserverWithFilter(Observer observer, AbstractEventFilter filter);
66
67
69
76 registerObserverWithFilter(object observer, AbstractEventFilter filter);
77
78
80
84 bool deregisterObserver(Observer observer);
85
86
88
94 bool deregisterObserver(object observer);
95
96
98
101 notifyObservers(string event_id, hash<auto> data_);
102
103
105
109 log(int level, string fmt);
110
111
113 protected:
114 hash<ObserverEventInfo> registerObserverEventsArgs(hash<ObserverEventInfo> info, list<auto> events);
115 public:
116
117 };
118
120 class DelayedObservable : public Observable {
121
122 public:
124
126 abstract observersReady();
127 };
128
130 class AbstractEventFilter {
131
132 public:
134 abstract bool filter(string event_id, hash<auto> event);
135 };
136 };
137
138 // private namespace; not exported
139 namespace Priv {
140 // Stores an observer with any subscribed events
141 hashdecl ObserverEventInfo {
142 // Observer
143 Observer observer;
144
145 # event filter object
146 *AbstractEventFilter filter;
147
148 # Map of subscribed event IDs; if the map is empty, then all events are registered
149 hash<string, bool> event_map;
150 }
151
152 // wraps a foreign observer object as an Observer
153 class ObserverWrapper : public Observer {
154
155 public:
156 protected:
157 object obj;
158
159 public:
160
161 // creates the wrapper object
162 constructor(object obj);
163
164
165 // calls the wrapped object's update method
166 update(string event_id, hash<auto> data_);
167
168 };
169 };
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::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::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