Qore DataProvider Module Reference 2.7.5
Loading...
Searching...
No Matches
Observable.qc.dox.h
1// -*- mode: c++; indent-tabs-mode: nil -*-
3
26namespace DataProvider {
29
30public:
31protected:
33 hash<string, hash<ObserverEventInfo>> observer_map;
34
35public:
36
38
45
46
48
54 registerObserver(object observer);
55
56
58
66
67
69
77
78
80
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
113protected:
114 hash<ObserverEventInfo> registerObserverEventsArgs(hash<ObserverEventInfo> info, list<auto> events);
115public:
116
117};
118
121
122public:
124
126 abstract observersReady();
127};
128
131
132public:
134 abstract bool filter(string event_id, hash<auto> event);
135};
136};
137
138// private namespace; not exported
139namespace Priv {
140// Stores an observer with any subscribed events
141hashdecl 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
153class ObserverWrapper : public Observer {
154
155public:
156protected:
157 object obj;
158
159public:
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};
This abstract class can be used to filter events that are raised on an Observer.
Definition: Observable.qc.dox.h:130
abstract bool filter(string event_id, hash< auto > event)
If this returns True, then the event is raised.
This class represents an observable subject that waits for external confirmation before raising event...
Definition: Observable.qc.dox.h:120
abstract observersReady()
Called when all observers have been added to the object.
This class represents an observable subject that will notify all of its registered observers.
Definition: Observable.qc.dox.h:28
hash< ObserverEventInfo > registerObserverEventsArgs(hash< ObserverEventInfo > info, list< auto > events)
Registers observer events.
registerObserverWithFilter(object observer, AbstractEventFilter filter)
The method registers the given observer.
registerObserver(object observer)
The method registers the given observer.
registerObserver(Observer observer)
The method registers the given observer.
registerObserverWithFilter(Observer observer, AbstractEventFilter filter)
The method registers the given observer.
log(int level, string fmt)
Reimplement this method to implement logging.
hash< string, hash< ObserverEventInfo > > observer_map
maps from object hash -> object
Definition: Observable.qc.dox.h:33
bool deregisterObserver(Observer observer)
The method deregisters the given observer.
bool deregisterObserver(object observer)
The method deregisters the given observer.
notifyObservers(string event_id, hash< auto > data_)
The method notifies all subscribed observers.
This abstract class represents an observer that will get notified by the subject it observes.
Definition: Observer.qc.dox.h:26
Qore AbstractDataField class definition.
Definition: AbstractDataField.qc.dox.h:27