A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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/node.h"
26
#include "ns3/nstime.h"
27
#include "ns3/simulator.h"
28
29
using namespace
std;
30
31
namespace
ns3 {
32
33
NS_OBJECT_ENSURE_REGISTERED
(Application);
34
35
// Application Methods
36
37
TypeId
38
Application::GetTypeId (
void
)
39
{
40
static
TypeId
tid =
TypeId
(
"ns3::Application"
)
41
.
SetParent
<
Object
> ()
42
.AddAttribute (
"StartTime"
,
"Time at which the application will start"
,
43
TimeValue
(
Seconds
(0.0)),
44
MakeTimeAccessor (&Application::m_startTime),
45
MakeTimeChecker ())
46
.AddAttribute (
"StopTime"
,
"Time at which the application will stop"
,
47
TimeValue
(
TimeStep
(0)),
48
MakeTimeAccessor (&Application::m_stopTime),
49
MakeTimeChecker ())
50
;
51
return
tid;
52
}
53
54
// \brief Application Constructor
55
Application::Application()
56
{
57
}
58
59
// \brief Application Destructor
60
Application::~Application()
61
{
62
}
63
64
void
65
Application::SetStartTime (
Time
start
)
66
{
67
m_startTime =
start
;
68
}
69
void
70
Application::SetStopTime (
Time
stop)
71
{
72
m_stopTime = stop;
73
}
74
75
76
void
77
Application::DoDispose (
void
)
78
{
79
m_node = 0;
80
m_startEvent.Cancel ();
81
m_stopEvent.Cancel ();
82
Object::DoDispose ();
83
}
84
85
void
86
Application::DoStart (
void
)
87
{
88
m_startEvent = Simulator::Schedule (m_startTime, &Application::StartApplication,
this
);
89
if
(m_stopTime !=
TimeStep
(0))
90
{
91
m_stopEvent = Simulator::Schedule (m_stopTime, &Application::StopApplication,
this
);
92
}
93
Object::DoStart ();
94
}
95
96
Ptr<Node>
Application::GetNode ()
const
97
{
98
return
m_node;
99
}
100
101
void
102
Application::SetNode (
Ptr<Node>
node)
103
{
104
m_node = node;
105
}
106
107
// Protected methods
108
// StartApp and StopApp will likely be overridden by application subclasses
109
void
Application::StartApplication ()
110
{
// Provide null functionality in case subclass is not interested
111
}
112
113
void
Application::StopApplication ()
114
{
// Provide null functionality in case subclass is not interested
115
}
116
117
}
// namespace ns3
118
119
src
network
model
application.cc
Generated on Tue Oct 9 2012 16:45:43 for ns-3 by
1.8.1.2