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 NODE_CONTAINER_H 00021 #define NODE_CONTAINER_H 00022 00023 #include <stdint.h> 00024 #include <vector> 00025 #include "ns3/node.h" 00026 00027 namespace ns3 { 00028 00029 /** 00030 * \brief keep track of a set of node pointers. 00031 * 00032 */ 00033 class NodeContainer 00034 { 00035 public: 00036 typedef std::vector<Ptr<Node> >::const_iterator Iterator; 00037 00038 /** 00039 * Create an empty NodeContainer. 00040 */ 00041 NodeContainer (); 00042 /** 00043 * \param node a node to add to the container 00044 * 00045 * Create a NodeContainer with exactly one node. 00046 */ 00047 NodeContainer (Ptr<Node> node); 00048 /** 00049 * \param a a node container 00050 * \param b another node container 00051 * 00052 * Create a node container which is a concatenation of the two input 00053 * NodeContainers. 00054 * 00055 * \note A frequently seen idiom that uses these constructors involves the 00056 * implicit conversion by constructor of Ptr<Node>. When used, two 00057 * Ptr<Node> will be passed to this constructor instead of NodeContainer&. 00058 * C++ will notice the implicit conversion path that goes through the 00059 * NodeContainer (Ptr<Node> node) constructor above. Using this conversion 00060 * one may provide optionally provide arguments of Ptr<Node> to these 00061 * constructors. 00062 */ 00063 NodeContainer (const NodeContainer &a, const NodeContainer &b); 00064 00065 NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c); 00066 NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c, const NodeContainer &d); 00067 NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c, const NodeContainer &d, 00068 const NodeContainer &e); 00069 00070 /** 00071 * \returns an iterator to the start of the vector of node pointers. 00072 */ 00073 Iterator Begin (void) const; 00074 /** 00075 * \returns an iterator to the end of the vector of node pointers. 00076 */ 00077 Iterator End (void) const; 00078 00079 /** 00080 * \returns the number of node pointers stored in this NodeContainer. 00081 */ 00082 uint32_t GetN (void) const; 00083 /** 00084 * \param i the index of the requested node pointer. 00085 * \returns the requested node pointer. 00086 */ 00087 Ptr<Node> Get (uint32_t i) const; 00088 00089 /** 00090 * \param n the number of nodes to create 00091 * 00092 * Create n nodes and append pointers to them to the end of this NodeContainer. 00093 */ 00094 void Create (uint32_t n); 00095 /** 00096 * \param other another NodeContainer 00097 * 00098 * Append the node pointers from the input NodeContainer at the end 00099 * of this NodeContainer. 00100 */ 00101 void Add (NodeContainer other); 00102 /** 00103 * \param node a node pointer 00104 * 00105 * Append the input node pointer at the end of this NodeContainer. 00106 */ 00107 void Add (Ptr<Node> node); 00108 00109 /** 00110 * \returns a container which contains a list of _all_ nodes 00111 * created through NodeContainer::Create and stored 00112 * in ns3::NodeList. 00113 */ 00114 static NodeContainer GetGlobal (void); 00115 00116 private: 00117 std::vector<Ptr<Node> > m_nodes; 00118 }; 00119 00120 } // namespace ns3 00121 00122 #endif /* NODE_CONTAINER_H */