19 #include "ns3/simulator.h"
20 #include "ns3/object-vector.h"
21 #include "ns3/config.h"
23 #include "ns3/assert.h"
24 #include "channel-list.h"
37 static TypeId GetTypeId (
void);
43 ChannelList::Iterator Begin (
void)
const;
44 ChannelList::Iterator End (
void)
const;
47 uint32_t GetNChannels (
void);
53 static void Delete (
void);
55 std::vector<Ptr<Channel> > m_channels;
61 ChannelListPriv::GetTypeId (
void)
65 .AddAttribute (
"ChannelList",
"The list of all channels created during the simulation.",
67 MakeObjectVectorAccessor (&ChannelListPriv::m_channels),
68 MakeObjectVectorChecker<Channel> ())
74 ChannelListPriv::Get (
void)
80 Ptr<ChannelListPriv> *
81 ChannelListPriv::DoGet (
void)
84 static Ptr<ChannelListPriv> ptr = 0;
87 ptr = CreateObject<ChannelListPriv> ();
95 ChannelListPriv::Delete (
void)
102 ChannelListPriv::ChannelListPriv ()
107 ChannelListPriv::~ChannelListPriv ()
115 for (std::vector<
Ptr<Channel> >::iterator i = m_channels.begin ();
116 i != m_channels.end (); i++)
122 m_channels.erase (m_channels.begin (), m_channels.end ());
130 uint32_t index = m_channels.size ();
131 m_channels.push_back (channel);
136 ChannelList::Iterator
137 ChannelListPriv::Begin (
void)
const
140 return m_channels.begin ();
143 ChannelList::Iterator
144 ChannelListPriv::End (
void)
const
147 return m_channels.end ();
151 ChannelListPriv::GetNChannels (
void)
154 return m_channels.size ();
158 ChannelListPriv::GetChannel (uint32_t n)
161 NS_ASSERT_MSG (n < m_channels.size (),
"Channel index " << n <<
162 " is out of range (only have " << m_channels.size () <<
" channels).");
163 return m_channels[n];
170 return ChannelListPriv::Get ()->Add (channel);
173 ChannelList::Iterator
177 return ChannelListPriv::Get ()->Begin ();
180 ChannelList::Iterator
184 return ChannelListPriv::Get ()->End ();
191 return ChannelListPriv::Get ()->GetChannel (n);
198 return ChannelListPriv::Get ()->GetNChannels ();
smart pointer class similar to boost::intrusive_ptr
#define NS_LOG_FUNCTION(parameters)
static uint32_t GetNChannels(void)
#define NS_LOG_COMPONENT_DEFINE(name)
virtual void DoDispose(void)
virtual void DoDispose(void)
void UnregisterRootNamespaceObject(Ptr< Object > obj)
#define NS_LOG_FUNCTION_NOARGS()
static Iterator Begin(void)
private implementation detail of the ChannelList API.
void RegisterRootNamespaceObject(Ptr< Object > obj)
#define NS_ASSERT_MSG(condition, message)
static uint32_t Add(Ptr< Channel > channel)
static EventId ScheduleDestroy(MEM mem_ptr, OBJ obj)
static Iterator End(void)
a base class which provides memory management and object aggregation
contain a set of ns3::Object pointers.
static Ptr< Channel > GetChannel(uint32_t n)
a unique identifier for an interface.
TypeId SetParent(TypeId tid)