A Discrete-Event Network Simulator
API
data-calculator.cc
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 #include "ns3/log.h"
22 #include "ns3/simulator.h"
23 
24 #include "data-calculator.h"
25 
26 using namespace ns3;
27 
28 NS_LOG_COMPONENT_DEFINE ("DataCalculator");
29 
30 static double zero = 0;
31 const double ns3::NaN = zero / zero;
32 
33 //--------------------------------------------------------------
34 //----------------------------------------------
36  m_enabled (true)
37 {
38  NS_LOG_FUNCTION (this);
39 }
40 
42 {
43  NS_LOG_FUNCTION (this);
44 }
45 
46 /* static */
47 TypeId
49 {
50  static TypeId tid = TypeId ("ns3::DataCalculator")
51  .SetParent<Object> ()
52  .SetGroupName ("Stats")
53  // No AddConstructor because this is an abstract class.
54  ;
55  return tid;
56 }
57 
58 void
60 {
61  NS_LOG_FUNCTION (this);
62 
65 
67  // DataCalculator::DoDispose
68 }
69 
70 //----------------------------------------------
71 void
72 DataCalculator::SetKey (const std::string key)
73 {
74  NS_LOG_FUNCTION (this << key);
75 
76  m_key = key;
77  // end DataCalculator::SetKey
78 }
79 
80 std::string
82 {
83  NS_LOG_FUNCTION (this);
84 
85  return m_key;
86  // end DataCalculator::GetKey
87 }
88 
89 //----------------------------------------------
90 void
91 DataCalculator::SetContext (const std::string context)
92 {
93  NS_LOG_FUNCTION (this << context);
94 
95  m_context = context;
96  // end DataCalculator::SetContext
97 }
98 
99 std::string
101 {
102  NS_LOG_FUNCTION (this);
103 
104  return m_context;
105  // end DataCalculator::GetContext
106 }
107 //----------------------------------------------
108 void
110 {
111  NS_LOG_FUNCTION (this);
112 
113  m_enabled = true;
114  // end DataCalculator::Enable
115 }
116 
117 void
119 {
120  NS_LOG_FUNCTION (this);
121 
122  m_enabled = false;
123  // end DataCalculator::Disable
124 }
125 
126 bool
128 {
129  NS_LOG_FUNCTION (this);
130 
131  return m_enabled;
132  // end DataCalculator::GetEnabled
133 }
134 
135 //----------------------------------------------
136 void
138 {
139  NS_LOG_FUNCTION (this << startTime);
140 
142  &DataCalculator::Enable, this);
143 
144  // end DataCalculator::Start
145 }
146 
147 void
149 {
150  NS_LOG_FUNCTION (this << stopTime);
151 
153  &DataCalculator::Disable, this);
154  // end DataCalculator::Stop
155 }
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
bool m_enabled
Descendant classes must check & respect m_enabled!
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
void Disable()
Disables DataCalculator when simulation stops.
std::string GetKey() const
Gets the DataCalculator key.
std::string m_context
Context value.
std::string m_key
Key value.
EventId m_stopEvent
Stop event.
void Enable()
Enables DataCalculator when simulation starts.
virtual void DoDispose(void)
Destructor implementation.
std::string GetContext() const
Gets the DataCalculator context.
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
EventId m_startEvent
Start event.
static TypeId GetTypeId(void)
Register this type.
A base class which provides memory management and object aggregation.
Definition: object.h:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
static void Cancel(const EventId &id)
Set the cancel bit on this event: the event's associated function will not be invoked when it expires...
Definition: simulator.cc:268
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:103
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
static double zero
Time stopTime
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const double NaN
Stored representation of NaN.
double startTime