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);
93  uint32_t GetSize (void) const;
94  virtual Vector GetNext (void) const;
95  virtual int64_t AssignStreams (int64_t stream);
96 private:
97  std::vector<Vector> m_positions;
98  mutable std::vector<Vector>::const_iterator m_current;
99 };
100 
106 {
107 public:
112  static TypeId GetTypeId (void);
113 
117  enum LayoutType {
130  };
131 
133 
137  void SetMinX (double xMin);
141  void SetMinY (double yMin);
145  void SetZ (double z);
149  void SetDeltaX (double deltaX);
153  void SetDeltaY (double deltaY);
158  void SetN (uint32_t n);
162  void SetLayoutType (enum LayoutType layoutType);
163 
167  double GetMinX (void) const;
171  double GetMinY (void) const;
175  double GetDeltaX (void) const;
179  double GetDeltaY (void) const;
183  uint32_t GetN (void) const;
187  enum LayoutType GetLayoutType (void) const;
188 
189 
190  virtual Vector GetNext (void) const;
191  virtual int64_t AssignStreams (int64_t stream);
192 private:
193  mutable uint32_t m_current;
195  double m_xMin;
196  double m_yMin;
197  double m_z;
198  uint32_t m_n;
199  double m_deltaX;
200  double m_deltaY;
201 };
202 
208 {
209 public:
214  static TypeId GetTypeId (void);
217 
231  void SetZ (double z);
232 
233  virtual Vector GetNext (void) const;
234  virtual int64_t AssignStreams (int64_t stream);
235 private:
238  double m_z;
239 };
240 
246 {
247 public:
252  static TypeId GetTypeId (void);
254  virtual ~RandomBoxPositionAllocator ();
255 
271 
272  virtual Vector GetNext (void) const;
273  virtual int64_t AssignStreams (int64_t stream);
274 private:
278 };
279 
286 {
287 public:
292  static TypeId GetTypeId (void);
294  virtual ~RandomDiscPositionAllocator ();
295 
300  void SetTheta (Ptr<RandomVariableStream> theta);
309  void SetX (double x);
313  void SetY (double y);
317  void SetZ (double z);
318 
319  virtual Vector GetNext (void) const;
320  virtual int64_t AssignStreams (int64_t stream);
321 private:
324  double m_x;
325  double m_y;
326  double m_z;
327 };
328 
329 
348 {
349 public:
354  static TypeId GetTypeId (void);
357 
361  void SetRho (double rho);
362 
366  void SetX (double x);
367 
371  void SetY (double y);
372 
376  void SetZ (double z);
377 
378  virtual Vector GetNext (void) const;
379  virtual int64_t AssignStreams (int64_t stream);
380 private:
382  double m_rho;
383  double m_x;
384  double m_y;
385  double m_z;
386 };
387 
388 } // namespace ns3
389 
390 #endif /* RANDOM_POSITION_H */
uint32_t m_current
currently position
In column-first mode, positions are allocated on the first column until N positions have been allocat...
enum LayoutType GetLayoutType(void) const
Ptr< RandomVariableStream > m_y
pointer to y&#39;s random variable stream
Ptr< RandomVariableStream > m_y
pointer to y&#39;s random variable stream
virtual Vector GetNext(void) const =0
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Ptr< RandomVariableStream > m_theta
pointer to theta&#39;s random variable stream
void SetZ(Ptr< RandomVariableStream > z)
Set the random variable stream object that generates z-positions.
double m_y
y coordinate of center of disc
double m_z
z coordinate of the disc
std::vector< Vector > m_positions
vector of positions
Ptr< RandomVariableStream > m_rho
pointer to rho&#39;s random variable stream
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...
double m_deltaX
x interval between two consecutive x positions
static TypeId GetTypeId(void)
Register this type with the TypeId system.
double m_rho
value of the radius of the disc
std::vector< Vector >::const_iterator m_current
vector iterator
Ptr< UniformRandomVariable > m_rv
pointer to uniform random variable
void SetRho(Ptr< RandomVariableStream > rho)
Set the random variable that generates position angle.
double m_deltaY
y interval between two consecutive y positions
double m_xMin
minimum boundary on x positions
virtual Vector GetNext(void) const
static TypeId GetTypeId(void)
Register this type with the TypeId system.
uint32_t GetSize(void) const
Return the number of positions stored.
double m_x
x coordinate of center of disc
uint32_t m_n
number of positions to allocate on each row or column
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.
virtual Vector GetNext(void) const
Allocate positions on a rectangular 2d grid.
double m_yMin
minimum boundary on y positions
void SetTheta(Ptr< RandomVariableStream > theta)
Set the random variable that generates position radius.
Allocate positions from a deterministic list specified by the user.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
double m_z
z coordinate of all the positions generated
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
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...
Allocate the positions uniformely (with constant density) randomly within a disc. ...
enum LayoutType m_layoutType
currently selected layout type
static TypeId GetTypeId(void)
Register this type with the TypeId system.
double m_y
y coordinate of center of disc
Allocate random positions within a rectangle according to a pair of random variables.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
In row-first mode, positions are allocated on the first row until N positions have been allocated...
virtual Vector GetNext(void) const
void Add(Vector v)
Add a position to the list of positions.
virtual Vector GetNext(void) const
void SetLayoutType(enum LayoutType layoutType)
double m_z
z coordinate of the disc
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
Allocate random positions within a 3D box according to a set of three random variables.
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:87
double m_x
x coordinate of center of disc
double m_z
z coordinate of all the positions generated
a unique identifier for an interface.
Definition: type-id.h:58
virtual Vector GetNext(void) const
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
LayoutType
Determine whether positions are allocated row first or column first.
Ptr< RandomVariableStream > m_z
pointer to z&#39;s random variable stream
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Ptr< RandomVariableStream > m_x
pointer to x&#39;s random variable stream
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...