cstatistic.h Source File

API: cstatistic.h Source File
API
cstatistic.h
1//==========================================================================
2// CSTATISTIC.H - part of
3// OMNeT++/OMNEST
4// Discrete System Simulation in C++
5//
6//==========================================================================
7
8/*--------------------------------------------------------------*
9 Copyright (C) 1992-2017 Andras Varga
10 Copyright (C) 2006-2017 OpenSim Ltd.
11
12 This file is distributed WITHOUT ANY WARRANTY. See the file
13 `license' for details on this and other legal matters.
14*--------------------------------------------------------------*/
15
16#ifndef __OMNETPP_CSTATISTIC_H
17#define __OMNETPP_CSTATISTIC_H
18
19#include "crandom.h"
20#include "simtime.h"
21#include "opp_string.h"
22
23namespace omnetpp {
24
34class SIM_API cStatistic : public cRandom
35{
36 private:
37 void copy(const cStatistic& other);
38
39 protected:
40 // internal: utility function for implementing loadFromFile() functions
41 _OPP_GNU_ATTRIBUTE(format(scanf, 3, 4))
42 void freadvarsf (FILE *f, const char *fmt, ...);
43 // internal: for collecting the attributes to record into the scalar file
44 virtual void getAttributesToRecord(opp_string_map& attributes) {}
45
46 public:
49
54
58 explicit cStatistic(const char *name=nullptr);
59
63 virtual ~cStatistic() {}
64
71
74
75 /* @note No dup() because this is an abstract class! */
76
82 virtual void parsimPack(cCommBuffer *buffer) const override;
83
89 virtual void parsimUnpack(cCommBuffer *buffer) override;
91
94
97 virtual bool isWeighted() const = 0;
98
102 virtual void collect(double value) = 0;
103
107 virtual void collect(SimTime value) {collect(value.dbl());}
108
112 virtual void collectWeighted(double value, double weight);
113
117 virtual void collectWeighted(SimTime value, double weight) {collectWeighted(value.dbl(), weight);}
118
122 virtual void collectWeighted(double value, SimTime weight) {collectWeighted(value, weight.dbl());}
123
127 virtual void collectWeighted(SimTime value, SimTime weight) {collectWeighted(value.dbl(), weight.dbl());}
128
134 virtual void merge(const cStatistic *other) = 0;
135
140 virtual void clear() = 0;
142
145
149 virtual int64_t getCount() const = 0;
150
156 virtual double getSum() const = 0;
157
163 virtual double getSqrSum() const = 0;
164
168 virtual double getMin() const = 0;
169
173 virtual double getMax() const = 0;
174
178 virtual double getMean() const = 0;
179
183 virtual double getStddev() const = 0;
184
188 virtual double getVariance() const = 0;
190
193
196 virtual double getSumWeights() const = 0;
197
201 virtual double getWeightedSum() const = 0;
202
206 virtual double getSqrSumWeights() const = 0;
207
211 virtual double getWeightedSqrSum() const = 0;
213
216
221 virtual void saveToFile(FILE *) const = 0;
222
227 virtual void loadFromFile(FILE *) = 0;
228
239 virtual void record() {recordAs(nullptr, nullptr);}
240
250 virtual void recordWithUnit(const char *unit) {recordAs(nullptr, unit);}
251
260 virtual void recordAs(const char *name, const char *unit=nullptr);
262};
263
264} // namespace omnetpp
265
266#endif
267
int64_t-based, base-10 fixed-point simulation time.
Definition simtime.h:67
double dbl() const
Definition simtime.h:346
Buffer for the communications layer of parallel simulation.
Definition ccommbuffer.h:42
virtual void collectWeighted(double value, double weight)
virtual void saveToFile(FILE *) const =0
virtual double getWeightedSqrSum() const =0
virtual void collect(SimTime value)
Definition cstatistic.h:107
virtual bool isWeighted() const =0
virtual ~cStatistic()
Definition cstatistic.h:63
virtual double getMin() const =0
virtual int64_t getCount() const =0
virtual double getSum() const =0
virtual void collect(double value)=0
virtual void loadFromFile(FILE *)=0
virtual void parsimPack(cCommBuffer *buffer) const override
virtual void recordWithUnit(const char *unit)
Definition cstatistic.h:250
virtual void clear()=0
virtual void collectWeighted(double value, SimTime weight)
Definition cstatistic.h:122
virtual double getVariance() const =0
virtual void parsimUnpack(cCommBuffer *buffer) override
cStatistic(const cStatistic &r)
virtual double getWeightedSum() const =0
virtual void merge(const cStatistic *other)=0
virtual void collectWeighted(SimTime value, SimTime weight)
Definition cstatistic.h:127
virtual double getSqrSumWeights() const =0
virtual void record()
Definition cstatistic.h:239
virtual void recordAs(const char *name, const char *unit=nullptr)
virtual double getStddev() const =0
cStatistic & operator=(const cStatistic &res)
virtual double getSumWeights() const =0
virtual double getMax() const =0
virtual double getMean() const =0
cStatistic(const char *name=nullptr)
virtual double getSqrSum() const =0
virtual void collectWeighted(SimTime value, double weight)
Definition cstatistic.h:117
Lightweight string-to-string map, used internally in some parts of OMNeT++.
Definition opp_string.h:220