A Discrete-Event Network Simulator
API
histogram.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 //
3 // Copyright (c) 2009 INESC Porto
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License version 2 as
7 // published by the Free Software Foundation;
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 //
18 // Author: Pedro Fortuna <pedro.fortuna@inescporto.pt> <pedro.fortuna@gmail.com>
19 //
20 
21 #ifndef NS3_HISTOGRAM_H
22 #define NS3_HISTOGRAM_H
23 
24 #include <vector>
25 #include <stdint.h>
26 #include <ostream>
27 
28 namespace ns3 {
29 
45 class Histogram
46 {
47 public:
48 
49  // --- basic methods ---
54  Histogram (double binWidth);
55  Histogram ();
56 
57  // Methods for Getting the Histogram Results
62  uint32_t GetNBins () const;
68  double GetBinStart (uint32_t index);
74  double GetBinEnd (uint32_t index);
83  double GetBinWidth (uint32_t index) const;
91  void SetDefaultBinWidth (double binWidth);
97  uint32_t GetBinCount (uint32_t index);
98 
99  // Method for adding values
104  void AddValue (double value);
105 
112  void SerializeToXmlStream (std::ostream &os, uint16_t indent, std::string elementName) const;
113 
114 
115 private:
116  std::vector<uint32_t> m_histogram;
117  double m_binWidth;
118 };
119 
120 
121 } // namespace ns3
122 
123 #endif /* NS3_HISTOGRAM_H */
double GetBinEnd(uint32_t index)
Returns the bin end, i.e., (index+1)*binWidth.
Definition: histogram.cc:54
std::vector< uint32_t > m_histogram
Histogram data.
Definition: histogram.h:116
uint32_t GetNBins() const
Returns the number of bins in the histogram.
Definition: histogram.cc:42
void SerializeToXmlStream(std::ostream &os, uint16_t indent, std::string elementName) const
Serializes the results to an std::ostream in XML format.
Definition: histogram.cc:105
double m_binWidth
Bin width.
Definition: histogram.h:117
def indent(source, debug, level)
Definition: check-style.py:424
void SetDefaultBinWidth(double binWidth)
Set the bin width.
Definition: histogram.cc:66
Every class exported by the ns3 library is enclosed in the ns3 namespace.
uint32_t GetBinCount(uint32_t index)
Get the number of data added to the bin.
Definition: histogram.cc:73
double GetBinWidth(uint32_t index) const
Returns the bin width.
Definition: histogram.cc:60
double GetBinStart(uint32_t index)
Returns the bin start, i.e., index*binWidth.
Definition: histogram.cc:48
void AddValue(double value)
Add a value to the histogram.
Definition: histogram.cc:80
Class used to store data and make an histogram of the data frequency.
Definition: histogram.h:45