diff --git a/src/node/net-device-container.cc b/src/node/net-device-container.cc new file mode 100644 index 000000000..9bde8226c --- /dev/null +++ b/src/node/net-device-container.cc @@ -0,0 +1,40 @@ +#include "net-device-container.h" + +namespace ns3 { + +NetDeviceContainer::Iterator +NetDeviceContainer::Begin (void) const +{ + return m_nodes.begin (); +} +NetDeviceContainer::Iterator +NetDeviceContainer::End (void) const +{ + return m_nodes.end (); +} + +uint32_t +NetDeviceContainer::GetN (void) const +{ + return m_nodes.size (); +} +Ptr +NetDeviceContainer::Get (uint32_t i) const +{ + return m_nodes[i]; +} +void +NetDeviceContainer::Add (NetDeviceContainer other) +{ + for (Iterator i = other.Begin (); i != other.End (); i++) + { + m_nodes.push_back (*i); + } +} +void +NetDeviceContainer::Add (Ptr node) +{ + m_nodes.push_back (node); +} + +} // namespace ns3 diff --git a/src/node/net-device-container.h b/src/node/net-device-container.h new file mode 100644 index 000000000..e90192067 --- /dev/null +++ b/src/node/net-device-container.h @@ -0,0 +1,31 @@ +#ifndef NET_DEVICE_CONTAINER_H +#define NET_DEVICE_CONTAINER_H + +#include +#include +#include "net-device.h" + +namespace ns3 { + +class NetDeviceContainer +{ +public: + typedef std::vector >::const_iterator Iterator; + + Iterator Begin (void) const; + Iterator End (void) const; + + uint32_t GetN (void) const; + Ptr Get (uint32_t i) const; + + void Create (uint32_t n); + void Add (NetDeviceContainer other); + void Add (Ptr node); + +private: + std::vector > m_nodes; +}; + +} // namespace ns3 + +#endif /* NET_DEVICE_CONTAINER_H */ diff --git a/src/node/node-container.cc b/src/node/node-container.cc new file mode 100644 index 000000000..6952da70f --- /dev/null +++ b/src/node/node-container.cc @@ -0,0 +1,48 @@ +#include "node-container.h" + +namespace ns3 { + +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 +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 ()); + } +} +void +NodeContainer::Add (NodeContainer other) +{ + for (Iterator i = other.Begin (); i != other.End (); i++) + { + m_nodes.push_back (*i); + } +} +void +NodeContainer::Add (Ptr node) +{ + m_nodes.push_back (node); +} + +} // namespace ns3 diff --git a/src/node/node-container.h b/src/node/node-container.h new file mode 100644 index 000000000..c7eb31c1b --- /dev/null +++ b/src/node/node-container.h @@ -0,0 +1,31 @@ +#ifndef NODE_CONTAINER_H +#define NODE_CONTAINER_H + +#include +#include +#include "node.h" + +namespace ns3 { + +class NodeContainer +{ +public: + typedef std::vector >::const_iterator Iterator; + + Iterator Begin (void) const; + Iterator End (void) const; + + uint32_t GetN (void) const; + Ptr Get (uint32_t i) const; + + void Create (uint32_t n); + void Add (NodeContainer other); + void Add (Ptr node); + + private: + std::vector > m_nodes; +}; + +} // namespace ns3 + +#endif /* NODE_CONTAINER_H */