clistener.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #ifndef __CLISTENER_H
00017 #define __CLISTENER_H
00018
00019 #include "simtime_t.h"
00020 #include "cobject.h"
00021
00022 NAMESPACE_BEGIN
00023
00024 class cComponent;
00025
00034 typedef int simsignal_t;
00035
00036 #define SIMSIGNAL_NULL ((simsignal_t)-1)
00037
00044 enum SimsignalType
00045 {
00046 SIMSIGNAL_UNDEF,
00047 SIMSIGNAL_BOOL,
00048 SIMSIGNAL_LONG,
00049 SIMSIGNAL_ULONG,
00050 SIMSIGNAL_DOUBLE,
00051 SIMSIGNAL_SIMTIME,
00052 SIMSIGNAL_STRING,
00053 SIMSIGNAL_OBJECT
00054 };
00055
00066 class SIM_API cIListener
00067 {
00068 friend class cComponent;
00069 friend class cResultFilter;
00070 private:
00071 int subscribecount;
00072 public:
00073 cIListener();
00074 virtual ~cIListener();
00075
00091 virtual void receiveSignal(cComponent *source, simsignal_t signalID, bool b) = 0;
00092
00094 virtual void receiveSignal(cComponent *source, simsignal_t signalID, long l) = 0;
00095
00097 virtual void receiveSignal(cComponent *source, simsignal_t signalID, unsigned long l) = 0;
00098
00100 virtual void receiveSignal(cComponent *source, simsignal_t signalID, double d) = 0;
00101
00103 virtual void receiveSignal(cComponent *source, simsignal_t signalID, const SimTime& t) = 0;
00104
00106 virtual void receiveSignal(cComponent *source, simsignal_t signalID, const char *s) = 0;
00107
00109 virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj) = 0;
00110
00118 virtual void finish(cComponent *component, simsignal_t signalID) {}
00119
00125 virtual void subscribedTo(cComponent *component, simsignal_t signalID) {}
00126
00142 virtual void unsubscribedFrom(cComponent *component, simsignal_t signalID) {}
00143
00147 int getSubscribeCount() const { return subscribecount; }
00148 };
00149
00158 class SIM_API cListener : public cIListener
00159 {
00160 protected:
00162 virtual void unsupportedType(simsignal_t signalID, const char *dataType);
00163 public:
00164 virtual void receiveSignal(cComponent *source, simsignal_t signalID, bool b);
00165 virtual void receiveSignal(cComponent *source, simsignal_t signalID, long l);
00166 virtual void receiveSignal(cComponent *source, simsignal_t signalID, unsigned long l);
00167 virtual void receiveSignal(cComponent *source, simsignal_t signalID, double d);
00168 virtual void receiveSignal(cComponent *source, simsignal_t signalID, const SimTime& t);
00169 virtual void receiveSignal(cComponent *source, simsignal_t signalID, const char *s);
00170 virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj);
00171 };
00172
00173 NAMESPACE_END
00174
00175 #endif
00176