A Discrete-Event Network Simulator
API
application-container.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2008 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 
21 #include "ns3/names.h"
22 #include "ns3/log.h"
23 #include "application-container.h"
24 
25 namespace ns3 {
26 
27 NS_LOG_COMPONENT_DEFINE ("ApplicationContainer");
28 
30 {
31 }
32 
34 {
35  m_applications.push_back (app);
36 }
37 
39 {
40  Ptr<Application> app = Names::Find<Application> (name);
41  m_applications.push_back (app);
42 }
43 
44 
47 {
48  return m_applications.begin ();
49 }
52 {
53  return m_applications.end ();
54 }
55 
56 uint32_t
58 {
59  return m_applications.size ();
60 }
62 ApplicationContainer::Get (uint32_t i) const
63 {
64  return m_applications[i];
65 }
66 void
68 {
69  for (Iterator i = other.Begin (); i != other.End (); i++)
70  {
71  m_applications.push_back (*i);
72  }
73 }
74 void
76 {
77  m_applications.push_back (application);
78 }
79 void
80 ApplicationContainer::Add (std::string name)
81 {
82  Ptr<Application> application = Names::Find<Application> (name);
83  m_applications.push_back (application);
84 }
85 
86 void
88 {
89  for (Iterator i = Begin (); i != End (); ++i)
90  {
91  Ptr<Application> app = *i;
92  app->SetStartTime (start);
93  }
94 }
95 void
97 {
98  for (Iterator i = Begin (); i != End (); ++i)
99  {
100  Ptr<Application> app = *i;
101  double value = rv->GetValue ();
102  NS_LOG_DEBUG ("Start application at time " << start.GetSeconds () + value << "s");
103  app->SetStartTime (start + Seconds (value));
104  }
105 }
106 void
108 {
109  for (Iterator i = Begin (); i != End (); ++i)
110  {
111  Ptr<Application> app = *i;
112  app->SetStopTime (stop);
113  }
114 }
115 
116 
117 } // namespace ns3
holds a vector of ns3::Application pointers.
void SetStopTime(Time stop)
Specify application stop time.
Definition: application.cc:75
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
std::vector< Ptr< Application > > m_applications
Applications smart pointers.
void Add(ApplicationContainer other)
Append the contents of another ApplicationContainer to the end of this container. ...
def start()
Definition: core.py:1844
Iterator End(void) const
Get an iterator which indicates past-the-last Application in the container.
#define NS_LOG_COMPONENT_DEFINE(name)
Define a Log component with a specific name.
Definition: log.h:202
Iterator Begin(void) const
Get an iterator which refers to the first Application in the container.
void StartWithJitter(Time start, Ptr< RandomVariableStream > rv)
Start all of the Applications in this container at the start time given as a parameter, plus some jitter.
virtual double GetValue(void)=0
Get the next random value as a double drawn from the distribution.
std::vector< Ptr< Application > >::const_iterator Iterator
Application container iterator.
ApplicationContainer()
Create an empty ApplicationContainer.
void Start(Time start)
Arrange for all of the Applications in this container to Start() at the Time given as a parameter...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Stop(Time stop)
Arrange for all of the Applications in this container to Stop() at the Time given as a parameter...
#define NS_LOG_DEBUG(msg)
Use NS_LOG to output a message of level LOG_DEBUG.
Definition: log.h:270
Time Seconds(double value)
Construct a Time in the indicated unit.
Definition: nstime.h:1014
void SetStartTime(Time start)
Specify application start time.
Definition: application.cc:69
Ptr< Application > Get(uint32_t i) const
Get the Ptr<Application> stored in this container at a given index.
uint32_t GetN(void) const
Get the number of Ptr<Application> stored in this container.