A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
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
//----------------------------------------------
35
DataCalculator::DataCalculator
() :
36
m_enabled (true)
37
{
38
NS_LOG_FUNCTION
(
this
);
39
}
40
41
DataCalculator::~DataCalculator
()
42
{
43
NS_LOG_FUNCTION
(
this
);
44
}
45
46
/* static */
47
TypeId
48
DataCalculator::GetTypeId
(
void
)
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
59
DataCalculator::DoDispose
(
void
)
60
{
61
NS_LOG_FUNCTION
(
this
);
62
63
Simulator::Cancel
(
m_startEvent
);
64
Simulator::Cancel
(
m_stopEvent
);
65
66
Object::DoDispose
();
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
81
DataCalculator::GetKey
()
const
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
100
DataCalculator::GetContext
()
const
101
{
102
NS_LOG_FUNCTION
(
this
);
103
104
return
m_context
;
105
// end DataCalculator::GetContext
106
}
107
//----------------------------------------------
108
void
109
DataCalculator::Enable
()
110
{
111
NS_LOG_FUNCTION
(
this
);
112
113
m_enabled
=
true
;
114
// end DataCalculator::Enable
115
}
116
117
void
118
DataCalculator::Disable
()
119
{
120
NS_LOG_FUNCTION
(
this
);
121
122
m_enabled
=
false
;
123
// end DataCalculator::Disable
124
}
125
126
bool
127
DataCalculator::GetEnabled
()
const
128
{
129
NS_LOG_FUNCTION
(
this
);
130
131
return
m_enabled
;
132
// end DataCalculator::GetEnabled
133
}
134
135
//----------------------------------------------
136
void
137
DataCalculator::Start
(
const
Time
&
startTime
)
138
{
139
NS_LOG_FUNCTION
(
this
<<
startTime
);
140
141
m_startEvent
=
Simulator::Schedule
(
startTime
,
142
&
DataCalculator::Enable
,
this
);
143
144
// end DataCalculator::Start
145
}
146
147
void
148
DataCalculator::Stop
(
const
Time
&
stopTime
)
149
{
150
NS_LOG_FUNCTION
(
this
<<
stopTime
);
151
152
m_stopEvent
=
Simulator::Schedule
(
stopTime
,
153
&
DataCalculator::Disable
,
this
);
154
// end DataCalculator::Stop
155
}
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:205
stopTime
Time stopTime
Definition:
tcp-linux-reno.cc:52
ns3::DataCalculator::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
data-calculator.cc:59
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition:
data-calculator.h:178
ns3::DataCalculator::~DataCalculator
virtual ~DataCalculator()
Definition:
data-calculator.cc:41
ns3::DataCalculator::Disable
void Disable()
Disables DataCalculator when simulation stops.
Definition:
data-calculator.cc:118
ns3::DataCalculator::SetContext
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
Definition:
data-calculator.cc:91
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition:
simulator.h:557
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition:
data-calculator.h:177
ns3::DataCalculator::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
data-calculator.cc:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:923
ns3::DataCalculator::GetContext
std::string GetContext() const
Gets the DataCalculator context.
Definition:
data-calculator.cc:100
startTime
double startTime
Definition:
tcp-nsc-comparison.cc:45
ns3::DataCalculator::GetEnabled
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
Definition:
data-calculator.cc:127
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition:
data-calculator.h:175
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:88
ns3::Simulator::Cancel
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
ns3::DataCalculator::Stop
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
Definition:
data-calculator.cc:148
ns3::DataCalculator::Start
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
Definition:
data-calculator.cc:137
ns3::DataCalculator::m_startEvent
EventId m_startEvent
Start event.
Definition:
data-calculator.h:183
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:104
ns3::DataCalculator::SetKey
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
Definition:
data-calculator.cc:72
ns3::DataCalculator::m_stopEvent
EventId m_stopEvent
Stop event.
Definition:
data-calculator.h:184
zero
static double zero
Definition:
data-calculator.cc:30
ns3::DataCalculator::Enable
void Enable()
Enables DataCalculator when simulation starts.
Definition:
data-calculator.cc:109
ns3::NaN
const double NaN
Stored representation of NaN.
Definition:
data-calculator.cc:31
NS_LOG_FUNCTION
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Definition:
log-macros-enabled.h:244
ns3::DataCalculator::DataCalculator
DataCalculator()
Definition:
data-calculator.cc:35
data-calculator.h
ns3::Object::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
object.cc:346
ns3::DataCalculator::GetKey
std::string GetKey() const
Gets the DataCalculator key.
Definition:
data-calculator.cc:81
src
stats
model
data-calculator.cc
Generated on Fri Oct 1 2021 17:03:36 for ns-3 by
1.8.20