2008-03-31 14:50:25 -07:00
|
|
|
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
|
|
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2008 INRIA
|
|
|
|
|
*
|
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License version 2 as
|
|
|
|
|
* published by the Free Software Foundation;
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
|
*
|
|
|
|
|
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
|
|
|
|
|
*/
|
2008-02-14 23:56:21 +01:00
|
|
|
#include "node-container.h"
|
2008-03-24 10:41:44 -07:00
|
|
|
#include "ns3/node-list.h"
|
2009-01-22 23:07:34 -08:00
|
|
|
#include "ns3/names.h"
|
2008-02-14 23:56:21 +01:00
|
|
|
|
|
|
|
|
namespace ns3 {
|
|
|
|
|
|
2008-03-01 05:40:06 +01:00
|
|
|
NodeContainer::NodeContainer ()
|
|
|
|
|
{}
|
|
|
|
|
|
|
|
|
|
NodeContainer::NodeContainer (Ptr<Node> node)
|
|
|
|
|
{
|
|
|
|
|
m_nodes.push_back (node);
|
|
|
|
|
}
|
2009-01-20 17:39:18 -08:00
|
|
|
NodeContainer::NodeContainer (std::string nodeName)
|
|
|
|
|
{
|
|
|
|
|
Ptr<Node> node = Names::Find<Node> (nodeName);
|
|
|
|
|
m_nodes.push_back (node);
|
|
|
|
|
}
|
2008-03-01 05:40:06 +01:00
|
|
|
NodeContainer::NodeContainer (const NodeContainer &a, const NodeContainer &b)
|
|
|
|
|
{
|
|
|
|
|
Add (a);
|
|
|
|
|
Add (b);
|
|
|
|
|
}
|
2008-03-26 14:50:56 -07:00
|
|
|
NodeContainer::NodeContainer (const NodeContainer &a, const NodeContainer &b,
|
2008-10-24 12:31:57 +02:00
|
|
|
const NodeContainer &c)
|
2008-03-26 14:50:56 -07:00
|
|
|
{
|
|
|
|
|
Add (a);
|
|
|
|
|
Add (b);
|
|
|
|
|
Add (c);
|
|
|
|
|
}
|
|
|
|
|
NodeContainer::NodeContainer (const NodeContainer &a, const NodeContainer &b,
|
2008-10-24 12:31:57 +02:00
|
|
|
const NodeContainer &c, const NodeContainer &d)
|
2008-03-26 14:50:56 -07:00
|
|
|
{
|
|
|
|
|
Add (a);
|
|
|
|
|
Add (b);
|
|
|
|
|
Add (c);
|
|
|
|
|
Add (d);
|
|
|
|
|
}
|
2008-03-01 05:40:06 +01:00
|
|
|
|
2008-11-19 15:54:12 -08:00
|
|
|
NodeContainer::NodeContainer (const NodeContainer &a, const NodeContainer &b,
|
|
|
|
|
const NodeContainer &c, const NodeContainer &d,
|
|
|
|
|
const NodeContainer &e)
|
|
|
|
|
{
|
|
|
|
|
Add (a);
|
|
|
|
|
Add (b);
|
|
|
|
|
Add (c);
|
|
|
|
|
Add (d);
|
|
|
|
|
Add (e);
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-14 23:56:21 +01:00
|
|
|
NodeContainer::Iterator
|
|
|
|
|
NodeContainer::Begin (void) const
|
|
|
|
|
{
|
|
|
|
|
return m_nodes.begin ();
|
|
|
|
|
}
|
|
|
|
|
NodeContainer::Iterator
|
|
|
|
|
NodeContainer::End (void) const
|
|
|
|
|
{
|
|
|
|
|
return m_nodes.end ();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint32_t
|
|
|
|
|
NodeContainer::GetN (void) const
|
|
|
|
|
{
|
|
|
|
|
return m_nodes.size ();
|
|
|
|
|
}
|
|
|
|
|
Ptr<Node>
|
|
|
|
|
NodeContainer::Get (uint32_t i) const
|
|
|
|
|
{
|
|
|
|
|
return m_nodes[i];
|
|
|
|
|
}
|
|
|
|
|
void
|
|
|
|
|
NodeContainer::Create (uint32_t n)
|
|
|
|
|
{
|
|
|
|
|
for (uint32_t i = 0; i < n; i++)
|
|
|
|
|
{
|
|
|
|
|
m_nodes.push_back (CreateObject<Node> ());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void
|
|
|
|
|
NodeContainer::Add (NodeContainer other)
|
|
|
|
|
{
|
|
|
|
|
for (Iterator i = other.Begin (); i != other.End (); i++)
|
|
|
|
|
{
|
|
|
|
|
m_nodes.push_back (*i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
void
|
|
|
|
|
NodeContainer::Add (Ptr<Node> node)
|
|
|
|
|
{
|
|
|
|
|
m_nodes.push_back (node);
|
|
|
|
|
}
|
2009-01-20 17:39:18 -08:00
|
|
|
void
|
|
|
|
|
NodeContainer::Add (std::string nodeName)
|
|
|
|
|
{
|
|
|
|
|
Ptr<Node> node = Names::Find<Node> (nodeName);
|
|
|
|
|
m_nodes.push_back (node);
|
|
|
|
|
}
|
2008-02-14 23:56:21 +01:00
|
|
|
|
2008-03-24 10:41:44 -07:00
|
|
|
NodeContainer
|
|
|
|
|
NodeContainer::GetGlobal (void)
|
|
|
|
|
{
|
|
|
|
|
NodeContainer c;
|
|
|
|
|
for (NodeList::Iterator i = NodeList::Begin (); i != NodeList::End (); ++i)
|
|
|
|
|
{
|
|
|
|
|
c.Add (*i);
|
|
|
|
|
}
|
|
|
|
|
return c;
|
|
|
|
|
}
|
|
|
|
|
|
2008-02-14 23:56:21 +01:00
|
|
|
} // namespace ns3
|