A Discrete-Event Network Simulator
API
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) 2007 INRIA
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: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
19  */
20 #ifndef POSITION_ALLOCATOR_H
21 #define POSITION_ALLOCATOR_H
22 
23 #include "ns3/object.h"
24 #include "ns3/random-variable-stream.h"
25 #include "ns3/vector.h"
26 
27 namespace ns3 {
28 
35 class PositionAllocator : public Object
36 {
37 public:
42  static TypeId GetTypeId (void);
44  virtual ~PositionAllocator ();
50  virtual Vector GetNext (void) const = 0;
61  virtual int64_t AssignStreams (int64_t stream) = 0;
62 };
63 
72 {
73 public:
78  static TypeId GetTypeId (void);
80 
85  void Add (Vector v);
86 
101  void Add (const std::string filePath,
102  double defaultZ = 0,
103  char delimiter = ',');
104 
112  uint32_t GetSize (void) const;
113  virtual Vector GetNext (void) const;
114  virtual int64_t AssignStreams (int64_t stream);
115 
116 private:
117  std::vector<Vector> m_positions;
118  mutable std::vector<Vector>::const_iterator m_current;
119 };
120 
126 {
127 public:
132  static TypeId GetTypeId (void);
133 
138  {
151  };
152 
154 
158  void SetMinX (double xMin);
162  void SetMinY (double yMin);
166  void SetZ (double z);
170  void SetDeltaX (double deltaX);
174  void SetDeltaY (double deltaY);
179  void SetN (uint32_t n);
183  void SetLayoutType (enum LayoutType layoutType);
184 
188  double GetMinX (void) const;
192  double GetMinY (void) const;
196  double GetDeltaX (void) const;
200  double GetDeltaY (void) const;
204  uint32_t GetN (void) const;
208  enum LayoutType GetLayoutType (void) const;
209 
210 
211  virtual Vector GetNext (void) const;
212  virtual int64_t AssignStreams (int64_t stream);
213 
214 private:
215  mutable uint32_t m_current;
216  enum LayoutType m_layoutType;
217  double m_xMin;
218  double m_yMin;
219  double m_z;
220  uint32_t m_n;
221  double m_deltaX;
222  double m_deltaY;
223 };
224 
230 {
231 public:
236  static TypeId GetTypeId (void);
239 
253  void SetZ (double z);
254 
255  virtual Vector GetNext (void) const;
256  virtual int64_t AssignStreams (int64_t stream);
257 
258 private:
261  double m_z;
262 };
263 
269 {
270 public:
275  static TypeId GetTypeId (void);
277  virtual ~RandomBoxPositionAllocator ();
278 
294 
295  virtual Vector GetNext (void) const;
296  virtual int64_t AssignStreams (int64_t stream);
297 
298 private:
302 };
303 
318 {
319 public:
324  static TypeId GetTypeId (void);
326  virtual ~RandomDiscPositionAllocator ();
327 
332  void SetTheta (Ptr<RandomVariableStream> theta);
341  void SetX (double x);
345  void SetY (double y);
349  void SetZ (double z);
350 
351  virtual Vector GetNext (void) const;
352  virtual int64_t AssignStreams (int64_t stream);
353 
354 private:
357  double m_x;
358  double m_y;
359  double m_z;
360 };
361 
362 
381 {
382 public:
387  static TypeId GetTypeId (void);
390 
394  void SetRho (double rho);
395 
399  void SetX (double x);
400 
404  void SetY (double y);
405 
409  void SetZ (double z);
410 
411  virtual Vector GetNext (void) const;
412  virtual int64_t AssignStreams (int64_t stream);
413 
414 private:
416  double m_rho;
417  double m_x;
418  double m_y;
419  double m_z;
420 };
421 
422 } // namespace ns3
423 
424 #endif /* RANDOM_POSITION_H */
Allocate positions on a rectangular 2d grid.
double m_deltaX
x interval between two consecutive x positions
double m_deltaY
y interval between two consecutive y positions
LayoutType
Determine whether positions are allocated row first or column first.
@ COLUMN_FIRST
In column-first mode, positions are allocated on the first column until N positions have been allocat...
@ ROW_FIRST
In row-first mode, positions are allocated on the first row until N positions have been allocated.
virtual Vector GetNext(void) const
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t m_current
currently position
enum LayoutType m_layoutType
currently selected layout type
double m_yMin
minimum boundary on y positions
double m_z
z coordinate of all the positions generated
void SetLayoutType(enum LayoutType layoutType)
static TypeId GetTypeId(void)
Register this type with the TypeId system.
double m_xMin
minimum boundary on x positions
uint32_t m_n
number of positions to allocate on each row or column
enum LayoutType GetLayoutType(void) const
Allocate positions from a deterministic list specified by the user.
void Add(Vector v)
Add a position to the list of positions.
std::vector< Vector >::const_iterator m_current
vector iterator
std::vector< Vector > m_positions
vector of positions
static TypeId GetTypeId(void)
Register this type with the TypeId system.
uint32_t GetSize(void) const
Return the number of positions stored.
virtual Vector GetNext(void) const
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
A base class which provides memory management and object aggregation.
Definition: object.h:88
Allocate a set of positions.
virtual int64_t AssignStreams(int64_t stream)=0
Assign a fixed random variable stream number to the random variables used by this model.
virtual Vector GetNext(void) const =0
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Allocate random positions within a 3D box according to a set of three random variables.
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
virtual Vector GetNext(void) const
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
Ptr< RandomVariableStream > m_z
pointer to z's random variable stream
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
double m_y
y coordinate of center of disc
Ptr< RandomVariableStream > m_rho
pointer to rho's random variable stream
void SetRho(Ptr< RandomVariableStream > rho)
Set the random variable that generates position radius, in meters.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
double m_x
x coordinate of center of disc
void SetTheta(Ptr< RandomVariableStream > theta)
Set the random variable that generates position angle, in radians.
virtual Vector GetNext(void) const
Ptr< RandomVariableStream > m_theta
pointer to theta's random variable stream
double m_z
z coordinate of the disc
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Allocate random positions within a rectangle according to a pair of random variables.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
double m_z
z coordinate of all the positions generated
a unique identifier for an interface.
Definition: type-id.h:59
Allocate the positions uniformly (with constant density) randomly within a disc.
virtual Vector GetNext(void) const
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model.
double m_rho
value of the radius of the disc
double m_x
x coordinate of center of disc
double m_y
y coordinate of center of disc
Ptr< UniformRandomVariable > m_rv
pointer to uniform random variable
double m_z
z coordinate of the disc
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
list x
Random number samples.