A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
void
47
DataCalculator::DoDispose
(
void
)
48
{
49
NS_LOG_FUNCTION
(
this
);
50
51
Simulator::Cancel
(
m_startEvent
);
52
Simulator::Cancel
(
m_stopEvent
);
53
54
Object::DoDispose
();
55
// DataCalculator::DoDispose
56
}
57
58
//----------------------------------------------
59
void
60
DataCalculator::SetKey
(
const
std::string key)
61
{
62
NS_LOG_FUNCTION
(
this
<< key);
63
64
m_key
= key;
65
// end DataCalculator::SetKey
66
}
67
68
std::string
69
DataCalculator::GetKey
()
const
70
{
71
NS_LOG_FUNCTION
(
this
);
72
73
return
m_key
;
74
// end DataCalculator::GetKey
75
}
76
77
//----------------------------------------------
78
void
79
DataCalculator::SetContext
(
const
std::string context)
80
{
81
NS_LOG_FUNCTION
(
this
<< context);
82
83
m_context
= context;
84
// end DataCalculator::SetContext
85
}
86
87
std::string
88
DataCalculator::GetContext
()
const
89
{
90
NS_LOG_FUNCTION
(
this
);
91
92
return
m_context
;
93
// end DataCalculator::GetContext
94
}
95
//----------------------------------------------
96
void
97
DataCalculator::Enable
()
98
{
99
NS_LOG_FUNCTION
(
this
);
100
101
m_enabled
=
true
;
102
// end DataCalculator::Enable
103
}
104
105
void
106
DataCalculator::Disable
()
107
{
108
NS_LOG_FUNCTION
(
this
);
109
110
m_enabled
=
false
;
111
// end DataCalculator::Disable
112
}
113
114
bool
115
DataCalculator::GetEnabled
()
const
116
{
117
NS_LOG_FUNCTION
(
this
);
118
119
return
m_enabled
;
120
// end DataCalculator::GetEnabled
121
}
122
123
//----------------------------------------------
124
void
125
DataCalculator::Start
(
const
Time
&
startTime
)
126
{
127
NS_LOG_FUNCTION
(
this
<< startTime);
128
129
m_startEvent
=
Simulator::Schedule
(startTime,
130
&
DataCalculator::Enable
,
this
);
131
132
// end DataCalculator::Start
133
}
134
135
void
136
DataCalculator::Stop
(
const
Time
&
stopTime
)
137
{
138
NS_LOG_FUNCTION
(
this
<< stopTime);
139
140
m_stopEvent
=
Simulator::Schedule
(stopTime,
141
&
DataCalculator::Disable
,
this
);
142
// end DataCalculator::Stop
143
}
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition:
nstime.h:102
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:213
ns3::DataCalculator::SetKey
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
Definition:
data-calculator.cc:60
ns3::DataCalculator::GetKey
std::string GetKey() const
Gets the DataCalculator key.
Definition:
data-calculator.cc:69
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:201
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition:
data-calculator.h:169
ns3::Object::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
object.cc:339
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:311
ns3::Simulator::Schedule
static EventId Schedule(Time const &time, MEM mem_ptr, OBJ obj)
Schedule an event to expire at the relative time "time" is reached.
Definition:
simulator.h:819
zero
static double zero
Definition:
data-calculator.cc:30
ns3::DataCalculator::Stop
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
Definition:
data-calculator.cc:136
ns3::DataCalculator::Start
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
Definition:
data-calculator.cc:125
stopTime
double stopTime
Definition:
tcp-nsc-comparison.cc:46
ns3::DataCalculator::m_startEvent
EventId m_startEvent
Start event.
Definition:
data-calculator.h:177
ns3::DataCalculator::GetContext
std::string GetContext() const
Gets the DataCalculator context.
Definition:
data-calculator.cc:88
ns3::DataCalculator::Enable
void Enable()
Enables DataCalculator when simulation starts.
Definition:
data-calculator.cc:97
ns3::DataCalculator::GetEnabled
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
Definition:
data-calculator.cc:115
startTime
double startTime
Definition:
tcp-nsc-comparison.cc:45
ns3::DataCalculator::m_stopEvent
EventId m_stopEvent
Stop event.
Definition:
data-calculator.h:178
data-calculator.h
ns3::DataCalculator::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
data-calculator.cc:47
ns3::NaN
const double NaN
Stored representation of NaN.
Definition:
data-calculator.cc:31
ns3::DataCalculator::Disable
void Disable()
Disables DataCalculator when simulation stops.
Definition:
data-calculator.cc:106
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::DataCalculator::~DataCalculator
virtual ~DataCalculator()
Definition:
data-calculator.cc:41
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition:
data-calculator.h:172
ns3::DataCalculator::SetContext
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
Definition:
data-calculator.cc:79
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition:
data-calculator.h:171
ns3::DataCalculator::DataCalculator
DataCalculator()
Definition:
data-calculator.cc:35
src
stats
model
data-calculator.cc
Generated on Wed May 13 2015 14:59:31 for ns-3 by
1.8.9.1