A Discrete-Event Network Simulator
API
application.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2006 Georgia Tech Research Corporation
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: George F. Riley<riley@ece.gatech.edu>
19  */
20 
21 // Implementation for ns3 Application base class.
22 // George F. Riley, Georgia Tech, Fall 2006
23 
24 #include "application.h"
25 #include "ns3/log.h"
26 #include "ns3/node.h"
27 #include "ns3/nstime.h"
28 #include "ns3/simulator.h"
29 
30 namespace ns3 {
31 
32 NS_LOG_COMPONENT_DEFINE ("Application");
33 
34 NS_OBJECT_ENSURE_REGISTERED (Application);
35 
36 // Application Methods
37 
38 TypeId
40 {
41  static TypeId tid = TypeId ("ns3::Application")
42  .SetParent<Object> ()
43  .SetGroupName("Network")
44  .AddAttribute ("StartTime", "Time at which the application will start",
45  TimeValue (Seconds (0.0)),
47  MakeTimeChecker ())
48  .AddAttribute ("StopTime", "Time at which the application will stop",
49  TimeValue (TimeStep (0)),
51  MakeTimeChecker ())
52  ;
53  return tid;
54 }
55 
56 // \brief Application Constructor
58 {
59  NS_LOG_FUNCTION (this);
60 }
61 
62 // \brief Application Destructor
64 {
65  NS_LOG_FUNCTION (this);
66 }
67 
68 void
70 {
71  NS_LOG_FUNCTION (this << start);
73 }
74 void
76 {
77  NS_LOG_FUNCTION (this << stop);
78  m_stopTime = stop;
79 }
80 
81 
82 void
84 {
85  NS_LOG_FUNCTION (this);
86  m_node = 0;
90 }
91 
92 void
94 {
95  NS_LOG_FUNCTION (this);
97  if (m_stopTime != TimeStep (0))
98  {
100  }
102 }
103 
105 {
106  NS_LOG_FUNCTION (this);
107  return m_node;
108 }
109 
110 void
112 {
113  NS_LOG_FUNCTION (this);
114  m_node = node;
115 }
116 
117 // Protected methods
118 // StartApp and StopApp will likely be overridden by application subclasses
120 { // Provide null functionality in case subclass is not interested
121  NS_LOG_FUNCTION (this);
122 }
123 
125 { // Provide null functionality in case subclass is not interested
126  NS_LOG_FUNCTION (this);
127 }
128 
129 } // namespace ns3
130 
131 
ns3::TypeId
a unique identifier for an interface.
Definition: type-id.h:59
NS_LOG_COMPONENT_DEFINE
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:205
ns3::Application::m_node
Ptr< Node > m_node
The node that this application is installed on.
Definition: application.h:148
NS_OBJECT_ENSURE_REGISTERED
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
ns3::MakeTimeChecker
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:533
ns3::Application::m_startEvent
EventId m_startEvent
The event that will fire at m_startTime to start the application.
Definition: application.h:151
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
ns3::Application::Application
Application()
Definition: application.cc:57
ns3::Application::m_stopTime
Time m_stopTime
The simulation time that the application will end.
Definition: application.h:150
ns3::Application::StopApplication
virtual void StopApplication(void)
Application specific shutdown code.
Definition: application.cc:124
ns3::Application::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: application.cc:83
ns3::Simulator::Schedule
static EventId Schedule(Time const &delay, FUNC f, Ts &&... args)
Schedule an event to expire after delay.
Definition: simulator.h:556
ns3::Application::SetNode
void SetNode(Ptr< Node > node)
Definition: application.cc:111
ns3::TypeId::SetParent
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:923
ns3::Application::m_stopEvent
EventId m_stopEvent
The event that will fire at m_stopTime to end the application.
Definition: application.h:152
ns3::Application::SetStopTime
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
ns3::Ptr< Node >
visualizer.core.start
def start()
Definition: core.py:1855
ns3::Application::SetStartTime
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
ns3::Object
A base class which provides memory management and object aggregation.
Definition: object.h:88
ns3::EventId::Cancel
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
ns3::Time
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:104
ns3::Application::m_startTime
Time m_startTime
The simulation time that the application will start.
Definition: application.h:149
ns3::Object::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:353
ns3::Application::GetTypeId
static TypeId GetTypeId(void)
Get the type ID.
Definition: application.cc:39
ns3::Application::~Application
virtual ~Application()
Definition: application.cc:63
ns3::Seconds
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1289
ns3::TimeValue
AttributeValue implementation for Time.
Definition: nstime.h:1353
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:244
ns3::Application::GetNode
Ptr< Node > GetNode() const
Definition: application.cc:104
ns3::Application::StartApplication
virtual void StartApplication(void)
Application specific startup code.
Definition: application.cc:119
ns3::Object::DoDispose
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
ns3::MakeTimeAccessor
Ptr< const AttributeAccessor > MakeTimeAccessor(T1 a1)
Create an AttributeAccessor for a class data member, or a lone class get functor or set method.
Definition: nstime.h:1354
ns3::Application::DoInitialize
virtual void DoInitialize(void)
Initialize() implementation.
Definition: application.cc:93
application.h