Dillo
signal.hh
Go to the documentation of this file.
1 #ifndef __LOUT_SIGNALS_HH__
2 #define __LOUT_SIGNALS_HH__
3 
4 #include "object.hh"
5 #include "container.hh"
6 
7 namespace lout {
8 
179 namespace signal {
180 
181 class Receiver;
182 
212 class Emitter: public object::Object
213 {
214  friend class Receiver;
215 
216 private:
218 
219  void unconnect (Receiver *receiver);
220 
221 protected:
222  void emitVoid (int signalNo, int argc, Object **argv);
223  bool emitBool (int signalNo, int argc, Object **argv);
224  void connect(Receiver *receiver);
225 
235  virtual bool emitToReceiver (Receiver *receiver, int signalNo,
236  int argc, Object **argv) = 0;
237 
238 public:
239  Emitter();
240  ~Emitter();
241 
243 };
244 
254 {
255  friend class Emitter;
256 
257 private:
259 
260  void connectTo(Emitter *emitter);
261  void unconnectFrom(Emitter *emitter);
262 
263 public:
264  Receiver();
265  ~Receiver();
266 
268 };
269 
275 {
276 public:
278  {
279  public:
280  virtual void deleted (ObservedObject *object) = 0;
281  };
282 
283 private:
285  {
286  protected:
287  bool emitToReceiver (signal::Receiver *receiver, int signalNo,
288  int argc, Object **argv);
289 
290  public:
291  inline void connectDeletion (DeletionReceiver *receiver)
292  { connect (receiver); }
293 
294  void emitDeletion (ObservedObject *obj);
295  };
296 
298 
299 public:
300  virtual ~ObservedObject();
301 
302  inline void connectDeletion (DeletionReceiver *receiver)
303  { deletionEmitter.connectDeletion (receiver); }
304 };
305 
306 } // namespace signal
307 
308 } // namespace lout
309 
310 #endif // __LOUT_SIGNALS_HH__
virtual void deleted(ObservedObject *object)=0
bool emitToReceiver(signal::Receiver *receiver, int signalNo, int argc, Object **argv)
A sub class must implement this for a call to a single receiver.
Definition: signal.cc:147
~Emitter()
Definition: signal.cc:38
DeletionEmitter deletionEmitter
Definition: signal.hh:297
container::typed::List< Receiver > * receivers
Definition: signal.hh:217
A class for fast concatenation of a large number of strings.
Definition: misc.hh:565
void unconnectFrom(Emitter *emitter)
Definition: signal.cc:138
void connect(Receiver *receiver)
Connect a receiver to the emitter.
Definition: signal.cc:65
void connectDeletion(DeletionReceiver *receiver)
Definition: signal.hh:291
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
The base class for signal emitters.
Definition: signal.hh:212
void unconnect(Receiver *receiver)
Definition: signal.cc:54
container::typed::List< Emitter > * emitters
Definition: signal.hh:258
The base class for signal receiver base classes.
Definition: signal.hh:253
~Receiver()
Definition: signal.cc:118
An observed object has a signal emitter, which tells the receivers, when the object is deleted...
Definition: signal.hh:274
Definition: container.cc:27
bool emitBool(int signalNo, int argc, Object **argv)
Emit a boolean signal.
Definition: signal.cc:91
void connectTo(Emitter *emitter)
Definition: signal.cc:133
virtual ~ObservedObject()
Definition: signal.cc:164
void emitDeletion(ObservedObject *obj)
Definition: signal.cc:157
void connectDeletion(DeletionReceiver *receiver)
Definition: signal.hh:302
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: signal.cc:127
Emitter()
Definition: signal.cc:33
void emitVoid(int signalNo, int argc, Object **argv)
Emit a void signal.
Definition: signal.cc:77
Typed version of container::untyped::List.
Definition: container.hh:463
virtual bool emitToReceiver(Receiver *receiver, int signalNo, int argc, Object **argv)=0
A sub class must implement this for a call to a single receiver.
Receiver()
Definition: signal.cc:113
void intoStringBuffer(misc::StringBuffer *sb)
Store a textual representation of the object in a misc::StringBuffer.
Definition: signal.cc:47