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  virtual Vector GetNext (void) const;
87  virtual int64_t AssignStreams (int64_t stream);
88 private:
89  std::vector<Vector> m_positions;
90  mutable std::vector<Vector>::const_iterator m_current;
91 };
92 
98 {
99 public:
104  static TypeId GetTypeId (void);
105 
109  enum LayoutType {
122  };
123 
125 
129  void SetMinX (double xMin);
133  void SetMinY (double yMin);
137  void SetDeltaX (double deltaX);
141  void SetDeltaY (double deltaY);
146  void SetN (uint32_t n);
150  void SetLayoutType (enum LayoutType layoutType);
151 
155  double GetMinX (void) const;
159  double GetMinY (void) const;
163  double GetDeltaX (void) const;
167  double GetDeltaY (void) const;
171  uint32_t GetN (void) const;
175  enum LayoutType GetLayoutType (void) const;
176 
177 
178  virtual Vector GetNext (void) const;
179  virtual int64_t AssignStreams (int64_t stream);
180 private:
181  mutable uint32_t m_current;
183  double m_xMin;
184  double m_yMin;
185  uint32_t m_n;
186  double m_deltaX;
187  double m_deltaY;
188 };
189 
195 {
196 public:
201  static TypeId GetTypeId (void);
204 
215 
216  virtual Vector GetNext (void) const;
217  virtual int64_t AssignStreams (int64_t stream);
218 private:
221 };
222 
228 {
229 public:
234  static TypeId GetTypeId (void);
236  virtual ~RandomBoxPositionAllocator ();
237 
253 
254  virtual Vector GetNext (void) const;
255  virtual int64_t AssignStreams (int64_t stream);
256 private:
260 };
261 
268 {
269 public:
274  static TypeId GetTypeId (void);
276  virtual ~RandomDiscPositionAllocator ();
277 
282  void SetTheta (Ptr<RandomVariableStream> theta);
291  void SetX (double x);
295  void SetY (double y);
296 
297  virtual Vector GetNext (void) const;
298  virtual int64_t AssignStreams (int64_t stream);
299 private:
302  double m_x;
303  double m_y;
304 };
305 
306 
325 {
326 public:
331  static TypeId GetTypeId (void);
334 
338  void SetRho (double rho);
339 
343  void SetX (double x);
344 
348  void SetY (double y);
349 
350  virtual Vector GetNext (void) const;
351  virtual int64_t AssignStreams (int64_t stream);
352 private:
354  double m_rho;
355  double m_x;
356  double m_y;
357 };
358 
359 } // namespace ns3
360 
361 #endif /* RANDOM_POSITION_H */
uint32_t m_current
currently position
LayoutType
Determine whether positions are allocated row first or column first.
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
Ptr< RandomVariableStream > m_y
pointer to y'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'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
enum LayoutType GetLayoutType(void) const
virtual Vector GetNext(void) const
std::vector< Vector > m_positions
vector of positions
Ptr< RandomVariableStream > m_rho
pointer to rho'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.
virtual Vector GetNext(void) const
In row-first mode, positions are allocated on the first row until N positions have been allocated...
double m_deltaY
y interval between two consecutive y positions
virtual Vector GetNext(void) const
double m_xMin
minimum boundary on x positions
static TypeId GetTypeId(void)
Register this type with the TypeId system.
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's random variable stream
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
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.
virtual int64_t AssignStreams(int64_t stream)
Assign a fixed random variable stream number to the random variables used by this model...
virtual Vector GetNext(void) const
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...
void Add(Vector v)
Add a position to the list of positions.
void SetLayoutType(enum LayoutType layoutType)
virtual Vector GetNext(void) const
uint32_t GetN(void) const
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
In column-first mode, positions are allocated on the first column until N positions have been allocat...
double m_x
x coordinate of center of disc
a unique identifier for an interface.
Definition: type-id.h:58
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...
Ptr< RandomVariableStream > m_z
pointer to z's random variable stream
static TypeId GetTypeId(void)
Register this type with the TypeId system.
Ptr< RandomVariableStream > m_x
pointer to x'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...