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  .AddAttribute ("StartTime", "Time at which the application will start",
44  TimeValue (Seconds (0.0)),
46  MakeTimeChecker ())
47  .AddAttribute ("StopTime", "Time at which the application will stop",
48  TimeValue (TimeStep (0)),
50  MakeTimeChecker ())
51  ;
52  return tid;
53 }
54 
55 // \brief Application Constructor
57 {
58  NS_LOG_FUNCTION (this);
59 }
60 
61 // \brief Application Destructor
63 {
64  NS_LOG_FUNCTION (this);
65 }
66 
67 void
69 {
70  NS_LOG_FUNCTION (this << start);
72 }
73 void
75 {
76  NS_LOG_FUNCTION (this << stop);
77  m_stopTime = stop;
78 }
79 
80 
81 void
83 {
84  NS_LOG_FUNCTION (this);
85  m_node = 0;
89 }
90 
91 void
93 {
94  NS_LOG_FUNCTION (this);
96  if (m_stopTime != TimeStep (0))
97  {
99  }
101 }
102 
104 {
105  NS_LOG_FUNCTION (this);
106  return m_node;
107 }
108 
109 void
111 {
112  NS_LOG_FUNCTION (this);
113  m_node = node;
114 }
115 
116 // Protected methods
117 // StartApp and StopApp will likely be overridden by application subclasses
119 { // Provide null functionality in case subclass is not interested
120  NS_LOG_FUNCTION (this);
121 }
122 
124 { // Provide null functionality in case subclass is not interested
125  NS_LOG_FUNCTION (this);
126 }
127 
128 } // namespace ns3
129 
130 
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:74
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:95
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by "...
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:44
static TypeId GetTypeId(void)
Get the type ID.
Definition: application.cc:39
def start()
Definition: core.py:1482
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:201
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:338
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:819
Ptr< const AttributeChecker > MakeTimeChecker(const Time min, const Time max)
Helper to make a Time checker with bounded range.
Definition: time.cc:439
virtual void DoInitialize(void)
Initialize() implementation.
Definition: application.cc:92
AttributeValue implementation for Time.
Definition: nstime.h:921
virtual void StartApplication(void)
Application specific startup code.
Definition: application.cc:118
Ptr< Node > GetNode() const
Definition: application.cc:103
Time m_stopTime
The simulation time that the application will end.
Definition: application.h:131
virtual void DoDispose(void)
Destructor implementation.
Definition: application.cc:82
Ptr< Node > m_node
The node that this application is installed on.
Definition: application.h:129
Every class exported by the ns3 library is enclosed in the ns3 namespace.
EventId m_startEvent
The event that will fire at m_startTime to start the application.
Definition: application.h:132
void SetNode(Ptr< Node > node)
Definition: application.cc:110
Time TimeStep(uint64_t ts)
Definition: nstime.h:916
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:922
virtual void StopApplication(void)
Application specific shutdown code.
Definition: application.cc:123
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:859
void Cancel(void)
This method is syntactic sugar for the ns3::Simulator::Cancel method.
Definition: event-id.cc:53
EventId m_stopEvent
The event that will fire at m_stopTime to end the application.
Definition: application.h:133
A base class which provides memory management and object aggregation.
Definition: object.h:87
Time m_startTime
The simulation time that the application will start.
Definition: application.h:130
a unique identifier for an interface.
Definition: type-id.h:51
TypeId SetParent(TypeId tid)
Definition: type-id.cc:631
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:68
virtual ~Application()
Definition: application.cc:62
virtual void DoInitialize(void)
Initialize() implementation.
Definition: object.cc:345