A Discrete-Event Network Simulator
API
ipv6-option-demux.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2007-2009 Strasbourg University
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: David Gross <gdavid.devel@gmail.com>
19  */
20 
21 #include <sstream>
22 #include "ns3/node.h"
23 #include "ns3/ptr.h"
24 #include "ns3/object-vector.h"
25 #include "ipv6-option-demux.h"
26 #include "ipv6-option.h"
27 
28 namespace ns3
29 {
30 
31 NS_OBJECT_ENSURE_REGISTERED (Ipv6OptionDemux);
32 
34 {
35  static TypeId tid = TypeId ("ns3::Ipv6OptionDemux")
36  .SetParent<Object> ()
37  .SetGroupName ("Internet")
38  .AddAttribute ("Options", "The set of IPv6 options registered with this demux.",
41  MakeObjectVectorChecker<Ipv6Option> ())
42  ;
43  return tid;
44 }
45 
47 {
48 }
49 
51 {
52 }
53 
55 {
56  for (Ipv6OptionList_t::iterator it = m_options.begin (); it != m_options.end (); it++)
57  {
58  (*it)->Dispose ();
59  *it = 0;
60  }
61  m_options.clear ();
62  m_node = 0;
64 }
65 
67 {
68  m_node = node;
69 }
70 
72 {
73  m_options.push_back (option);
74 }
75 
77 {
78  for (Ipv6OptionList_t::iterator i = m_options.begin (); i != m_options.end (); ++i)
79  {
80  if ((*i)->GetOptionNumber () == optionNumber)
81  {
82  return *i;
83  }
84  }
85  return 0;
86 }
87 
89 {
90  m_options.remove (option);
91 }
92 
93 } /* namespace ns3 */
94 
static TypeId GetTypeId(void)
The interface ID.
Ipv6OptionDemux()
Constructor.
void Insert(Ptr< Ipv6Option > option)
Insert a new IPv6 Option.
virtual ~Ipv6OptionDemux()
Destructor.
Ptr< Node > m_node
The node.
void SetNode(Ptr< Node > node)
Set the node.
virtual void DoDispose()
Dispose this object.
void Remove(Ptr< Ipv6Option > option)
Remove an option from this demux.
Ipv6OptionList_t m_options
List of IPv6 Options supported.
Ptr< Ipv6Option > GetOption(int optionNumber)
Get the option corresponding to optionNumber.
A base class which provides memory management and object aggregation.
Definition: object.h:88
virtual void DoDispose(void)
Destructor implementation.
Definition: object.cc:346
Container for a set of ns3::Object pointers.
a unique identifier for an interface.
Definition: type-id.h:59
TypeId SetParent(TypeId tid)
Set the parent TypeId.
Definition: type-id.cc:922
Ptr< const AttributeAccessor > MakeObjectVectorAccessor(U T::*memberVariable)
MakeAccessorHelper implementation for ObjectVector.
Definition: object-vector.h:81
#define NS_OBJECT_ENSURE_REGISTERED(type)
Register an Object subclass with the TypeId system.
Definition: object-base.h:45
Every class exported by the ns3 library is enclosed in the ns3 namespace.