A Discrete-Event Network Simulator
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
14using namespace ns3;
15
16NS_LOG_COMPONENT_DEFINE("DataCalculator");
17
18// NS_DEPRECATED_3_44
19const double ns3::NaN = std::nan("");
20
21//--------------------------------------------------------------
22//----------------------------------------------
24 : m_enabled(true)
25{
26 NS_LOG_FUNCTION(this);
27}
28
33
34/* static */
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
44void
46{
47 NS_LOG_FUNCTION(this);
48
51
53 // DataCalculator::DoDispose
54}
55
56//----------------------------------------------
57void
58DataCalculator::SetKey(const std::string key)
59{
60 NS_LOG_FUNCTION(this << key);
61
62 m_key = key;
63 // end DataCalculator::SetKey
64}
65
66std::string
68{
69 NS_LOG_FUNCTION(this);
70
71 return m_key;
72 // end DataCalculator::GetKey
73}
74
75//----------------------------------------------
76void
77DataCalculator::SetContext(const std::string context)
78{
79 NS_LOG_FUNCTION(this << context);
80
81 m_context = context;
82 // end DataCalculator::SetContext
83}
84
85std::string
87{
88 NS_LOG_FUNCTION(this);
89
90 return m_context;
91 // end DataCalculator::GetContext
92}
93
94//----------------------------------------------
95void
97{
98 NS_LOG_FUNCTION(this);
99
100 m_enabled = true;
101 // end DataCalculator::Enable
102}
103
104void
106{
107 NS_LOG_FUNCTION(this);
108
109 m_enabled = false;
110 // end DataCalculator::Disable
111}
112
113bool
115{
116 NS_LOG_FUNCTION(this);
117
118 return m_enabled;
119 // end DataCalculator::GetEnabled
120}
121
122//----------------------------------------------
123void
125{
126 NS_LOG_FUNCTION(this << startTime);
127
129
130 // end DataCalculator::Start
131}
132
133void
135{
136 NS_LOG_FUNCTION(this << stopTime);
137
139 // end DataCalculator::Stop
140}
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
bool m_enabled
Descendant classes must check & respect m_enabled!
static TypeId GetTypeId()
Register this type.
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
void Disable()
Disables DataCalculator when simulation stops.
std::string GetKey() const
Gets the DataCalculator key.
std::string m_context
Context value.
std::string m_key
Key value.
EventId m_stopEvent
Stop event.
void DoDispose() override
Destructor implementation.
void Enable()
Enables DataCalculator when simulation starts.
std::string GetContext() const
Gets the DataCalculator context.
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
EventId m_startEvent
Start event.
A base class which provides memory management and object aggregation.
Definition object.h:78
virtual void DoDispose()
Destructor implementation.
Definition object.cc:433
static EventId Schedule(const Time &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition simulator.h:560
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
Simulation virtual time values and global simulation resolution.
Definition nstime.h:94
a unique identifier for an interface.
Definition type-id.h:49
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition type-id.cc:1001
Time stopTime
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition log.h:191
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Ptr< T > Create(Ts &&... args)
Create class instances by constructors with varying numbers of arguments and return them by Ptr.
Definition ptr.h:436
Every class exported by the ns3 library is enclosed in the ns3 namespace.
const double NaN
Stored representation of NaN.