A Discrete-Event Network Simulator
API
Loading...
Searching...
No Matches
position-allocator.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2007 INRIA
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation;
7 *
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
12 *
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 *
17 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr>
18 */
19#ifndef POSITION_ALLOCATOR_H
20#define POSITION_ALLOCATOR_H
21
22#include "ns3/object.h"
23#include "ns3/random-variable-stream.h"
24#include "ns3/vector.h"
25
26namespace ns3
27{
28
36{
37 public:
42 static TypeId GetTypeId();
44 ~PositionAllocator() override;
50 virtual Vector GetNext() const = 0;
61 virtual int64_t AssignStreams(int64_t stream) = 0;
62};
63
72{
73 public:
78 static TypeId GetTypeId();
80
85 void Add(Vector v);
86
101 void Add(const std::string filePath, double defaultZ = 0, char delimiter = ',');
102
110 uint32_t GetSize() const;
111 Vector GetNext() const override;
112 int64_t AssignStreams(int64_t stream) override;
113
114 private:
115 std::vector<Vector> m_positions;
116 mutable std::vector<Vector>::const_iterator m_current;
117};
118
124{
125 public:
130 static TypeId GetTypeId();
131
136 {
149 };
150
152
156 void SetMinX(double xMin);
160 void SetMinY(double yMin);
164 void SetZ(double z);
168 void SetDeltaX(double deltaX);
172 void SetDeltaY(double deltaY);
177 void SetN(uint32_t n);
181 void SetLayoutType(LayoutType layoutType);
182
186 double GetMinX() const;
190 double GetMinY() const;
194 double GetDeltaX() const;
198 double GetDeltaY() const;
202 uint32_t GetN() const;
207
208 Vector GetNext() const override;
209 int64_t AssignStreams(int64_t stream) override;
210
211 private:
214 double m_xMin;
215 double m_yMin;
216 double m_z;
218 double m_deltaX;
219 double m_deltaY;
220};
221
227{
228 public:
233 static TypeId GetTypeId();
236
250 void SetZ(double z);
251
252 Vector GetNext() const override;
253 int64_t AssignStreams(int64_t stream) override;
254
255 private:
258 double m_z;
259};
260
266{
267 public:
272 static TypeId GetTypeId();
275
291
292 Vector GetNext() const override;
293 int64_t AssignStreams(int64_t stream) override;
294
295 private:
299};
300
315{
316 public:
321 static TypeId GetTypeId();
324
340 void SetX(double x);
344 void SetY(double y);
348 void SetZ(double z);
349
350 Vector GetNext() const override;
351 int64_t AssignStreams(int64_t stream) override;
352
353 private:
356 double m_x;
357 double m_y;
358 double m_z;
359};
360
377{
378 public:
383 static TypeId GetTypeId();
386
390 void SetRho(double rho);
391
395 void SetX(double x);
396
400 void SetY(double y);
401
405 void SetZ(double z);
406
407 Vector GetNext() const override;
408 int64_t AssignStreams(int64_t stream) override;
409
410 private:
412 double m_rho;
413 double m_x;
414 double m_y;
415 double m_z;
416};
417
418} // namespace ns3
419
420#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 GetLayoutType() const
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.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
uint32_t m_current
currently position
double m_yMin
minimum boundary on y positions
Vector GetNext() const override
double m_z
z coordinate of all the positions generated
LayoutType m_layoutType
currently selected layout type
double m_xMin
minimum boundary on x positions
uint32_t m_n
number of positions to allocate on each row or column
static TypeId GetTypeId()
Register this type with the TypeId system.
void SetLayoutType(LayoutType layoutType)
Allocate positions from a deterministic list specified by the user.
int64_t AssignStreams(int64_t stream) override
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.
uint32_t GetSize() const
Return the number of positions stored.
static TypeId GetTypeId()
Register this type with the TypeId system.
std::vector< Vector >::const_iterator m_current
vector iterator
Vector GetNext() const override
std::vector< Vector > m_positions
vector of positions
A base class which provides memory management and object aggregation.
Definition: object.h:89
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.
static TypeId GetTypeId()
Register this type with the TypeId system.
virtual Vector GetNext() const =0
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:78
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.
Ptr< RandomVariableStream > m_x
pointer to x's random variable stream
Ptr< RandomVariableStream > m_y
pointer to y's random variable stream
void SetX(Ptr< RandomVariableStream > x)
Set the random variable stream object that generates x-positions.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
void SetY(Ptr< RandomVariableStream > y)
Set the random variable stream object that generates y-positions.
static TypeId GetTypeId()
Register this type with the TypeId system.
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
static TypeId GetTypeId()
Register this type with the TypeId system.
void SetRho(Ptr< RandomVariableStream > rho)
Set the random variable that generates position radius, in meters.
double m_x
x coordinate of center of disc
void SetTheta(Ptr< RandomVariableStream > theta)
Set the random variable that generates position angle, in radians.
int64_t AssignStreams(int64_t stream) override
Assign a fixed random variable stream number to the random variables used by this model.
Ptr< RandomVariableStream > m_theta
pointer to theta's random variable stream
double m_z
z coordinate of the disc
Allocate random positions within a rectangle according to a pair of random variables.
int64_t AssignStreams(int64_t stream) override
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.
static TypeId GetTypeId()
Register this type with the TypeId system.
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.
static TypeId GetTypeId()
Register this type with the TypeId system.
int64_t AssignStreams(int64_t stream) override
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
Every class exported by the ns3 library is enclosed in the ns3 namespace.