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 {
39 }
40 
42 {
44 }
45 
46 void
48 {
50 
53 
55  // DataCalculator::DoDispose
56 }
57 
58 //----------------------------------------------
59 void
60 DataCalculator::SetKey (const std::string key)
61 {
62  m_key = key;
63  // end DataCalculator::SetKey
64 }
65 
66 std::string
68 {
69  return m_key;
70  // end DataCalculator::GetKey
71 }
72 
73 //----------------------------------------------
74 void
75 DataCalculator::SetContext (const std::string context)
76 {
77  m_context = context;
78  // end DataCalculator::SetContext
79 }
80 
81 std::string
83 {
84  return m_context;
85  // end DataCalculator::GetContext
86 }
87 //----------------------------------------------
88 void
90 {
91  m_enabled = true;
92  // end DataCalculator::Enable
93 }
94 
95 void
97 {
98  m_enabled = false;
99  // end DataCalculator::Disable
100 }
101 
102 bool
104 {
105  return m_enabled;
106  // end DataCalculator::GetEnabled
107 }
108 
109 //----------------------------------------------
110 void
112 {
113 
114  m_startEvent = Simulator::Schedule (startTime,
115  &DataCalculator::Enable, this);
116 
117  // end DataCalculator::Start
118 }
119 
120 void
122 {
123  m_stopEvent = Simulator::Schedule (stopTime,
124  &DataCalculator::Disable, this);
125  // end DataCalculator::Stop
126 }
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
NS_LOG_COMPONENT_DEFINE("GrantedTimeWindowMpiInterface")
void SetKey(const std::string key)
Sets the DataCalculator key to the provided key.
std::string GetKey() const
Gets the DataCalculator key.
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:336
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
#define NS_LOG_FUNCTION_NOARGS()
Output the name of the function.
Definition: log.h:309
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:824
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.