OMNeT++ Simulation Library  5.6.1
cvarhist.h
1 //==========================================================================
2 // CVARHIST.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_CVARHIST_H
17 #define __OMNETPP_CVARHIST_H
18 
19 #include "clegacyhistogram.h"
20 
21 #if defined(__clang__) || defined(__GNUC__)
22 #pragma GCC diagnostic push
23 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
24 #endif
25 
26 namespace omnetpp {
27 
40 class _OPPDEPRECATED SIM_API cVarHistogram : public cLegacyHistogramBase
41 {
42  public:
49  HIST_TR_AUTO_EPC_INT
50  };
51 
52  protected:
53  TransformType transformType;
54 
55  // bin lower boundaries, plus an extra one for the upper bound of the last bin
56  // Note: cellLowerBounds[0] = rangeMin, and cellLowerBounds[numCells] = rangeMax
57  double *cellLowerBounds;
58  int maxNumCells; // allocated size of cellLowerBounds[] during setup
59 
60  private:
61  void copy(const cVarHistogram& other);
62 
63  protected:
69  void createEquiprobableCells();
70 
71  public:
74 
78  cVarHistogram(const cVarHistogram& r) : cLegacyHistogramBase(r) {cellLowerBounds=nullptr;copy(r);}
79 
86  explicit cVarHistogram(const char *name=nullptr,
87  int numcells=11,
88  TransformType transformtype=HIST_TR_AUTO_EPC_DBL);
89 
93  virtual ~cVarHistogram();
94 
98  cVarHistogram& operator=(const cVarHistogram& res);
100 
103 
108  virtual cVarHistogram *dup() const override {return new cVarHistogram(*this);}
109 
115  virtual void parsimPack(cCommBuffer *buffer) const override;
116 
122  virtual void parsimUnpack(cCommBuffer *buffer) override;
124 
127 
131  virtual void clear() override;
132 
136  virtual void setUpBins() override;
137 
142  virtual void collectIntoHistogram(double value) override;
143 
148  virtual void collectWeightedIntoHistogram(double value, double weight) override;
149 
153  virtual double draw() const override;
154 
158  virtual double getPDF(double x) const override;
159 
163  virtual double getCDF(double x) const override;
164 
168  virtual double getBinEdge(int k) const override;
169 
173  virtual double getBinValue(int k) const override;
174 
178  virtual void saveToFile(FILE *) const override;
179 
183  virtual void loadFromFile(FILE *) override;
185 
188 
195  virtual void addBinBound(double x);
197 };
198 
199 } // namespace omnetpp
200 
201 #if defined(__clang__) || defined(__GNUC__)
202 #pragma GCC diagnostic pop
203 #endif
204 
205 #endif
206 
207 
Base class for histogram classes. It adds a vector of counters to cPrecollectionBasedDensityEst.
Definition: clegacyhistogram.h:37
Variable bin size histogram.
Definition: cvarhist.h:40
no transformation; uses bin boundaries previously defined by addBinBound()/appendBinBound() ...
Definition: cvarhist.h:47
Buffer for the communications layer of parallel simulation.
Definition: ccommbuffer.h:41
virtual cVarHistogram * dup() const override
Definition: cvarhist.h:108
Definition: cabstracthistogram.h:21
TransformType
Definition: cvarhist.h:46
automatically creates equi-probable bins
Definition: cvarhist.h:48
cVarHistogram(const cVarHistogram &r)
Definition: cvarhist.h:78