Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
lout::signal::Emitter Class Referenceabstract

The base class for signal emitters. More...

#include <signal.hh>

Public Member Functions

 Emitter ()
 
 ~Emitter ()
 
void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer.
 
- Public Member Functions inherited from lout::object::Object
virtual ~Object ()
 The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly.
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal.
 
virtual int hashValue ()
 Return a hash value for the object.
 
virtual Objectclone ()
 Return an exact copy of the object.
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object.
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses.
 

Protected Member Functions

void emitVoid (int signalNo, int argc, Object **argv)
 Emit a void signal.
 
bool emitBool (int signalNo, int argc, Object **argv)
 Emit a boolean signal.
 
void connect (Receiver *receiver)
 Connect a receiver to the emitter.
 
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.
 

Private Member Functions

void unconnect (Receiver *receiver)
 

Private Attributes

container::typed::List< Receiver > * receivers
 

Friends

class Receiver
 

Detailed Description

The base class for signal emitters.

If defining a signal group, a sub class of this class must be defined, with

There are two representations of signals:

  • In the unfolded representation, the signal itself is represented by the method itself (in the emitter or the receiver), and the arguments are represented as normal C++ types.

  • Folding signals means to represent the signal itself by an integer number (enumeration), and translate the arguments in an object::Object* array. (If a given argument is not an instance of object::Object*, the wrappers in object can be used.)
See also
signal

Definition at line 212 of file signal.hh.

Constructor & Destructor Documentation

◆ Emitter()

lout::signal::Emitter::Emitter ( )

Definition at line 33 of file signal.cc.

References receivers.

◆ ~Emitter()

lout::signal::Emitter::~Emitter ( )

Definition at line 38 of file signal.cc.

References receivers, and lout::signal::Receiver::unconnectFrom().

Member Function Documentation

◆ connect()

void lout::signal::Emitter::connect ( Receiver receiver)
protected

Connect a receiver to the emitter.

This is protected, a sub class should define a wrapper, with the respective receiver as an argument, to gain type safety.

Definition at line 65 of file signal.cc.

References lout::signal::Receiver::connectTo(), and receivers.

Referenced by dw::core::ui::Resource::ActivateEmitter::connectActivate(), dw::core::ui::Resource::ClickedEmitter::connectClicked(), lout::signal::ObservedObject::DeletionEmitter::connectDeletion(), dw::core::Layout::Emitter::connectLayout(), and dw::core::Layout::LinkEmitter::connectLink().

◆ emitBool()

bool lout::signal::Emitter::emitBool ( int  signalNo,
int  argc,
Object **  argv 
)
protected

Emit a boolean signal.

This method should be called by a wrapper, which folds the signal, delegates the emission to here, and returns the same boolean value.

Definition at line 91 of file signal.cc.

References emitToReceiver(), and receivers.

◆ emitToReceiver()

virtual bool lout::signal::Emitter::emitToReceiver ( Receiver receiver,
int  signalNo,
int  argc,
Object **  argv 
)
protectedpure virtual

A sub class must implement this for a call to a single receiver.

This methods gets the signal in a folded representation, it has to unfold it, and pass it to a single receiver. For boolean signals, the return value of the receiver must be returned, for void signals, the return value is discarded.

Implemented in dw::core::Layout::LinkEmitter, dw::core::Layout::Emitter, dw::core::ui::Resource::ActivateEmitter, dw::core::ui::Resource::ClickedEmitter, and lout::signal::ObservedObject::DeletionEmitter.

Referenced by emitBool(), and emitVoid().

◆ emitVoid()

void lout::signal::Emitter::emitVoid ( int  signalNo,
int  argc,
Object **  argv 
)
protected

Emit a void signal.

This method should be called by a wrapper (return value void), which folds the signal, and delegates the emission to here.

Definition at line 77 of file signal.cc.

References emitToReceiver(), and receivers.

◆ intoStringBuffer()

void lout::signal::Emitter::intoStringBuffer ( misc::StringBuffer sb)
virtual

Store a textual representation of the object in a misc::StringBuffer.

This is used by object::Object::toString.

Reimplemented from lout::object::Object.

Definition at line 47 of file signal.cc.

References lout::misc::StringBuffer::append(), and receivers.

◆ unconnect()

void lout::signal::Emitter::unconnect ( Receiver receiver)
private

Definition at line 54 of file signal.cc.

References receivers.

Referenced by lout::signal::Receiver::~Receiver().

Friends And Related Symbol Documentation

◆ Receiver

friend class Receiver
friend

Definition at line 214 of file signal.hh.

Member Data Documentation

◆ receivers

container::typed::List<Receiver>* lout::signal::Emitter::receivers
private

Definition at line 217 of file signal.hh.

Referenced by connect(), emitBool(), Emitter(), emitVoid(), intoStringBuffer(), unconnect(), and ~Emitter().


The documentation for this class was generated from the following files: