OLD | NEW |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2008 INRIA | 3 * Copyright (c) 2008 INRIA |
4 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) | 4 * Copyright (c) 2011 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC) |
5 * | 5 * |
6 * This program is free software; you can redistribute it and/or modify | 6 * This program is free software; you can redistribute it and/or modify |
7 * it under the terms of the GNU General Public License version 2 as | 7 * it under the terms of the GNU General Public License version 2 as |
8 * published by the Free Software Foundation; | 8 * published by the Free Software Foundation; |
9 * | 9 * |
10 * This program is distributed in the hope that it will be useful, | 10 * This program is distributed in the hope that it will be useful, |
(...skipping 22 matching lines...) Expand all Loading... |
33 * | 33 * |
34 * Some ns-3 helpers operate on more than one building at a time. For example | 34 * Some ns-3 helpers operate on more than one building at a time. For example |
35 * a PositionAllocator may want to position nodes on a set of buildings. | 35 * a PositionAllocator may want to position nodes on a set of buildings. |
36 * The helper methods will then usually take a BuildingContainer as a | 36 * The helper methods will then usually take a BuildingContainer as a |
37 * parameter. BuildingContainers hold the multiple Ptr<Building> which are used | 37 * parameter. BuildingContainers hold the multiple Ptr<Building> which are used |
38 * to refer to the buildings. | 38 * to refer to the buildings. |
39 */ | 39 */ |
40 class BuildingContainer | 40 class BuildingContainer |
41 { | 41 { |
42 public: | 42 public: |
| 43 /// Building list Iterator typedef |
43 typedef std::vector<Ptr<Building> >::const_iterator Iterator; | 44 typedef std::vector<Ptr<Building> >::const_iterator Iterator; |
44 | 45 |
45 /** | 46 /** |
46 * Create an empty BuildingContainer. | 47 * Create an empty BuildingContainer. |
47 */ | 48 */ |
48 BuildingContainer (); | 49 BuildingContainer (); |
49 | 50 |
50 /** | 51 /** |
51 * Create a BuildingContainer with exactly one building which has been previou
sly | 52 * Create a BuildingContainer with exactly one building which has been previou
sly |
52 * instantiated. The single Building is specified by a smart pointer. | 53 * instantiated. The single Building is specified by a smart pointer. |
53 * | 54 * |
54 * \param building The Ptr<Building> to add to the container. | 55 * \param building The Ptr<Building> to add to the container. |
55 */ | 56 */ |
56 BuildingContainer (Ptr<Building> building); | 57 BuildingContainer (Ptr<Building> building); |
57 | 58 |
58 /** | 59 /** |
59 * Create a BuildingContainer with exactly one building which has been previou
sly | 60 * Create a BuildingContainer with exactly one building which has been previou
sly |
60 * instantiated and assigned a name using the Object Name Service. This | 61 * instantiated and assigned a name using the Object Name Service. This |
61 * Building is then specified by its assigned name. | 62 * Building is then specified by its assigned name. |
62 * | 63 * |
63 * \param buildingName The name of the Building Object to add to the container
. | 64 * \param buildingName The name of the Building Object to add to the container
. |
64 */ | 65 */ |
65 BuildingContainer (std::string buildingName); | 66 BuildingContainer (std::string buildingName); |
66 | 67 |
67 /** | 68 /** |
68 * \brief Get an iterator which refers to the first Building in the | 69 * \brief Get an iterator which refers to the first Building in the |
69 * container. | 70 * container. |
70 * | 71 * |
71 * Buildings can be retrieved from the container in two ways. First, | 72 * Buildings can be retrieved from the container in two ways. First, |
72 * directly by an index into the container, and second, using an iterator. | 73 * directly by an index into the container, and second, using an iterator. |
73 * This method is used in the iterator method and is typically used in a | 74 * This method is used in the iterator method and is typically used in a |
74 * for-loop to run through the Buildings | 75 * for-loop to run through the Buildings |
75 * | 76 * |
76 * \code | 77 * \code |
77 * BuildingContainer::Iterator i; | 78 * BuildingContainer::Iterator i; |
78 * for (i = container.Begin (); i != container.End (); ++i) | 79 * for (i = container.Begin (); i != container.End (); ++i) |
79 * { | 80 * { |
80 * (*i)->method (); // some Building method | 81 * (*i)->method (); // some Building method |
81 * } | 82 * } |
82 * \endcode | 83 * \endcode |
83 * | 84 * |
84 * \returns an iterator which refers to the first Building in the container. | 85 * \returns an iterator which refers to the first Building in the container. |
85 */ | 86 */ |
86 Iterator Begin (void) const; | 87 Iterator Begin (void) const; |
87 | 88 |
88 /** | 89 /** |
89 * \brief Get an iterator which indicates past-the-last Building in the | 90 * \brief Get an iterator which indicates past-the-last Building in the |
90 * container. | 91 * container. |
91 * | 92 * |
92 * Buildings can be retrieved from the container in two ways. First, | 93 * Buildings can be retrieved from the container in two ways. First, |
93 * directly by an index into the container, and second, using an iterator. | 94 * directly by an index into the container, and second, using an iterator. |
94 * This method is used in the iterator method and is typically used in a | 95 * This method is used in the iterator method and is typically used in a |
95 * for-loop to run through the Buildings | 96 * for-loop to run through the Buildings |
96 * | 97 * |
97 * \code | 98 * \code |
98 * BuildingContainer::Iterator i; | 99 * BuildingContainer::Iterator i; |
99 * for (i = container.Begin (); i != container.End (); ++i) | 100 * for (i = container.Begin (); i != container.End (); ++i) |
100 * { | 101 * { |
101 * (*i)->method (); // some Building method | 102 * (*i)->method (); // some Building method |
102 * } | 103 * } |
103 * \endcode | 104 * \endcode |
104 * | 105 * |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 * i->method (); // some Building method | 146 * i->method (); // some Building method |
146 * } | 147 * } |
147 * \endcode | 148 * \endcode |
148 * | 149 * |
149 * \param i the index of the requested building pointer. | 150 * \param i the index of the requested building pointer. |
150 * \returns the requested building pointer. | 151 * \returns the requested building pointer. |
151 */ | 152 */ |
152 Ptr<Building> Get (uint32_t i) const; | 153 Ptr<Building> Get (uint32_t i) const; |
153 | 154 |
154 /** | 155 /** |
155 * \brief Create n buildings and append pointers to them to the end of this | 156 * \brief Create n buildings and append pointers to them to the end of this |
156 * BuildingContainer. | 157 * BuildingContainer. |
157 * | 158 * |
158 * Buildings are at the heart of any ns-3 simulation. One of the first tasks
that | 159 * Buildings are at the heart of any ns-3 simulation. One of the first tasks
that |
159 * any simulation needs to do is to create a number of buildings. This method | 160 * any simulation needs to do is to create a number of buildings. This method |
160 * automates that task. | 161 * automates that task. |
161 * | 162 * |
162 * \param n The number of Buildings to create | 163 * \param n The number of Buildings to create |
163 */ | 164 */ |
164 void Create (uint32_t n); | 165 void Create (uint32_t n); |
165 | 166 |
(...skipping 19 matching lines...) Expand all Loading... |
185 * \param buildingName The name of the Building Object to add to the container
. | 186 * \param buildingName The name of the Building Object to add to the container
. |
186 */ | 187 */ |
187 void Add (std::string buildingName); | 188 void Add (std::string buildingName); |
188 | 189 |
189 /** | 190 /** |
190 * \brief Create a BuildingContainer that contains a list of _all_ buildings | 191 * \brief Create a BuildingContainer that contains a list of _all_ buildings |
191 * stored in the ns3::BuildingList. | 192 * stored in the ns3::BuildingList. |
192 * | 193 * |
193 * Whenever a Building is created, a Ptr<Building> is added to a global list o
f all | 194 * Whenever a Building is created, a Ptr<Building> is added to a global list o
f all |
194 * buildings in the system. It is sometimes useful to be able to get to all | 195 * buildings in the system. It is sometimes useful to be able to get to all |
195 * buildings in one place. This method creates a BuildingContainer that is | 196 * buildings in one place. This method creates a BuildingContainer that is |
196 * initialized to contain all of the simulation buildings, | 197 * initialized to contain all of the simulation buildings, |
197 * | 198 * |
198 * \returns a BuildingContainer which contains a list of all Buildings. | 199 * \returns a BuildingContainer which contains a list of all Buildings. |
199 */ | 200 */ |
200 static BuildingContainer GetGlobal (void); | 201 static BuildingContainer GetGlobal (void); |
201 | 202 |
202 private: | 203 private: |
203 std::vector<Ptr<Building> > m_buildings; | 204 std::vector<Ptr<Building> > m_buildings; ///< collection of buildings |
204 }; | 205 }; |
205 | 206 |
206 } // namespace ns3 | 207 } // namespace ns3 |
207 | 208 |
208 #endif /* BUILDING_CONTAINER_H */ | 209 #endif /* BUILDING_CONTAINER_H */ |
OLD | NEW |