- Main Page
- Modules
- Classes
- Files
- Directories
- Related Pages

# chist.h

    00001 //==========================================================================
    00002 //  CHIST.H - part of
    00003 //
    00004 //                     OMNeT++/OMNEST
    00005 //            Discrete System Simulation in C++
    00006 //
    00007 //
    00008 //  Declaration of the following classes:
    00009 //    cHistogramBase        : common base class for histogram classes
    00010 //      cEqdHistogramBase   : Equi-distant histograms
    00011 //        cLongHistogram    : long int distribution
    00012 //        cDoubleHistogram  : double distribution
    00013 //
    00014 //==========================================================================
    00015
    00016 /*--------------------------------------------------------------*
    00017   Copyright (C) 1992-2005 Andras Varga
    00018
    00019   This file is distributed WITHOUT ANY WARRANTY. See the file
    00020   `license' for details on this and other legal matters.
    00021 *--------------------------------------------------------------*/
    00022
    00023 #ifndef __CHIST_H
    00024 #define __CHIST_H
    00025
    00026 #include "cdensity.h"
    00027
    00028 //==========================================================================
    00029
    00036 class SIM_API cHistogramBase : public cDensityEstBase
    00037 {
    00038   protected:
    00039     int num_cells;        // nr. of categories
    00040     unsigned *cellv;      // array of counters
    00041
    00042   public:
    00045
    00049     cHistogramBase(const cHistogramBase& r) : cDensityEstBase(r)
    00050         {setName(r.name());cellv=NULL;operator=(r);}
    00051
    00055     cHistogramBase(const char *name, int numcells);
    00056
    00060     virtual ~cHistogramBase();
    00061
    00065     cHistogramBase& operator=(const cHistogramBase& res);
    00067
    00070
    00071     /* No dup() because this is an abstract class. */
    00072
    00078     virtual void netPack(cCommBuffer *buffer);
    00079
    00085     virtual void netUnpack(cCommBuffer *buffer);
    00087
    00090
    00094     virtual void clearResult();
    00095
    00100     virtual void transform();
    00101
    00105     virtual int cells() const;
    00106
    00110     virtual void saveToFile(FILE *) const; //--LG
    00111
    00115     virtual void loadFromFile(FILE *);  //--LG
    00117
    00120
    00125     virtual void setNumCells(int numcells);
    00127 };
    00128
    00129 //==========================================================================
    00130
    00136 class SIM_API cEqdHistogramBase : public cHistogramBase //--LG
    00137 {
    00138   protected:
    00139     double cellsize;            // cell/category  sizes
    00140
    00141   public:
    00144
    00148     cEqdHistogramBase(const cEqdHistogramBase& r) : cHistogramBase(r)
    00149         {setName(r.name());operator=(r);}
    00150
    00154     explicit cEqdHistogramBase(const char *name=NULL, int numcells=-1);
    00155
    00159     cEqdHistogramBase& operator=(const cEqdHistogramBase& res);
    00161
    00164
    00165     /* No dup() because this is an abstract class. */
    00166
    00172     virtual void netPack(cCommBuffer *buffer);
    00173
    00179     virtual void netUnpack(cCommBuffer *buffer);
    00181
    00182   protected:
    00187     virtual void collectTransformed(double val);
    00188
    00193     virtual void setupRange();
    00194
    00195   public:
    00198
    00202     virtual double basepoint(int k) const;
    00203
    00207     virtual double cell(int k) const;
    00208
    00212     virtual double pdf(double x) const; // --LG
    00213
    00217     virtual double cdf(double x) const; // --LG
    00218
    00222     virtual void saveToFile(FILE *) const; //--LG
    00223
    00227     virtual void loadFromFile(FILE *);  //--LG
    00229 };
    00230
    00231 //==========================================================================
    00232
    00298 class SIM_API cLongHistogram : public cEqdHistogramBase
    00299 {
    00300   public:
    00303
    00307     cLongHistogram(const cLongHistogram& r) : cEqdHistogramBase(r)
    00308         {setName(r.name());operator=(r);}
    00309
    00313     explicit cLongHistogram(const char *name=NULL, int numcells=-1);
    00314
    00318     virtual ~cLongHistogram();
    00319
    00323     cLongHistogram& operator=(const cLongHistogram&)  {copyNotSupported();return *this;}
    00325
    00328
    00333     virtual cPolymorphic *dup() const    {return new cLongHistogram(*this);}
    00335
    00336   protected:
    00341     virtual void setupRange();
    00342
    00343   public:
    00346
    00351     virtual void collect(double val);
    00352
    00359     virtual double random() const;
    00361 };
    00362
    00363 //==========================================================================
    00364
    00416 class SIM_API cDoubleHistogram : public cEqdHistogramBase
    00417 {
    00418   protected:
    00423     virtual void setupRange();
    00424
    00425   public:
    00428
    00432     cDoubleHistogram(const cDoubleHistogram& r) : cEqdHistogramBase(r)
    00433           {setName(r.name());operator=(r);}
    00434
    00438     explicit cDoubleHistogram(const char *name=NULL, int numcells=-1);
    00439
    00443     virtual ~cDoubleHistogram();
    00444
    00448     cDoubleHistogram& operator=(const cDoubleHistogram&)  {copyNotSupported();return *this;}
    00450
    00453
    00458     virtual cPolymorphic *dup() const  {return new cDoubleHistogram(*this);}
    00460
    00463
    00470     virtual double random() const;
    00472 };
    00473
    00474 #endif
    00475