Interface for listeners in a simulation model. More...
#include <clistener.h>
Public Member Functions | |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, bool b)=0 |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, long l)=0 |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, unsigned long l)=0 |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, double d)=0 |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, const SimTime &t)=0 |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, const char *s)=0 |
virtual void | receiveSignal (cComponent *source, simsignal_t signalID, cObject *obj)=0 |
virtual void | finish (cComponent *component, simsignal_t signalID) |
virtual void | subscribedTo (cComponent *component, simsignal_t signalID) |
virtual void | unsubscribedFrom (cComponent *component, simsignal_t signalID) |
int | getSubscribeCount () const |
Friends | |
class | cComponent |
class | cResultFilter |
Interface for listeners in a simulation model.
This class performs subscription counting, in order to make sure that when the destructor runs, the object is no longer subscribed anywhere.
virtual void cIListener::finish | ( | cComponent * | component, | |
simsignal_t | signalID | |||
) | [inline, virtual] |
Called by a component on its local listeners after the component's finish() method was called.
If the listener is subscribed to multiple signals or at multiple components, the method will be called multiple times. Note that finish() methods in general are not invoked if the simulation terminates with an error.
Reimplemented in cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
cObject * | obj | |||
) | [pure virtual] |
Receive an emitted cObject value.
See receiveSignal(cComponent*,simsignal_t,bool) for more info.
Implemented in cListener, and cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
const char * | s | |||
) | [pure virtual] |
Receive an emitted string value.
See receiveSignal(cComponent*,simsignal_t,bool) for more info.
Implemented in cListener, and cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
const SimTime & | t | |||
) | [pure virtual] |
Receive an emitted simtime_t value.
See receiveSignal(cComponent*,simsignal_t,bool) for more info.
Implemented in cListener, and cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
double | d | |||
) | [pure virtual] |
Receive an emitted double value.
See receiveSignal(cComponent*,simsignal_t,bool) for more info.
Implemented in cListener, and cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
unsigned long | l | |||
) | [pure virtual] |
Receive an emitted unsigned long value.
See receiveSignal(cComponent*,simsignal_t,bool) for more info.
Implemented in cListener, and cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
long | l | |||
) | [pure virtual] |
Receive an emitted long value.
See receiveSignal(cComponent*,simsignal_t,bool) for more info.
Implemented in cListener, and cResultListener.
virtual void cIListener::receiveSignal | ( | cComponent * | source, | |
simsignal_t | signalID, | |||
bool | b | |||
) | [pure virtual] |
Receive an emitted signal.
Note that cIListener declares several overloaded receiveSignal() methods, one for each data type (except that all integer types are merged to the long and unsigned long types). The "source" argument is the channel or module on which the emit() method was invoked, and NOT the one at which this listener is subscribed.
It is not allowed inside a receiveSignal() call to unsubscribe from the signal being received -- it will cause an error to be thrown. (This is to prevent interesting cases when the listener list is being modified while the component iterates on it. The alternative would be to make a temporary copy of the listener list each time, but this is not desirable for performance reasons.)
Implemented in cListener, and cResultListener.
virtual void cIListener::subscribedTo | ( | cComponent * | component, | |
simsignal_t | signalID | |||
) | [inline, virtual] |
Called when this object was added to the given component's given signal as a listener.
Note that this method will only be called from subscribe() if this listener was not already subscribed.
Reimplemented in cResultListener.
virtual void cIListener::unsubscribedFrom | ( | cComponent * | component, | |
simsignal_t | signalID | |||
) | [inline, virtual] |
Called when this object was removed from the given component's listener list for the given signal.
Note that it will not be called from unsubscribe() if this listener was not actually subscribed before.
This method is also called from cComponent's destructor for all listeners, so at this point it is not safe to cast the component pointer to any other type. Also, the method may be called several times (i.e. if the listener was subscribed to multiple signals).
It is OK for the listener to delete itself in this method (delete this
). However, since this method may be called more than once if the listener is subscribed multiple times (see above), one must be careful to prevent double deletion, e.g. by reference counting.
Reimplemented in cResultListener.