A Discrete-Event Network Simulator
API
ipv4-list-routing-helper.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  */
21 #include "ns3/ipv4-list-routing.h"
22 #include "ns3/node.h"
23 
24 namespace ns3 {
25 
27 {
28 }
29 
31 {
32  for (std::list<std::pair<const Ipv4RoutingHelper *, int16_t> >::iterator i = m_list.begin ();
33  i != m_list.end (); ++i)
34  {
35  delete i->first;
36  }
37 }
38 
40 {
41  std::list<std::pair<const Ipv4RoutingHelper *, int16_t> >::const_iterator i;
42  for (i = o.m_list.begin (); i != o.m_list.end (); ++i)
43  {
44  m_list.push_back (std::make_pair (const_cast<const Ipv4RoutingHelper *> (i->first->Copy ()), i->second));
45  }
46 }
47 
50 {
51  return new Ipv4ListRoutingHelper (*this);
52 }
53 
54 void
55 Ipv4ListRoutingHelper::Add (const Ipv4RoutingHelper &routing, int16_t priority)
56 {
57  m_list.push_back (std::make_pair (const_cast<const Ipv4RoutingHelper *> (routing.Copy ()), priority));
58 }
59 
62 {
63  Ptr<Ipv4ListRouting> list = CreateObject<Ipv4ListRouting> ();
64  for (std::list<std::pair<const Ipv4RoutingHelper *, int16_t> >::const_iterator i = m_list.begin ();
65  i != m_list.end (); ++i)
66  {
67  Ptr<Ipv4RoutingProtocol> prot = i->first->Create (node);
68  list->AddRoutingProtocol (prot,i->second);
69  }
70  return list;
71 }
72 
73 } // namespace ns3
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
virtual Ipv4RoutingHelper * Copy(void) const =0
virtual constructor
Ipv4ListRoutingHelper * Copy(void) const
a factory to create ns3::Ipv4RoutingProtocol objects
#define list
Every class exported by the ns3 library is enclosed in the ns3 namespace.
std::list< std::pair< const Ipv4RoutingHelper *, int16_t > > m_list
Container for pairs of Ipv4RoutingHelper pointer / priority.
virtual Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
Helper class that adds ns3::Ipv4ListRouting objects.