A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
data-calculator.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 Drexel University
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Joe Kopena (tjkopena@cs.drexel.edu)
18 */
19
20#include "data-calculator.h"
21
22#include "ns3/log.h"
23#include "ns3/simulator.h"
24
25using namespace ns3;
26
27NS_LOG_COMPONENT_DEFINE("DataCalculator");
28
29static double zero = 0;
30const double ns3::NaN = zero / zero;
31
32//--------------------------------------------------------------
33//----------------------------------------------
35 : m_enabled(true)
36{
37 NS_LOG_FUNCTION(this);
38}
39
41{
42 NS_LOG_FUNCTION(this);
43}
44
45/* static */
48{
49 static TypeId tid = TypeId("ns3::DataCalculator").SetParent<Object>().SetGroupName("Stats")
50 // No AddConstructor because this is an abstract class.
51 ;
52 return tid;
53}
54
55void
57{
58 NS_LOG_FUNCTION(this);
59
62
64 // DataCalculator::DoDispose
65}
66
67//----------------------------------------------
68void
69DataCalculator::SetKey(const std::string key)
70{
71 NS_LOG_FUNCTION(this << key);
72
73 m_key = key;
74 // end DataCalculator::SetKey
75}
76
77std::string
79{
80 NS_LOG_FUNCTION(this);
81
82 return m_key;
83 // end DataCalculator::GetKey
84}
85
86//----------------------------------------------
87void
88DataCalculator::SetContext(const std::string context)
89{
90 NS_LOG_FUNCTION(this << context);
91
92 m_context = context;
93 // end DataCalculator::SetContext
94}
95
96std::string
98{
99 NS_LOG_FUNCTION(this);
100
101 return m_context;
102 // end DataCalculator::GetContext
103}
104
105//----------------------------------------------
106void
108{
109 NS_LOG_FUNCTION(this);
110
111 m_enabled = true;
112 // end DataCalculator::Enable
113}
114
115void
117{
118 NS_LOG_FUNCTION(this);
119
120 m_enabled = false;
121 // end DataCalculator::Disable
122}
123
124bool
126{
127 NS_LOG_FUNCTION(this);
128
129 return m_enabled;
130 // end DataCalculator::GetEnabled
131}
132
133//----------------------------------------------
134void
136{
137 NS_LOG_FUNCTION(this << startTime);
138
140
141 // end DataCalculator::Start
142}
143
144void
146{
147 NS_LOG_FUNCTION(this << stopTime);
148
150 // end DataCalculator::Stop
151}
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
bool m_enabled
Descendant classes must check & respect m_enabled!
static TypeId GetTypeId()
Register this type.
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
~DataCalculator() override
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 DoDispose() override
Destructor implementation.
void Enable()
Enables DataCalculator when simulation starts.
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.
A base class which provides memory management and object aggregation.
Definition: object.h:89
virtual void DoDispose()
Destructor implementation.
Definition: object.cc:444
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:571
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:285
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:105
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:932
static double zero
Time stopTime
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
#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.