author | Gustavo J. A. M. Carneiro <gjc@inescporto.pt> |
Fri, 11 Jul 2008 18:39:19 +0100 | |
changeset 3416 | 926ccb845111 |
parent 2890 | 172baa5960ff |
child 3937 | 04f9377661b8 |
permissions | -rw-r--r-- |
2833
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
1 |
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
2 |
/* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
3 |
* Copyright (c) 2008 INRIA |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
4 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
5 |
* This program is free software; you can redistribute it and/or modify |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
6 |
* it under the terms of the GNU General Public License version 2 as |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
7 |
* published by the Free Software Foundation; |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
8 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
9 |
* This program is distributed in the hope that it will be useful, |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
12 |
* GNU General Public License for more details. |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
13 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
14 |
* You should have received a copy of the GNU General Public License |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
15 |
* along with this program; if not, write to the Free Software |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
16 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
17 |
* |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
18 |
* Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
f3474fd850b2
add missing license headers
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2756
diff
changeset
|
19 |
*/ |
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
20 |
#ifndef NODE_CONTAINER_H |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
21 |
#define NODE_CONTAINER_H |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
22 |
|
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
23 |
#include <stdint.h> |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
24 |
#include <vector> |
2603
1308da4cb3bf
move helpers to their own dir.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2516
diff
changeset
|
25 |
#include "ns3/node.h" |
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
26 |
|
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
27 |
namespace ns3 { |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
28 |
|
2697 | 29 |
/** |
30 |
* \brief keep track of a set of node pointers. |
|
31 |
* |
|
32 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
33 |
class NodeContainer |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
34 |
{ |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
35 |
public: |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
36 |
typedef std::vector<Ptr<Node> >::const_iterator Iterator; |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
37 |
|
2697 | 38 |
/** |
39 |
* Create an empty NodeContainer. |
|
40 |
*/ |
|
2516
d189f25169ee
add extra NodeContainer constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2417
diff
changeset
|
41 |
NodeContainer (); |
2697 | 42 |
/** |
43 |
* \param node a node to add to the container |
|
44 |
* |
|
45 |
* Create a NodeContainer with exactly one node. |
|
46 |
*/ |
|
2516
d189f25169ee
add extra NodeContainer constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2417
diff
changeset
|
47 |
NodeContainer (Ptr<Node> node); |
2697 | 48 |
/** |
49 |
* \param a a node container |
|
50 |
* \param b another node container |
|
51 |
* |
|
52 |
* Create a node container which is a concatenation of the two input |
|
53 |
* NodeContainers. |
|
2890
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
54 |
* |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
55 |
* \note A frequently seen idiom that uses these constructors involves the |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
56 |
* implicit conversion by constructor of Ptr<Node>. When used, two |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
57 |
* Ptr<Node> will be passed to this constructor instead of NodeContainer&. |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
58 |
* C++ will notice the implicit conversion path that goes through the |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
59 |
* NodeContainer (Ptr<Node> node) constructor above. Using this conversion |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
60 |
* one may provide optionally provide arguments of Ptr<Node> to these |
172baa5960ff
rework app constructors
Craig Dowell <craigdo@ee.washington.edu>
parents:
2834
diff
changeset
|
61 |
* constructors. |
2697 | 62 |
*/ |
2516
d189f25169ee
add extra NodeContainer constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2417
diff
changeset
|
63 |
NodeContainer (const NodeContainer &a, const NodeContainer &b); |
d189f25169ee
add extra NodeContainer constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2417
diff
changeset
|
64 |
|
2756
672f1203a4d1
add extra convenience constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2699
diff
changeset
|
65 |
NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c); |
672f1203a4d1
add extra convenience constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2699
diff
changeset
|
66 |
NodeContainer (const NodeContainer &a, const NodeContainer &b, const NodeContainer &c, const NodeContainer &d); |
672f1203a4d1
add extra convenience constructors
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2699
diff
changeset
|
67 |
|
2697 | 68 |
/** |
69 |
* \returns an iterator to the start of the vector of node pointers. |
|
70 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
71 |
Iterator Begin (void) const; |
2697 | 72 |
/** |
73 |
* \returns an iterator to the end of the vector of node pointers. |
|
74 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
75 |
Iterator End (void) const; |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
76 |
|
2697 | 77 |
/** |
78 |
* \returns the number of node pointers stored in this NodeContainer. |
|
79 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
80 |
uint32_t GetN (void) const; |
2697 | 81 |
/** |
82 |
* \param i the index of the requested node pointer. |
|
83 |
* \returns the requested node pointer. |
|
84 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
85 |
Ptr<Node> Get (uint32_t i) const; |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
86 |
|
2697 | 87 |
/** |
88 |
* \param n the number of nodes to create |
|
89 |
* |
|
90 |
* Create n nodes and append pointers to them to the end of this NodeContainer. |
|
91 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
92 |
void Create (uint32_t n); |
2697 | 93 |
/** |
94 |
* \param other another NodeContainer |
|
95 |
* |
|
96 |
* Append the node pointers from the input NodeContainer at the end |
|
97 |
* of this NodeContainer. |
|
98 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
99 |
void Add (NodeContainer other); |
2697 | 100 |
/** |
101 |
* \param node a node pointer |
|
102 |
* |
|
103 |
* Append the input node pointer at the end of this NodeContainer. |
|
104 |
*/ |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
105 |
void Add (Ptr<Node> node); |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
106 |
|
2699
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
107 |
/** |
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
108 |
* \returns a container which contains a list of _all_ nodes |
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
109 |
* created through NodeContainer::Create and stored |
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
110 |
* in ns3::NodeList. |
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
111 |
*/ |
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
112 |
static NodeContainer GetGlobal (void); |
cbc8b1ae341d
add NodeContainer::GetGlobal
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
2697
diff
changeset
|
113 |
|
2417
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
114 |
private: |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
115 |
std::vector<Ptr<Node> > m_nodes; |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
116 |
}; |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
117 |
|
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
118 |
} // namespace ns3 |
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
119 |
|
004ac83aca83
add device/node containers for helper API.
Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
parents:
diff
changeset
|
120 |
#endif /* NODE_CONTAINER_H */ |