| Qore DataProvider Module Reference 3.2.2

Loading...
Searching...
No Matches
Observable.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
24
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
63 registerObserverArgs(Observer observer, *list<auto> event_ids);
64
65
67
72 registerObserverArgs(object observer, *list<auto> event_ids);
73
74
76
83 registerObserverWithFilter(Observer observer, AbstractEventFilter filter, ...);
84
85
87
94 registerObserverWithFilter(object observer, AbstractEventFilter filter, ...);
95
96
98
104 registerObserverWithFilterArgs(Observer observer, AbstractEventFilter filter, *list<auto> event_ids);
105
106
108
114 registerObserverWithFilter(object observer, AbstractEventFilter filter, list<auto> event_ids);
115
116
118
122 bool deregisterObserver(Observer observer);
123
124
126
132 bool deregisterObserver(object observer);
133
134
136
139 notifyObservers(string event_id, hash<auto> data_);
140
141
143
147 log(int level, string fmt, ...);
148
149
151
153 bool isActive();
154
155
157 protected:
158 hash<ObserverEventInfo> registerObserverEventsArgs(hash<ObserverEventInfo> info, list<auto> events);
159 public:
160
161};
162
164 class DelayedObservable : public Observable {
165
166 public:
168
170 abstract observersReady();
171
173
175 stopEvents();
176
177};
178
180 class AbstractEventFilter : public Qore::Serializable {
181
182 public:
184 abstract bool filter(string event_id, hash<auto> event);
185};
186};
187
188// private namespace; not exported
189 namespace Priv {
190// Stores an observer with any subscribed events
191hashdecl ObserverEventInfo {
192 // Observer
193 Observer observer;
194
195 // event filter object
196 *AbstractEventFilter filter;
197
198 // Map of subscribed event IDs; if the map is empty, then all events are registered
199 hash<string, bool> event_map;
200}
201
202// wraps a foreign observer object as an Observer
203 class ObserverWrapper : public Observer {
204
205 public:
206 protected:
207 object obj;
208
209 public:
210
211 // creates the wrapper object
212 constructor(object obj);
213
214
215 // calls the wrapped object's update method
216 update(string event_id, hash<auto> data_);
217
218};
219}
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
Qore::Serializable
DataProvider
Qore AbstractDataField class definition.
Definition AbstractDataField.qc.dox.h:27
Priv
Private definitions.
Definition AbstractDataProviderType.qc.dox.h:454