00001 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ 00002 /* 00003 * Copyright (c) 2008 INRIA 00004 * 00005 * This program is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License version 2 as 00007 * published by the Free Software Foundation; 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software 00016 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00017 * 00018 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> 00019 */ 00020 #ifndef NET_DEVICE_CONTAINER_H 00021 #define NET_DEVICE_CONTAINER_H 00022 00023 #include <stdint.h> 00024 #include <vector> 00025 #include "ns3/net-device.h" 00026 00027 namespace ns3 { 00028 00029 /** 00030 * \brief holds a vector of ns3::NetDevice pointers 00031 * 00032 */ 00033 class NetDeviceContainer 00034 { 00035 public: 00036 typedef std::vector<Ptr<NetDevice> >::const_iterator Iterator; 00037 00038 /** 00039 * Create an empty NetDeviceContainer. 00040 */ 00041 NetDeviceContainer (); 00042 /** 00043 * \param dev a device to add to the container 00044 * 00045 * Create a NetDeviceContainer with exactly one device 00046 */ 00047 NetDeviceContainer (Ptr<NetDevice> dev); 00048 /** 00049 * \param a a device container 00050 * \param b another device container 00051 * 00052 * Create a device container which is a concatenation of the two input 00053 * NetDeviceContainers. 00054 * 00055 * \note A frequently seen idiom that uses these constructors involves the 00056 * implicit conversion by constructor of Ptr<NetDevice>. When used, two 00057 * Ptr<NetDevice> will be passed to this constructor instead of NetDeviceContainer&. 00058 * C++ will notice the implicit conversion path that goes through the 00059 * NetDeviceContainer (Ptr<NetDevice> dev) constructor above. Using this conversion 00060 * one may provide optionally provide arguments of Ptr<NetDevice> to these 00061 * constructors. 00062 */ 00063 NetDeviceContainer (const NetDeviceContainer &a, const NetDeviceContainer &b); 00064 00065 /** 00066 * \returns an iterator which points to the start of the array of pointers. 00067 */ 00068 Iterator Begin (void) const; 00069 /** 00070 * \returns an iterator which points to the end of the array of pointers. 00071 */ 00072 Iterator End (void) const; 00073 00074 /** 00075 * \returns the number of netdevice pointers stored in this container. 00076 */ 00077 uint32_t GetN (void) const; 00078 /** 00079 * \param i the index of the requested netdevice pointer. 00080 * \returns the requested netdevice pointer. 00081 */ 00082 Ptr<NetDevice> Get (uint32_t i) const; 00083 00084 /** 00085 * \param other another netdevice container 00086 * 00087 * Append to the end of this container the other input container. 00088 */ 00089 void Add (NetDeviceContainer other); 00090 /** 00091 * \param device another netdevice pointer. 00092 * 00093 * Append to the end of this container the input netdevice pointer. 00094 */ 00095 void Add (Ptr<NetDevice> device); 00096 00097 private: 00098 std::vector<Ptr<NetDevice> > m_devices; 00099 }; 00100 00101 } // namespace ns3 00102 00103 #endif /* NET_DEVICE_CONTAINER_H */