A Discrete-Event Network Simulator
API
ipv6-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  */
20 
21 #include "ns3/ipv6-list-routing.h"
22 #include "ns3/node.h"
23 
25 
26 namespace ns3 {
27 
29 {
30 }
31 
33 {
34  for (std::list<std::pair<const Ipv6RoutingHelper *, int16_t> >::iterator i = m_list.begin ();
35  i != m_list.end (); ++i)
36  {
37  delete i->first;
38  }
39 }
41 {
42  std::list<std::pair<const Ipv6RoutingHelper *, int16_t> >::const_iterator i;
43  for (i = o.m_list.begin (); i != o.m_list.end (); ++i)
44  {
45  m_list.push_back (std::make_pair (const_cast<const Ipv6RoutingHelper *> (i->first->Copy ()), i->second));
46  }
47 }
48 
51 {
52  return new Ipv6ListRoutingHelper (*this);
53 }
54 
55 void
56 Ipv6ListRoutingHelper::Add (const Ipv6RoutingHelper &routing, int16_t priority)
57 {
58  m_list.push_back (std::make_pair (const_cast<const Ipv6RoutingHelper *> (routing.Copy ()), priority));
59 }
62 {
63  Ptr<Ipv6ListRouting> list = CreateObject<Ipv6ListRouting> ();
64  for (std::list<std::pair<const Ipv6RoutingHelper *,int16_t> >::const_iterator i = m_list.begin ();
65  i != m_list.end (); ++i)
66  {
67  Ptr<Ipv6RoutingProtocol> 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 Ipv6RoutingHelper * Copy(void) const =0
virtual constructor
std::list< std::pair< const Ipv6RoutingHelper *, int16_t > > m_list
Container for pairs of Ipv6RoutingHelper pointer / priority.
Ipv6ListRoutingHelper()
Construct an Ipv6 Ipv6ListRoutingHelper which is used to make life easier for people wanting to confi...
virtual Ptr< Ipv6RoutingProtocol > Create(Ptr< Node > node) const
A factory to create ns3::Ipv6RoutingProtocol objects.
#define list
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void Add(const Ipv6RoutingHelper &routing, int16_t priority)
virtual ~Ipv6ListRoutingHelper()
Destroy an Ipv6 Ipv6ListRoutingHelper.
Helper class that adds ns3::Ipv6ListRouting objects.
Ipv6ListRoutingHelper * Copy(void) const