A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
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
);
39
PositionAllocator
();
40
virtual
~PositionAllocator
();
46
virtual
Vector
GetNext
(
void
)
const
= 0;
57
virtual
int64_t
AssignStreams
(int64_t stream) = 0;
58
};
59
67
class
ListPositionAllocator
:
public
PositionAllocator
68
{
69
public
:
70
static
TypeId
GetTypeId
(
void
);
71
ListPositionAllocator
();
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
88
class
GridPositionAllocator
:
public
PositionAllocator
89
{
90
public
:
91
static
TypeId
GetTypeId
(
void
);
92
96
enum
LayoutType
{
102
ROW_FIRST
,
108
COLUMN_FIRST
109
};
110
111
GridPositionAllocator
();
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
;
169
enum
LayoutType
m_layoutType
;
170
double
m_xMin
;
171
double
m_yMin
;
172
uint32_t
m_n
;
173
double
m_deltaX
;
174
double
m_deltaY
;
175
};
176
181
class
RandomRectanglePositionAllocator
:
public
PositionAllocator
182
{
183
public
:
184
static
TypeId
GetTypeId
(
void
);
185
RandomRectanglePositionAllocator
();
186
virtual
~RandomRectanglePositionAllocator
();
187
188
void
SetX
(
Ptr<RandomVariableStream>
x
);
189
void
SetY
(
Ptr<RandomVariableStream>
y);
190
191
virtual
Vector
GetNext
(
void
)
const
;
192
virtual
int64_t
AssignStreams
(int64_t stream);
193
private
:
194
Ptr<RandomVariableStream>
m_x
;
195
Ptr<RandomVariableStream>
m_y
;
196
};
197
202
class
RandomBoxPositionAllocator
:
public
PositionAllocator
203
{
204
public
:
205
static
TypeId
GetTypeId
(
void
);
206
RandomBoxPositionAllocator
();
207
virtual
~RandomBoxPositionAllocator
();
208
209
void
SetX
(
Ptr<RandomVariableStream>
x
);
210
void
SetY
(
Ptr<RandomVariableStream>
y);
211
void
SetZ
(
Ptr<RandomVariableStream>
z);
212
213
virtual
Vector
GetNext
(
void
)
const
;
214
virtual
int64_t
AssignStreams
(int64_t stream);
215
private
:
216
Ptr<RandomVariableStream>
m_x
;
217
Ptr<RandomVariableStream>
m_y
;
218
Ptr<RandomVariableStream>
m_z
;
219
};
220
226
class
RandomDiscPositionAllocator
:
public
PositionAllocator
227
{
228
public
:
229
static
TypeId
GetTypeId
(
void
);
230
RandomDiscPositionAllocator
();
231
virtual
~RandomDiscPositionAllocator
();
232
233
void
SetTheta
(
Ptr<RandomVariableStream>
theta);
234
void
SetRho
(
Ptr<RandomVariableStream>
rho);
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
:
241
Ptr<RandomVariableStream>
m_theta
;
242
Ptr<RandomVariableStream>
m_rho
;
243
double
m_x
;
244
double
m_y
;
245
};
246
247
265
class
UniformDiscPositionAllocator
:
public
PositionAllocator
266
{
267
public
:
268
static
TypeId
GetTypeId
(
void
);
269
UniformDiscPositionAllocator
();
270
virtual
~UniformDiscPositionAllocator
();
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
:
290
Ptr<UniformRandomVariable>
m_rv
;
291
double
m_rho
;
292
double
m_x
;
293
double
m_y
;
294
};
295
296
}
// namespace ns3
297
298
#endif
/* RANDOM_POSITION_H */
src
mobility
model
position-allocator.h
Generated on Tue Oct 9 2012 16:45:43 for ns-3 by
1.8.1.2