A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Installation
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
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
25
using namespace
ns3
;
26
27
NS_LOG_COMPONENT_DEFINE
(
"DataCalculator"
);
28
29
static
double
zero
= 0;
30
const
double
ns3::NaN
=
zero
/
zero
;
31
32
//--------------------------------------------------------------
33
//----------------------------------------------
34
DataCalculator::DataCalculator
()
35
: m_enabled(true)
36
{
37
NS_LOG_FUNCTION
(
this
);
38
}
39
40
DataCalculator::~DataCalculator
()
41
{
42
NS_LOG_FUNCTION
(
this
);
43
}
44
45
/* static */
46
TypeId
47
DataCalculator::GetTypeId
()
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
55
void
56
DataCalculator::DoDispose
()
57
{
58
NS_LOG_FUNCTION
(
this
);
59
60
Simulator::Cancel
(
m_startEvent
);
61
Simulator::Cancel
(
m_stopEvent
);
62
63
Object::DoDispose
();
64
// DataCalculator::DoDispose
65
}
66
67
//----------------------------------------------
68
void
69
DataCalculator::SetKey
(
const
std::string key)
70
{
71
NS_LOG_FUNCTION
(
this
<< key);
72
73
m_key
= key;
74
// end DataCalculator::SetKey
75
}
76
77
std::string
78
DataCalculator::GetKey
()
const
79
{
80
NS_LOG_FUNCTION
(
this
);
81
82
return
m_key
;
83
// end DataCalculator::GetKey
84
}
85
86
//----------------------------------------------
87
void
88
DataCalculator::SetContext
(
const
std::string context)
89
{
90
NS_LOG_FUNCTION
(
this
<< context);
91
92
m_context
= context;
93
// end DataCalculator::SetContext
94
}
95
96
std::string
97
DataCalculator::GetContext
()
const
98
{
99
NS_LOG_FUNCTION
(
this
);
100
101
return
m_context
;
102
// end DataCalculator::GetContext
103
}
104
105
//----------------------------------------------
106
void
107
DataCalculator::Enable
()
108
{
109
NS_LOG_FUNCTION
(
this
);
110
111
m_enabled
=
true
;
112
// end DataCalculator::Enable
113
}
114
115
void
116
DataCalculator::Disable
()
117
{
118
NS_LOG_FUNCTION
(
this
);
119
120
m_enabled
=
false
;
121
// end DataCalculator::Disable
122
}
123
124
bool
125
DataCalculator::GetEnabled
()
const
126
{
127
NS_LOG_FUNCTION
(
this
);
128
129
return
m_enabled
;
130
// end DataCalculator::GetEnabled
131
}
132
133
//----------------------------------------------
134
void
135
DataCalculator::Start
(
const
Time
& startTime)
136
{
137
NS_LOG_FUNCTION
(
this
<< startTime);
138
139
m_startEvent
=
Simulator::Schedule
(startTime, &
DataCalculator::Enable
,
this
);
140
141
// end DataCalculator::Start
142
}
143
144
void
145
DataCalculator::Stop
(
const
Time
&
stopTime
)
146
{
147
NS_LOG_FUNCTION
(
this
<<
stopTime
);
148
149
m_stopEvent
=
Simulator::Schedule
(
stopTime
, &
DataCalculator::Disable
,
this
);
150
// end DataCalculator::Stop
151
}
ns3::DataCalculator::SetContext
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
Definition:
data-calculator.cc:88
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition:
data-calculator.h:182
ns3::DataCalculator::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition:
data-calculator.cc:47
ns3::DataCalculator::Start
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
Definition:
data-calculator.cc:135
ns3::DataCalculator::~DataCalculator
~DataCalculator() override
Definition:
data-calculator.cc:40
ns3::DataCalculator::Stop
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
Definition:
data-calculator.cc:145
ns3::DataCalculator::GetEnabled
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
Definition:
data-calculator.cc:125
ns3::DataCalculator::Disable
void Disable()
Disables DataCalculator when simulation stops.
Definition:
data-calculator.cc:116
ns3::DataCalculator::GetKey
std::string GetKey() const
Gets the DataCalculator key.
Definition:
data-calculator.cc:78
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition:
data-calculator.h:185
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition:
data-calculator.h:184
ns3::DataCalculator::m_stopEvent
EventId m_stopEvent
Stop event.
Definition:
data-calculator.h:191
ns3::DataCalculator::DoDispose
void DoDispose() override
Destructor implementation.
Definition:
data-calculator.cc:56
ns3::DataCalculator::Enable
void Enable()
Enables DataCalculator when simulation starts.
Definition:
data-calculator.cc:107
ns3::DataCalculator::DataCalculator
DataCalculator()
Definition:
data-calculator.cc:34
ns3::DataCalculator::GetContext
std::string GetContext() const
Gets the DataCalculator context.
Definition:
data-calculator.cc:97
ns3::DataCalculator::SetKey
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
Definition:
data-calculator.cc:69
ns3::DataCalculator::m_startEvent
EventId m_startEvent
Start event.
Definition:
data-calculator.h:190
ns3::Object
A base class which provides memory management and object aggregation.
Definition:
object.h:89
ns3::Object::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition:
object.cc:353
ns3::Simulator::Schedule
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition:
simulator.h:568
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:276
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:105
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:59
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:936
zero
static double zero
Definition:
data-calculator.cc:29
data-calculator.h
stopTime
Time stopTime
Definition:
tcp-linux-reno.cc:52
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
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:238
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::NaN
const double NaN
Stored representation of NaN.
Definition:
data-calculator.cc:30
src
stats
model
data-calculator.cc
Generated on Sun Jul 2 2023 18:22:04 for ns-3 by
1.9.6