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 
40 {
41 public:
43 
48  static TypeId GetTypeId (void);
49 
50  // inherited from PositionAllocator
51  virtual Vector GetNext (void) const;
52 
61  int64_t AssignStreams (int64_t stream);
62 
63 private:
64 
66  mutable std::vector< Ptr<Building> > m_buildingListWithoutReplacement;
67 
70 };
71 
87 {
88 public:
90 
95  static TypeId GetTypeId (void);
96 
97  // inherited from PositionAllocator
98  virtual Vector GetNext (void) const;
99 
115 
124  int64_t AssignStreams (int64_t stream);
125 
126 private:
130 
131  uint32_t m_maxAttempts;
132 };
133 
141 {
142 public:
144 
149  static TypeId GetTypeId (void);
150 
151  // inherited from PositionAllocator
152  virtual Vector GetNext (void) const;
153 
162  int64_t AssignStreams (int64_t stream);
163 
164 private:
165 
169  struct RoomInfo
170  {
172  uint32_t roomx;
173  uint32_t roomy;
174  uint32_t floor;
175  };
176  mutable std::vector<RoomInfo> m_roomListWithoutReplacement;
177 
180 };
181 
182 
183 
190 {
191 public:
193 
199 
204  static TypeId GetTypeId (void);
205 
206  // inherited from PositionAllocator
207  virtual Vector GetNext (void) const;
208 
217  int64_t AssignStreams (int64_t);
218 
219 private:
220 
223 
226 };
227 
233 {
234 public:
235 
245  FixedRoomPositionAllocator (uint32_t x,
246  uint32_t y,
247  uint32_t z,
248  Ptr<Building> b);
253  static TypeId GetTypeId (void);
254  // inherited from PositionAllocator
255  virtual Vector GetNext (void) const;
256 
265  int64_t AssignStreams (int64_t);
266 
267 private:
268 
269  uint32_t roomx;
270  uint32_t roomy;
271  uint32_t floor;
272 
274 
277 };
278 
279 
280 } // namespace ns3
281 
282 #endif /* BUILDING_POSITION_ALLOCATOR_H */
Generate a random position uniformly distributed in the volume of a chosen room inside a chosen build...
uint32_t floor
Index of the room on the z-axis (i.e., floor number)
uint32_t roomx
Index of the room on the x-axis.
uint32_t roomy
Index of the room on the y-axis.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
Ptr< Building > bptr
Pointer to the chosen building.
FixedRoomPositionAllocator(uint32_t x, uint32_t y, uint32_t z, Ptr< Building > b)
int64_t AssignStreams(int64_t)
Assign a fixed random variable stream number to the random variables used by this model.
static TypeId GetTypeId(void)
Get the type ID.
keep track of a set of node pointers.
std::vector< Ptr< Node > >::const_iterator Iterator
Node container iterator.
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
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.
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
Ptr< RandomVariableStream > m_z
pointer to z's random variable stream
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions.
static TypeId GetTypeId(void)
Get the type ID.
Allocate a set of positions.
Allocate each position by randomly choosing a building from the list of all buildings,...
static TypeId GetTypeId(void)
Get the type ID.
bool m_withReplacement
If true, the building will be randomly selected with replacement.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
std::vector< Ptr< Building > > m_buildingListWithoutReplacement
List of building without replacement.
Allocate each position by randomly choosing a room from the list of all buildings,...
int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
std::vector< RoomInfo > m_roomListWithoutReplacement
Container of rooms.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
static TypeId GetTypeId(void)
Get the type ID.
Walks a given NodeContainer sequentially, and for each node allocate a new position randomly in the s...
int64_t AssignStreams(int64_t)
Assign a fixed random variable stream number to the random variables used by this model.
NodeContainer m_nodes
Nodes container.
Ptr< UniformRandomVariable > m_rand
Provides uniform random variables.
NodeContainer::Iterator m_nodeIt
Nodes iterator.
static TypeId GetTypeId(void)
Get the type ID.
a unique identifier for an interface.
Definition: type-id.h:59
Every class exported by the ns3 library is enclosed in the ns3 namespace.
list x
Random number samples.