cstatistic.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef __CSTATISTIC_H
00021 #define __CSTATISTIC_H
00022
00023 #include <stdio.h>
00024 #include "cownedobject.h"
00025 #include "simtime.h"
00026
00027 NAMESPACE_BEGIN
00028
00029 class cTransientDetection;
00030 class cAccuracyDetection;
00031
00032
00043 class SIM_API cStatistic : public cOwnedObject
00044 {
00045 public:
00046 cTransientDetection *td;
00047 cAccuracyDetection *ra;
00048 int genk;
00049
00050 private:
00051 void copy(const cStatistic& other);
00052
00053 protected:
00054
00055 void freadvarsf (FILE *f, const char *fmt, ...);
00056
00057 virtual void getAttributesToRecord(opp_string_map& attributes) {}
00058
00059 public:
00062
00066 cStatistic(const cStatistic& r);
00067
00071 explicit cStatistic(const char *name=NULL);
00072
00076 virtual ~cStatistic();
00077
00082 cStatistic& operator=(const cStatistic& res);
00084
00087
00088
00089
00095 virtual void parsimPack(cCommBuffer *buffer);
00096
00102 virtual void parsimUnpack(cCommBuffer *buffer);
00104
00107
00111 virtual void collect(double value) = 0;
00112
00116 virtual void collect(SimTime value) {collect(value.dbl());}
00117
00121 virtual bool isWeighted() const = 0;
00122
00126 virtual void collect2(double value, double weight);
00127
00133 virtual void merge(const cStatistic *other) = 0;
00134
00139 virtual void clearResult() = 0;
00141
00144
00148 virtual long getCount() const = 0;
00149
00154 virtual double getSum() const = 0;
00155
00160 virtual double getSqrSum() const = 0;
00161
00165 virtual double getMin() const = 0;
00166
00170 virtual double getMax() const = 0;
00171
00175 virtual double getMean() const = 0;
00176
00180 virtual double getStddev() const = 0;
00181
00185 virtual double getVariance() const = 0;
00187
00193 virtual double getWeights() const = 0;
00194
00198 virtual double getWeightedSum() const = 0;
00199
00203 virtual double getSqrSumWeights() const = 0;
00204
00208 virtual double getWeightedSqrSum() const = 0;
00210
00213
00218 void addTransientDetection(cTransientDetection *object);
00219
00224 void addAccuracyDetection(cAccuracyDetection *object);
00225
00229 cTransientDetection *getTransientDetectionObject() const {return td;}
00230
00234 cAccuracyDetection *getAccuracyDetectionObject() const {return ra;}
00236
00239
00245 void setGenK(int gen_nr) {genk=gen_nr;}
00246
00251 virtual double random() const = 0;
00253
00256
00261 virtual void saveToFile(FILE *) const = 0;
00262
00267 virtual void loadFromFile(FILE *) = 0;
00268
00279 virtual void record() {recordAs(NULL, NULL);}
00280
00290 virtual void recordWithUnit(const char *unit) {recordAs(NULL, unit);}
00291
00300 virtual void recordAs(const char *name, const char *unit=NULL);
00302 };
00303
00304 NAMESPACE_END
00305
00306 #endif
00307