cresultfilter.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __CRESULTFILTER_H
00019 #define __CRESULTFILTER_H
00020
00021 #include "simkerneldefs.h"
00022 #include "cresultlistener.h"
00023 #include "onstartup.h"
00024 #include "globals.h"
00025 #include "cownedobject.h"
00026
00027 NAMESPACE_BEGIN
00028
00029 class cResultFilter;
00030
00040 #define Register_ResultFilter(NAME, CLASSNAME) \
00041 static cResultFilter *__FILEUNIQUENAME__() {return new CLASSNAME;} \
00042 EXECUTE_ON_STARTUP(resultFilters.getInstance()->add(new cResultFilterDescriptor(NAME,__FILEUNIQUENAME__));)
00043
00044
00054 class SIM_API cResultFilter : public cResultListener
00055 {
00056 private:
00057 cResultListener **delegates;
00058 protected:
00059
00060 void fire(cResultFilter *prev, simtime_t_cref t, bool b);
00061 void fire(cResultFilter *prev, simtime_t_cref t, long l);
00062 void fire(cResultFilter *prev, simtime_t_cref t, unsigned long l);
00063 void fire(cResultFilter *prev, simtime_t_cref t, double d);
00064 void fire(cResultFilter *prev, simtime_t_cref t, const SimTime& v);
00065 void fire(cResultFilter *prev, simtime_t_cref t, const char *s);
00066 void fire(cResultFilter *prev, simtime_t_cref t, cObject *obj);
00067 public:
00068 cResultFilter();
00069 ~cResultFilter();
00070 virtual void addDelegate(cResultListener *delegate);
00071 virtual int getNumDelegates() const;
00072 std::vector<cResultListener*> getDelegates() const;
00073 virtual void finish(cResultFilter *prev);
00074 };
00075
00083 class SIM_API cNumericResultFilter : public cResultFilter
00084 {
00085 protected:
00086
00087
00088 virtual bool process(simtime_t& t, double& value) = 0;
00089 public:
00090 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, bool b);
00091 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, long l);
00092 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, unsigned long l);
00093 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, double d);
00094 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, const SimTime& v);
00095 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, const char *s);
00096 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, cObject *obj);
00097 };
00098
00106 class SIM_API cObjectResultFilter : public cResultFilter
00107 {
00108 public:
00109 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, bool b);
00110 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, long l);
00111 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, unsigned long l);
00112 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, double d);
00113 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, const SimTime& v);
00114 virtual void receiveSignal(cResultFilter *prev, simtime_t_cref t, const char *s);
00115 };
00116
00122 class SIM_API cResultFilterDescriptor : public cNoncopyableOwnedObject
00123 {
00124 private:
00125 cResultFilter *(*creatorfunc)();
00126
00127 public:
00131 cResultFilterDescriptor(const char *name, cResultFilter *(*f)());
00132
00137 cResultFilter *create() const {return creatorfunc();}
00138
00143 static cResultFilterDescriptor *find(const char *name);
00144
00148 static cResultFilterDescriptor *get(const char *name);
00149 };
00150
00151 NAMESPACE_END
00152
00153 #endif
00154
00155