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
* SPDX-License-Identifier: GPL-2.0-only
5
*
6
* Author: Joe Kopena (tjkopena@cs.drexel.edu)
7
*/
8
9
#include "
data-calculator.h
"
10
11
#include "ns3/log.h"
12
#include "ns3/simulator.h"
13
14
using namespace
ns3
;
15
16
NS_LOG_COMPONENT_DEFINE
(
"DataCalculator"
);
17
18
// NS_DEPRECATED_3_44
19
const
double
ns3::NaN
= std::nan(
""
);
20
21
//--------------------------------------------------------------
22
//----------------------------------------------
23
DataCalculator::DataCalculator
()
24
: m_enabled(true)
25
{
26
NS_LOG_FUNCTION
(
this
);
27
}
28
29
DataCalculator::~DataCalculator
()
30
{
31
NS_LOG_FUNCTION
(
this
);
32
}
33
34
/* static */
35
TypeId
36
DataCalculator::GetTypeId
()
37
{
38
static
TypeId
tid =
TypeId
(
"ns3::DataCalculator"
).
SetParent
<
Object
>().SetGroupName(
"Stats"
)
39
// No AddConstructor because this is an abstract class.
40
;
41
return
tid;
42
}
43
44
void
45
DataCalculator::DoDispose
()
46
{
47
NS_LOG_FUNCTION
(
this
);
48
49
Simulator::Cancel
(
m_startEvent
);
50
Simulator::Cancel
(
m_stopEvent
);
51
52
Object::DoDispose
();
53
// DataCalculator::DoDispose
54
}
55
56
//----------------------------------------------
57
void
58
DataCalculator::SetKey
(
const
std::string key)
59
{
60
NS_LOG_FUNCTION
(
this
<< key);
61
62
m_key
= key;
63
// end DataCalculator::SetKey
64
}
65
66
std::string
67
DataCalculator::GetKey
()
const
68
{
69
NS_LOG_FUNCTION
(
this
);
70
71
return
m_key
;
72
// end DataCalculator::GetKey
73
}
74
75
//----------------------------------------------
76
void
77
DataCalculator::SetContext
(
const
std::string context)
78
{
79
NS_LOG_FUNCTION
(
this
<< context);
80
81
m_context
= context;
82
// end DataCalculator::SetContext
83
}
84
85
std::string
86
DataCalculator::GetContext
()
const
87
{
88
NS_LOG_FUNCTION
(
this
);
89
90
return
m_context
;
91
// end DataCalculator::GetContext
92
}
93
94
//----------------------------------------------
95
void
96
DataCalculator::Enable
()
97
{
98
NS_LOG_FUNCTION
(
this
);
99
100
m_enabled
=
true
;
101
// end DataCalculator::Enable
102
}
103
104
void
105
DataCalculator::Disable
()
106
{
107
NS_LOG_FUNCTION
(
this
);
108
109
m_enabled
=
false
;
110
// end DataCalculator::Disable
111
}
112
113
bool
114
DataCalculator::GetEnabled
()
const
115
{
116
NS_LOG_FUNCTION
(
this
);
117
118
return
m_enabled
;
119
// end DataCalculator::GetEnabled
120
}
121
122
//----------------------------------------------
123
void
124
DataCalculator::Start
(
const
Time
& startTime)
125
{
126
NS_LOG_FUNCTION
(
this
<< startTime);
127
128
m_startEvent
=
Simulator::Schedule
(startTime, &
DataCalculator::Enable
,
this
);
129
130
// end DataCalculator::Start
131
}
132
133
void
134
DataCalculator::Stop
(
const
Time
&
stopTime
)
135
{
136
NS_LOG_FUNCTION
(
this
<<
stopTime
);
137
138
m_stopEvent
=
Simulator::Schedule
(
stopTime
, &
DataCalculator::Disable
,
this
);
139
// end DataCalculator::Stop
140
}
ns3::DataCalculator::SetContext
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
Definition
data-calculator.cc:77
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition
data-calculator.h:175
ns3::DataCalculator::GetTypeId
static TypeId GetTypeId()
Register this type.
Definition
data-calculator.cc:36
ns3::DataCalculator::Start
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
Definition
data-calculator.cc:124
ns3::DataCalculator::~DataCalculator
~DataCalculator() override
Definition
data-calculator.cc:29
ns3::DataCalculator::Stop
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
Definition
data-calculator.cc:134
ns3::DataCalculator::GetEnabled
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
Definition
data-calculator.cc:114
ns3::DataCalculator::Disable
void Disable()
Disables DataCalculator when simulation stops.
Definition
data-calculator.cc:105
ns3::DataCalculator::GetKey
std::string GetKey() const
Gets the DataCalculator key.
Definition
data-calculator.cc:67
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition
data-calculator.h:178
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition
data-calculator.h:177
ns3::DataCalculator::m_stopEvent
EventId m_stopEvent
Stop event.
Definition
data-calculator.h:184
ns3::DataCalculator::DoDispose
void DoDispose() override
Destructor implementation.
Definition
data-calculator.cc:45
ns3::DataCalculator::Enable
void Enable()
Enables DataCalculator when simulation starts.
Definition
data-calculator.cc:96
ns3::DataCalculator::DataCalculator
DataCalculator()
Definition
data-calculator.cc:23
ns3::DataCalculator::GetContext
std::string GetContext() const
Gets the DataCalculator context.
Definition
data-calculator.cc:86
ns3::DataCalculator::SetKey
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
Definition
data-calculator.cc:58
ns3::DataCalculator::m_startEvent
EventId m_startEvent
Start event.
Definition
data-calculator.h:183
ns3::Object
A base class which provides memory management and object aggregation.
Definition
object.h:78
ns3::Object::DoDispose
virtual void DoDispose()
Destructor implementation.
Definition
object.cc:433
ns3::Simulator::Schedule
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition
simulator.h:560
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:274
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition
nstime.h:94
ns3::TypeId
a unique identifier for an interface.
Definition
type-id.h:48
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition
type-id.cc:1001
data-calculator.h
stopTime
Time stopTime
Definition
tcp-linux-reno.cc:41
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition
log.h:191
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:229
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:19
src
stats
model
data-calculator.cc
Generated on Thu Dec 12 2024 18:40:47 for ns-3 by
1.11.0