A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
src
stats
model
time-data-calculators.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/nstime.h"
23
24
#include "
time-data-calculators.h
"
25
26
using namespace
ns3
;
27
28
NS_LOG_COMPONENT_DEFINE
(
"TimeDataCalculators"
);
29
30
//--------------------------------------------------------------
31
//----------------------------------------------
32
TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator
()
33
{
34
NS_LOG_FUNCTION
(
this
);
35
36
m_count
= 0;
37
}
38
TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator
()
39
{
40
NS_LOG_FUNCTION
(
this
);
41
}
42
/* static */
43
TypeId
44
TimeMinMaxAvgTotalCalculator::GetTypeId
(
void
)
45
{
46
static
TypeId
tid =
TypeId
(
"ns3::TimeMinMaxAvgTotalCalculator"
)
47
.
SetParent
<
DataCalculator
> ()
48
.SetGroupName (
"Stats"
)
49
.AddConstructor<
TimeMinMaxAvgTotalCalculator
> ();
50
return
tid;
51
}
52
53
void
54
TimeMinMaxAvgTotalCalculator::DoDispose
(
void
)
55
{
56
NS_LOG_FUNCTION
(
this
);
57
58
DataCalculator::DoDispose
();
59
// TimeMinMaxAvgTotalCalculator::DoDispose
60
}
61
62
void
63
TimeMinMaxAvgTotalCalculator::Update
(
const
Time
i)
64
{
65
NS_LOG_FUNCTION
(
this
<< i);
66
67
if
(
m_enabled
) {
68
if
(
m_count
) {
69
m_total
+= i;
70
71
if
(i <
m_min
)
72
m_min
= i;
73
74
if
(i >
m_max
)
75
m_max
= i;
76
77
}
else
{
78
m_min
= i;
79
m_max
= i;
80
m_total
= i;
81
}
82
m_count
++;
83
84
}
85
// end TimeMinMaxAvgTotalCalculator::Update
86
}
87
void
88
TimeMinMaxAvgTotalCalculator::Output
(
DataOutputCallback
&callback)
const
89
{
90
NS_LOG_FUNCTION
(
this
<< &callback);
91
92
callback.
OutputSingleton
(
m_context
,
m_key
+
"-count"
,
m_count
);
93
if
(
m_count
> 0) {
94
callback.
OutputSingleton
(
m_context
,
m_key
+
"-total"
,
m_total
);
95
callback.
OutputSingleton
(
m_context
,
m_key
+
"-average"
,
Time
(
m_total
/
m_count
));
96
callback.
OutputSingleton
(
m_context
,
m_key
+
"-max"
,
m_max
);
97
callback.
OutputSingleton
(
m_context
,
m_key
+
"-min"
,
m_min
);
98
}
99
// end TimeMinMaxAvgTotalCalculator::Output
100
}
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
time-data-calculators.h
ns3::TimeMinMaxAvgTotalCalculator::Output
virtual void Output(DataOutputCallback &callback) const
Outputs data based on the provided callback.
Definition:
time-data-calculators.cc:88
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition:
log.h:202
ns3::DataCalculator::m_enabled
bool m_enabled
Descendant classes must check & respect m_enabled!
Definition:
data-calculator.h:175
ns3::TimeMinMaxAvgTotalCalculator::TimeMinMaxAvgTotalCalculator
TimeMinMaxAvgTotalCalculator()
Definition:
time-data-calculators.cc:32
ns3::TimeMinMaxAvgTotalCalculator::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition:
time-data-calculators.cc:54
ns3::TimeMinMaxAvgTotalCalculator
Unfortunately, templating the base MinMaxAvgTotalCalculator to operate over Time values isn't straigh...
Definition:
time-data-calculators.h:42
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::TimeMinMaxAvgTotalCalculator::m_count
uint32_t m_count
Count value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:68
ns3::DataOutputCallback
Callback class for the DataOutput classes.
Definition:
data-output-interface.h:81
ns3::TimeMinMaxAvgTotalCalculator::GetTypeId
static TypeId GetTypeId(void)
Register this type.
Definition:
time-data-calculators.cc:44
ns3::TimeMinMaxAvgTotalCalculator::~TimeMinMaxAvgTotalCalculator
virtual ~TimeMinMaxAvgTotalCalculator()
Definition:
time-data-calculators.cc:38
ns3::DataCalculator::m_context
std::string m_context
Context value.
Definition:
data-calculator.h:178
ns3::DataCalculator
Calculates data during a simulation.
Definition:
data-calculator.h:111
ns3::TimeMinMaxAvgTotalCalculator::m_min
Time m_min
Minimum value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:70
ns3::TimeMinMaxAvgTotalCalculator::m_total
Time m_total
Total value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:69
ns3::TimeMinMaxAvgTotalCalculator::Update
void Update(const Time i)
Updates all variables of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.cc:63
ns3::TimeMinMaxAvgTotalCalculator::m_max
Time m_max
Maximum value of TimeMinMaxAvgTotalCalculator.
Definition:
time-data-calculators.h:71
ns3::DataOutputCallback::OutputSingleton
virtual void OutputSingleton(std::string key, std::string variable, int val)=0
Associates the integer value with the variable name for a specific output format. ...
ns3::TypeId
a unique identifier for an interface.
Definition:
type-id.h:58
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition:
type-id.cc:915
ns3::DataCalculator::m_key
std::string m_key
Key value.
Definition:
data-calculator.h:177
Generated on Wed Nov 7 2018 10:02:10 for ns-3 by
1.8.14