A Discrete-Event Network Simulator
API
building-position-allocator.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (C) 2012 Centre Tecnologic de Telecomunicacions de Catalunya (CTTC)
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License version 2 as
7  * published by the Free Software Foundation;
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with this program; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17  *
18  * Author: Nicola Baldo <nbaldo@cttc.es>
19  * Michele Polese <michele.polese@gmail.com> for the OutdoorPositionAllocator class
20  */
21 #ifndef BUILDING_POSITION_ALLOCATOR_H
22 #define BUILDING_POSITION_ALLOCATOR_H
23 
24 #include <ns3/ptr.h>
25 #include <ns3/position-allocator.h>
26 #include <ns3/node-container.h>
27 #include "ns3/random-variable-stream.h"
28 
29 namespace ns3 {
30 
31 class Building;
32 class UniformRandomVariable;
33 
34 
41 {
42 public:
44 
45  // inherited from Object
46  static TypeId GetTypeId (void);
47 
48  // inherited from PositionAllocator
49  virtual Vector GetNext (void) const;
50 
59  int64_t AssignStreams (int64_t stream);
60 
61 private:
62 
64  mutable std::vector< Ptr<Building> > m_buildingListWithoutReplacement;
65 
68 };
69 
85 {
86 public:
88 
89  // inherited from Object
90  static TypeId GetTypeId (void);
91 
92  // inherited from PositionAllocator
93  virtual Vector GetNext (void) const;
94 
110 
119  int64_t AssignStreams (int64_t stream);
120 
121 private:
125 
126  uint32_t m_maxAttempts;
127 };
128 
136 {
137 public:
139 
140  // inherited from Object
141  static TypeId GetTypeId (void);
142 
143  // inherited from PositionAllocator
144  virtual Vector GetNext (void) const;
145 
154  int64_t AssignStreams (int64_t stream);
155 
156 private:
157 
158  struct RoomInfo
159  {
161  uint32_t roomx;
162  uint32_t roomy;
163  uint32_t floor;
164  };
165  mutable std::vector<RoomInfo> m_roomListWithoutReplacement;
166 
169 };
170 
171 
172 
179 {
180 public:
183 
184  // inherited from Object
185  static TypeId GetTypeId (void);
186 
187  // inherited from PositionAllocator
188  virtual Vector GetNext (void) const;
189 
198  int64_t AssignStreams (int64_t);
199 
200 private:
201 
204 
207 };
208 
214 {
215 public:
216 
226  FixedRoomPositionAllocator (uint32_t x,
227  uint32_t y,
228  uint32_t z,
229  Ptr<Building> b);
230  // inherited from Object
231  static TypeId GetTypeId (void);
232  // inherited from PositionAllocator
233  virtual Vector GetNext (void) const;
234 
243  int64_t AssignStreams (int64_t);
244 
245 private:
246 
247  uint32_t roomx;
248  uint32_t roomy;
249  uint32_t floor;
250 
252 
255 };
256 
257 
258 } // namespace ns3
259 
260 #endif /* BUILDING_POSITION_ALLOCATOR_H */
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
FixedRoomPositionAllocator(uint32_t x, uint32_t y, uint32_t z, Ptr< Building > b)
Ptr< RandomVariableStream > m_z
pointer to z&#39;s random variable stream
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
Walks a given NodeContainer sequentially, and for each node allocate a new position randomly in the s...
Ptr< RandomVariableStream > m_y
pointer to y&#39;s random variable stream
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions.
Generate a random position uniformly distributed in the volume of a chosen room inside a chosen build...
Allocate each position by randomly choosing a building from the list of all buildings, and then randomly choosing a position inside the building.
int64_t AssignStreams(int64_t)
Assign a fixed random variable stream number to the random variables used by this model...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
keep track of a set of node pointers.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
Ptr< RandomVariableStream > m_x
pointer to x&#39;s random variable stream
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
Allocate each position by randomly choosing a room from the list of all buildings, and then randomly choosing a position inside the room.
uint32_t m_maxAttempts
maximum number of attempts before giving up
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
std::vector< Ptr< Building > > m_buildingListWithoutReplacement
a unique identifier for an interface.
Definition: type-id.h:58
int64_t AssignStreams(int64_t)
Assign a fixed random variable stream number to the random variables used by this model...
Allocate a set of positions.
std::vector< RoomInfo > m_roomListWithoutReplacement