A Discrete-Event Network Simulator
API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
position-allocator.h
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;
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 
182 {
183 public:
184  static TypeId GetTypeId (void);
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:
196 };
197 
203 {
204 public:
205  static TypeId GetTypeId (void);
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:
219 };
220 
227 {
228 public:
229  static TypeId GetTypeId (void);
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:
243  double m_x;
244  double m_y;
245 };
246 
247 
266 {
267 public:
268  static TypeId GetTypeId (void);
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:
291  double m_rho;
292  double m_x;
293  double m_y;
294 };
295 
296 } // namespace ns3
297 
298 #endif /* RANDOM_POSITION_H */
virtual Vector GetNext(void) const =0
enum LayoutType GetLayoutType(void) const
virtual Vector GetNext(void) const
virtual int64_t AssignStreams(int64_t stream)
virtual Vector GetNext(void) const
a 3d vector
Definition: vector.h:31
virtual Vector GetNext(void) const
Allocate positions on a rectangular 2d grid.
Allocate positions from a deterministic list specified by the user.
virtual int64_t AssignStreams(int64_t stream)
virtual Vector GetNext(void) const
virtual int64_t AssignStreams(int64_t stream)
Allocate the positions uniformely (with constant density) randomly within a disc. ...
Allocate random positions within a rectangle according to a pair of random variables.
virtual int64_t AssignStreams(int64_t stream)
void SetLayoutType(enum LayoutType layoutType)
virtual Vector GetNext(void) const
uint32_t GetN(void) const
Allocate random positions within a 3D box according to a set of three random variables.
virtual int64_t AssignStreams(int64_t stream)
a base class which provides memory management and object aggregation
Definition: object.h:63
a unique identifier for an interface.
Definition: type-id.h:44
Allocate random positions within a disc according to a given distribution for the polar coordinates o...
virtual int64_t AssignStreams(int64_t stream)
Allocate a set of positions. The allocation strategy is implemented in subclasses.
virtual int64_t AssignStreams(int64_t stream)=0