src/helper/application-container.cc
author Craig Dowell <craigdo@ee.washington.edu>
Tue, 20 Jan 2009 17:39:18 -0800
changeset 4140 6bbf05bf4826
parent 3848 affd0834debc
child 4147 5d8530130930
permissions -rw-r--r--
Brute force all of the helpers to use object name service
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2833
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     2
/*
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     3
 * Copyright (c) 2008 INRIA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     4
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     5
 * This program is free software; you can redistribute it and/or modify
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     6
 * it under the terms of the GNU General Public License version 2 as
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     7
 * published by the Free Software Foundation;
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     8
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
     9
 * This program is distributed in the hope that it will be useful,
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    10
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    11
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    12
 * GNU General Public License for more details.
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    13
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    14
 * You should have received a copy of the GNU General Public License
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    15
 * along with this program; if not, write to the Free Software
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    16
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    17
 *
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    18
 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
f3474fd850b2 add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2731
diff changeset
    19
 */
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    20
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    21
#include "ns3/object-names.h"
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    22
#include "application-container.h"
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    23
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    24
namespace ns3 {
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    25
3848
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    26
ApplicationContainer::ApplicationContainer ()
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    27
{}
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    28
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    29
ApplicationContainer::ApplicationContainer (Ptr<Application> app)
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    30
{
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    31
  m_applications.push_back (app);
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    32
}
affd0834debc address bug 393 (need to overload Install methods for python)
Craig Dowell <craigdo@ee.washington.edu>
parents: 2834
diff changeset
    33
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    34
ApplicationContainer::ApplicationContainer (std::string name)
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    35
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    36
  Ptr<Application> app = Names::Find<Application> (name);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    37
  m_applications.push_back (app);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    38
}
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    39
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    40
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    41
ApplicationContainer::Iterator 
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    42
ApplicationContainer::Begin (void) const
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    43
{
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    44
  return m_applications.begin ();
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    45
}
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    46
ApplicationContainer::Iterator 
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    47
ApplicationContainer::End (void) const
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    48
{
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    49
  return m_applications.end ();
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    50
}
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    51
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    52
uint32_t 
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    53
ApplicationContainer::GetN (void) const
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    54
{
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    55
  return m_applications.size ();
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    56
}
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    57
Ptr<Application> 
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    58
ApplicationContainer::Get (uint32_t i) const
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    59
{
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    60
  return m_applications[i];
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    61
}
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    62
void 
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    63
ApplicationContainer::Add (ApplicationContainer other)
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    64
{
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    65
  for (Iterator i = other.Begin (); i != other.End (); i++)
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    66
    {
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    67
      m_applications.push_back (*i);
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    68
    }
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    69
}
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    70
void 
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    71
ApplicationContainer::Add (Ptr<Application> application)
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    72
{
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    73
  m_applications.push_back (application);
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    74
}
4140
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    75
void 
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    76
ApplicationContainer::Add (std::string name)
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    77
{
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    78
  Ptr<Application> application = Names::Find<Application> (name);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    79
  m_applications.push_back (application);
6bbf05bf4826 Brute force all of the helpers to use object name service
Craig Dowell <craigdo@ee.washington.edu>
parents: 3848
diff changeset
    80
}
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
    81
2731
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    82
void 
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    83
ApplicationContainer::Start (Time start)
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    84
{
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    85
  for (Iterator i = Begin (); i != End (); ++i)
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    86
    {
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    87
      Ptr<Application> app = *i;
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    88
      app->Start (start);
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    89
    }
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    90
}
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    91
void 
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    92
ApplicationContainer::Stop (Time stop)
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    93
{
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    94
  for (Iterator i = Begin (); i != End (); ++i)
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    95
    {
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    96
      Ptr<Application> app = *i;
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    97
      app->Stop (stop);
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    98
    }
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
    99
}
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
   100
9eb9988afd08 a bunch of new helpers.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents: 2698
diff changeset
   101
2417
004ac83aca83 add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff changeset
   102
} // namespace ns3