A Discrete-Event Network Simulator
API
data-calculator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 Drexel University
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: Joe Kopena (tjkopena@cs.drexel.edu)
19  */
20 
21 #ifndef DATA_CALCULATOR_H
22 #define DATA_CALCULATOR_H
23 
24 #include "ns3/object.h"
25 #include "ns3/nstime.h"
26 #include "ns3/simulator.h"
27 
28 namespace ns3 {
29 extern const double NaN;
30 
36 inline bool isNaN (double x) { return x != x; }
37 
38 class DataOutputCallback;
39 
47 public:
52  {
53  }
58  virtual long getCount () const = 0;
59 
64  virtual double getSum () const = 0;
65 
70  virtual double getSqrSum () const = 0;
71 
76  virtual double getMin () const = 0;
77 
82  virtual double getMax () const = 0;
83 
88  virtual double getMean () const = 0;
89 
94  virtual double getStddev () const = 0;
95 
100  virtual double getVariance () const = 0;
101 };
102 
103 //------------------------------------------------------------
104 //--------------------------------------------
111 class DataCalculator : public Object {
112 public:
113  DataCalculator();
114  virtual ~DataCalculator();
115 
120  static TypeId GetTypeId (void);
121 
126  bool GetEnabled () const;
130  void Enable ();
134  void Disable ();
139  void SetKey (const std::string key);
144  std::string GetKey () const;
145 
150  void SetContext (const std::string context);
155  std::string GetContext () const;
156 
161  virtual void Start (const Time& startTime);
166  virtual void Stop (const Time& stopTime);
167 
172  virtual void Output (DataOutputCallback &callback) const = 0;
173 
174 protected:
175  bool m_enabled;
176 
177  std::string m_key;
178  std::string m_context;
179 
180  virtual void DoDispose (void);
181 
182 private:
185 
186  // end class DataCalculator
187 };
188 
189 
190 // end namespace ns3
191 };
192 
193 
194 #endif /* DATA_CALCULATOR_H */
virtual void Output(DataOutputCallback &callback) const =0
Outputs data based on the provided callback.
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
virtual double getMin() const =0
Returns the minimum of the values.
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
std::string GetKey() const
Gets the DataCalculator key.
Abstract class for calculating statistical data.
virtual double getSqrSum() const =0
static TypeId GetTypeId(void)
Register this type.
bool m_enabled
Descendant classes must check & respect m_enabled!
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
double stopTime
EventId m_startEvent
Start event.
virtual double getStddev() const =0
Returns the standard deviation of the (weighted) observations.
virtual double getMean() const =0
Returns the mean of the (weighted) observations.
virtual double getMax() const =0
Returns the maximum of the values.
std::string GetContext() const
Gets the DataCalculator context.
void Enable()
Enables DataCalculator when simulation starts.
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
double startTime
virtual ~StatisticalSummary()
Destructor.
EventId m_stopEvent
Stop event.
virtual void DoDispose(void)
Destructor implementation.
const double NaN
Stored representation of NaN.
void Disable()
Disables DataCalculator when simulation stops.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Callback class for the DataOutput classes.
virtual double getSum() const =0
virtual double getVariance() const =0
Returns the variance of the (weighted) observations.
std::string m_context
Context value.
Calculates data during a simulation.
An identifier for simulation events.
Definition: event-id.h:53
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
bool isNaN(double x)
true if x is NaN
A base class which provides memory management and object aggregation.
Definition: object.h:87
virtual long getCount() const =0
Returns the number of observations.
a unique identifier for an interface.
Definition: type-id.h:58
std::string m_key
Key value.