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 {
129  COLUMN_FIRST
130  };
131 
133 
137  void SetMinX (double xMin);
141  void SetMinY (double yMin);
145  void SetDeltaX (double deltaX);
149  void SetDeltaY (double deltaY);
154  void SetN (uint32_t n);
158  void SetLayoutType (enum LayoutType layoutType);
159 
163  double GetMinX (void) const;
167  double GetMinY (void) const;
171  double GetDeltaX (void) const;
175  double GetDeltaY (void) const;
179  uint32_t GetN (void) const;
183  enum LayoutType GetLayoutType (void) const;
184 
185 
186  virtual Vector GetNext (void) const;
187  virtual int64_t AssignStreams (int64_t stream);
188 private:
189  mutable uint32_t m_current;
190  enum LayoutType m_layoutType;
191  double m_xMin;
192  double m_yMin;
193  uint32_t m_n;
194  double m_deltaX;
195  double m_deltaY;
196 };
197 
203 {
204 public:
209  static TypeId GetTypeId (void);
212 
217  void SetX (Ptr<RandomVariableStream> x);
222  void SetY (Ptr<RandomVariableStream> y);
223 
224  virtual Vector GetNext (void) const;
225  virtual int64_t AssignStreams (int64_t stream);
226 private:
229 };
230 
236 {
237 public:
242  static TypeId GetTypeId (void);
244  virtual ~RandomBoxPositionAllocator ();
245 
250  void SetX (Ptr<RandomVariableStream> x);
255  void SetY (Ptr<RandomVariableStream> y);
260  void SetZ (Ptr<RandomVariableStream> z);
261 
262  virtual Vector GetNext (void) const;
263  virtual int64_t AssignStreams (int64_t stream);
264 private:
268 };
269 
276 {
277 public:
282  static TypeId GetTypeId (void);
284  virtual ~RandomDiscPositionAllocator ();
285 
290  void SetTheta (Ptr<RandomVariableStream> theta);
295  void SetRho (Ptr<RandomVariableStream> rho);
299  void SetX (double x);
303  void SetY (double y);
304 
305  virtual Vector GetNext (void) const;
306  virtual int64_t AssignStreams (int64_t stream);
307 private:
310  double m_x;
311  double m_y;
312 };
313 
314 
333 {
334 public:
339  static TypeId GetTypeId (void);
341  virtual ~UniformDiscPositionAllocator ();
342 
346  void SetRho (double rho);
347 
351  void SetX (double x);
352 
356  void SetY (double y);
357 
358  virtual Vector GetNext (void) const;
359  virtual int64_t AssignStreams (int64_t stream);
360 private:
362  double m_rho;
363  double m_x;
364  double m_y;
365 };
366 
367 } // namespace ns3
368 
369 #endif /* RANDOM_POSITION_H */
uint32_t m_current
currently position
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
Ptr< RandomVariableStream > m_theta
pointer to theta&#39;s random variable stream
uint32_t GetSize(Ptr< const Packet > packet, const WifiMacHeader *hdr, bool isAmpdu)
Return the total size of the packet after WifiMacHeader and FCS trailer have been added...
Definition: wifi-utils.cc:163
double m_y
y coordinate of center of disc
std::vector< Vector > m_positions
vector of positions
Ptr< RandomVariableStream > m_rho
pointer to rho&#39;s random variable stream
double m_deltaX
x interval between two consecutive x positions
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
double m_deltaY
y interval between two consecutive y positions
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&#39;s random variable stream
Allocate positions on a rectangular 2d grid.
double m_yMin
minimum boundary on y positions
Allocate positions from a deterministic list specified by the user.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
Allocate the positions uniformely (with constant density) randomly within a disc. ...
double m_y
y coordinate of center of disc
Allocate random positions within a rectangle according to a pair of random variables.
In row-first mode, positions are allocated on the first row until N positions have been allocated...
Allocate random positions within a 3D box according to a set of three random variables.
A base class which provides memory management and object aggregation.
Definition: object.h:87
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...
LayoutType
Determine whether positions are allocated row first or column first.
Ptr< RandomVariableStream > m_z
pointer to z&#39;s random variable stream
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...