coutvector.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __COUTVECTOR_H
00021 #define __COUTVECTOR_H
00022
00023 #include <stdio.h>
00024 #include "cownedobject.h"
00025 #include "simtime_t.h"
00026
00027 NAMESPACE_BEGIN
00028
00029
00035 typedef void (*RecordFunc)(void *, simtime_t, double, double);
00036
00037 class cEnum;
00038
00039
00047 class SIM_API cOutVector : public cNoncopyableOwnedObject
00048 {
00049 protected:
00050 enum {
00051 FL_ENABLED = 4,
00052 FL_RECORDWARMUP = 8,
00053 };
00054
00055 void *handle;
00056 simtime_t last_t;
00057 long num_received;
00058 long num_stored;
00059
00060
00061 RecordFunc record_in_inspector;
00062 void *data_for_inspector;
00063
00064 public:
00065
00066 void setCallback(RecordFunc f, void *d) {record_in_inspector=f; data_for_inspector=d;}
00067
00068 public:
00069 enum Type { TYPE_INT, TYPE_DOUBLE, TYPE_ENUM };
00070 enum InterpolationMode { NONE, SAMPLE_HOLD, BACKWARD_SAMPLE_HOLD, LINEAR };
00071
00072 public:
00078 explicit cOutVector(const char *name=NULL);
00079
00083 virtual ~cOutVector();
00085
00088
00093 virtual void setName(const char *name);
00094
00099 virtual std::string info() const;
00100
00105 virtual void parsimPack(cCommBuffer *buffer);
00106
00111 virtual void parsimUnpack(cCommBuffer *buffer);
00113
00123 virtual void setEnum(const char *registeredEnumName);
00124
00132 virtual void setEnum(cEnum *enumDecl);
00133
00139 virtual void setUnit(const char *unit);
00140
00147 virtual void setType(Type type);
00148
00154 virtual void setInterpolationMode(InterpolationMode mode);
00155
00162 virtual void setMin(double minValue);
00163
00170 virtual void setMax(double maxValue);
00172
00181 virtual bool record(double value);
00182
00186 virtual bool record(SimTime value) {return record(value.dbl());}
00187
00197 virtual bool recordWithTimestamp(simtime_t t, double value);
00198
00202 virtual bool recordWithTimestamp(simtime_t t, SimTime value) {return recordWithTimestamp(t, value.dbl());}
00203
00207 virtual void enable() {setFlag(FL_ENABLED,true);}
00208
00213 virtual void disable() {setFlag(FL_ENABLED,false);}
00214
00219 virtual void setEnabled(bool b) {setFlag(FL_ENABLED,b);}
00220
00224 virtual bool isEnabled() const {return flags&FL_ENABLED;}
00225
00233 virtual void setRecordDuringWarmupPeriod(bool b) {setFlag(FL_RECORDWARMUP,b);}
00234
00239 virtual bool getRecordDuringWarmupPeriod() const {return flags&FL_RECORDWARMUP;}
00240
00246 long getValuesReceived() const {return num_received;}
00247
00253 long getValuesStored() const {return num_stored;}
00255 };
00256
00257 NAMESPACE_END
00258
00259
00260 #endif
00261
00262