A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
ipv4-list-routing-helper.cc
Go to the documentation of this file.
1/*
2 * Copyright (c) 2008 INRIA
3 *
4 * SPDX-License-Identifier: GPL-2.0-only
5 *
6 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
7 */
9
10#include "ns3/ipv4-list-routing.h"
11#include "ns3/node.h"
12
13namespace ns3
14{
15
19
21{
22 for (auto i = m_list.begin(); i != m_list.end(); ++i)
23 {
24 delete i->first;
25 }
26}
27
29{
30 for (auto i = o.m_list.begin(); i != o.m_list.end(); ++i)
31 {
32 m_list.emplace_back(const_cast<const Ipv4RoutingHelper*>(i->first->Copy()), i->second);
33 }
34}
35
38{
39 return new Ipv4ListRoutingHelper(*this);
40}
41
42void
43Ipv4ListRoutingHelper::Add(const Ipv4RoutingHelper& routing, int16_t priority)
44{
45 m_list.emplace_back(const_cast<const Ipv4RoutingHelper*>(routing.Copy()), priority);
46}
47
50{
52 for (auto i = m_list.begin(); i != m_list.end(); ++i)
53 {
54 Ptr<Ipv4RoutingProtocol> prot = i->first->Create(node);
55 list->AddRoutingProtocol(prot, i->second);
56 }
57 return list;
58}
59
60} // namespace ns3
Helper class that adds ns3::Ipv4ListRouting objects.
Ipv4ListRoutingHelper * Copy() const override
Ptr< Ipv4RoutingProtocol > Create(Ptr< Node > node) const override
void Add(const Ipv4RoutingHelper &routing, int16_t priority)
std::list< std::pair< const Ipv4RoutingHelper *, int16_t > > m_list
Container for pairs of Ipv4RoutingHelper pointer / priority.
a factory to create ns3::Ipv4RoutingProtocol objects
virtual Ipv4RoutingHelper * Copy() const =0
virtual constructor
Smart pointer class similar to boost::intrusive_ptr.
Ptr< T > CreateObject(Args &&... args)
Create an object by type, with varying number of constructor parameters.
Definition object.h:619
Every class exported by the ns3 library is enclosed in the ns3 namespace.
#define list