A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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:
38  static TypeId GetTypeId (void);
40  virtual ~PositionAllocator ();
46  virtual Vector GetNext (void) const = 0;
57  virtual int64_t AssignStreams (int64_t stream) = 0;
58 };
59 
68 {
69 public:
70  static TypeId GetTypeId (void);
72 
76  void Add (Vector v);
77  virtual Vector GetNext (void) const;
78  virtual int64_t AssignStreams (int64_t stream);
79 private:
80  std::vector<Vector> m_positions;
81  mutable std::vector<Vector>::const_iterator m_current;
82 };
83 
89 {
90 public:
91  static TypeId GetTypeId (void);
92 
96  enum LayoutType {
109  };
110 
112 
116  void SetMinX (double xMin);
120  void SetMinY (double yMin);
124  void SetDeltaX (double deltaX);
128  void SetDeltaY (double deltaY);
133  void SetN (uint32_t n);
137  void SetLayoutType (enum LayoutType layoutType);
138 
142  double GetMinX (void) const;
146  double GetMinY (void) const;
150  double GetDeltaX (void) const;
154  double GetDeltaY (void) const;
158  uint32_t GetN (void) const;
162  enum LayoutType GetLayoutType (void) const;
163 
164 
165  virtual Vector GetNext (void) const;
166  virtual int64_t AssignStreams (int64_t stream);
167 private:
168  mutable uint32_t m_current;
170  double m_xMin;
171  double m_yMin;
172  uint32_t m_n;
173  double m_deltaX;
174  double m_deltaY;
175 };
176 
182 {
183 public:
184  static TypeId GetTypeId (void);
187 
190 
191  virtual Vector GetNext (void) const;
192  virtual int64_t AssignStreams (int64_t stream);
193 private:
196 };
197 
203 {
204 public:
205  static TypeId GetTypeId (void);
207  virtual ~RandomBoxPositionAllocator ();
208 
212 
213  virtual Vector GetNext (void) const;
214  virtual int64_t AssignStreams (int64_t stream);
215 private:
219 };
220 
227 {
228 public:
229  static TypeId GetTypeId (void);
231  virtual ~RandomDiscPositionAllocator ();
232 
233  void SetTheta (Ptr<RandomVariableStream> theta);
235  void SetX (double x);
236  void SetY (double y);
237 
238  virtual Vector GetNext (void) const;
239  virtual int64_t AssignStreams (int64_t stream);
240 private:
243  double m_x;
244  double m_y;
245 };
246 
247 
266 {
267 public:
268  static TypeId GetTypeId (void);
271 
275  void SetRho (double rho);
276 
280  void SetX (double x);
281 
285  void SetY (double y);
286 
287  virtual Vector GetNext (void) const;
288  virtual int64_t AssignStreams (int64_t stream);
289 private:
291  double m_rho;
292  double m_x;
293  double m_y;
294 };
295 
296 } // namespace ns3
297 
298 #endif /* RANDOM_POSITION_H */
In column-first mode, positions are allocated on the first column until N positions have been allocat...
Ptr< RandomVariableStream > m_y
virtual Vector GetNext(void) const =0
Ptr< RandomVariableStream > m_theta
void SetZ(Ptr< RandomVariableStream > z)
enum LayoutType GetLayoutType(void) const
virtual Vector GetNext(void) const
std::vector< Vector > m_positions
Ptr< RandomVariableStream > m_rho
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)
std::vector< Vector >::const_iterator m_current
Ptr< UniformRandomVariable > m_rv
void SetRho(Ptr< RandomVariableStream > rho)
virtual Vector GetNext(void) const
a 3d vector
Definition: vector.h:31
virtual Vector GetNext(void) const
static TypeId GetTypeId(void)
void SetY(Ptr< RandomVariableStream > y)
Allocate positions on a rectangular 2d grid.
void SetTheta(Ptr< RandomVariableStream > theta)
Allocate positions from a deterministic list specified by the user.
void SetY(Ptr< RandomVariableStream > y)
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
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. ...
static TypeId GetTypeId(void)
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...
void SetLayoutType(enum LayoutType layoutType)
virtual Vector GetNext(void) const
uint32_t GetN(void) const
void SetX(Ptr< RandomVariableStream > x)
void SetX(Ptr< RandomVariableStream > x)
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:64
a unique identifier for an interface.
Definition: type-id.h:49
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
Ptr< RandomVariableStream > m_x
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...