A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 NS_LOG_COMPONENT_DEFINE ("Application");
31 
32 namespace ns3 {
33 
34 NS_OBJECT_ENSURE_REGISTERED (Application)
35  ;
36 
37 // Application Methods
38 
39 TypeId
41 {
42  static TypeId tid = TypeId ("ns3::Application")
43  .SetParent<Object> ()
44  .AddAttribute ("StartTime", "Time at which the application will start",
45  TimeValue (Seconds (0.0)),
46  MakeTimeAccessor (&Application::m_startTime),
47  MakeTimeChecker ())
48  .AddAttribute ("StopTime", "Time at which the application will stop",
49  TimeValue (TimeStep (0)),
50  MakeTimeAccessor (&Application::m_stopTime),
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 
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
keep track of time values and allow control of global simulation resolution
Definition: nstime.h:81
#define NS_LOG_FUNCTION(parameters)
Definition: log.h:345
Time TimeStep(uint64_t ts)
Definition: nstime.h:950
static TypeId GetTypeId(void)
Definition: application.cc:40
NS_OBJECT_ENSURE_REGISTERED(NullMessageSimulatorImpl)
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: object.cc:336
NS_LOG_COMPONENT_DEFINE("Application")
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
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: application.cc:93
hold objects of type ns3::Time
Definition: nstime.h:961
virtual void StartApplication(void)
Application specific startup code.
Definition: application.cc:119
Ptr< Node > GetNode() const
Definition: application.cc:104
Time m_stopTime
The simulation time that the appliacation will start.
Definition: application.h:128
virtual void DoDispose(void)
This method is called by Object::Dispose or by the object's destructor, whichever comes first...
Definition: application.cc:83
Ptr< Node > m_node
Definition: application.h:126
EventId m_startEvent
The simulation time that the appliacation will end.
Definition: application.h:129
void SetNode(Ptr< Node > node)
Definition: application.cc:111
virtual void StopApplication(void)
Application specific shutdown code.
Definition: application.cc:124
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::cancel method.
Definition: event-id.cc:47
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:452
EventId m_stopEvent
The event that will fire at m_startTime to start the application.
Definition: application.h:130
a base class which provides memory management and object aggregation
Definition: object.h:63
Time m_startTime
The node that this application is installed on.
Definition: application.h:127
a unique identifier for an interface.
Definition: type-id.h:49
TypeId SetParent(TypeId tid)
Definition: type-id.cc:611
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
virtual ~Application()
Definition: application.cc:63
virtual void DoInitialize(void)
This method is called only once by Object::Initialize.
Definition: object.cc:343