A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 //----------------------------------------------
36  m_enabled (true)
37 {
38  NS_LOG_FUNCTION (this);
39 }
40 
42 {
43  NS_LOG_FUNCTION (this);
44 }
45 
46 void
48 {
49  NS_LOG_FUNCTION (this);
50 
53 
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
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
89 {
90  NS_LOG_FUNCTION (this);
91 
92  return m_context;
93  // end DataCalculator::GetContext
94 }
95 //----------------------------------------------
96 void
98 {
99  NS_LOG_FUNCTION (this);
100 
101  m_enabled = true;
102  // end DataCalculator::Enable
103 }
104 
105 void
107 {
108  NS_LOG_FUNCTION (this);
109 
110  m_enabled = false;
111  // end DataCalculator::Disable
112 }
113 
114 bool
116 {
117  NS_LOG_FUNCTION (this);
118 
119  return m_enabled;
120  // end DataCalculator::GetEnabled
121 }
122 
123 //----------------------------------------------
124 void
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
137 {
138  NS_LOG_FUNCTION (this << stopTime);
139 
140  m_stopEvent = Simulator::Schedule (stopTime,
141  &DataCalculator::Disable, this);
142  // end DataCalculator::Stop
143 }
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:79
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
std::string GetKey() const
Gets the DataCalculator key.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:170
bool m_enabled
Descendant classes must check & respect m_enabled!
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:335
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:268
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:825
static double zero
virtual void Stop(const Time &stopTime)
Stops DataCalculator at a given time in the simulation.
virtual void Start(const Time &startTime)
Starts DataCalculator at a given time in the simulation.
double stopTime
EventId m_startEvent
Start event.
std::string GetContext() const
Gets the DataCalculator context.
void Enable()
Enables DataCalculator when simulation starts.
bool GetEnabled() const
Returns whether the DataCalculator is enabled.
double startTime
EventId m_stopEvent
Stop event.
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
const double NaN
Stored representation of NaN.
void Disable()
Disables DataCalculator when simulation stops.
std::string m_context
Context value.
void SetContext(const std::string context)
Sets the DataCalculator context to the provided context.
std::string m_key
Key value.