A Discrete-Event Network Simulator
API
mobility-helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 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 
20 #ifndef MOBILITY_HELPER_H
21 #define MOBILITY_HELPER_H
22 
23 #include "ns3/attribute.h"
24 #include "ns3/node-container.h"
25 #include "ns3/object-factory.h"
26 #include "ns3/output-stream-wrapper.h"
27 #include "ns3/position-allocator.h"
28 
29 #include <vector>
30 
31 namespace ns3
32 {
33 
34 class PositionAllocator;
35 class MobilityModel;
36 
44 {
45  public:
51 
56 
64 
70  template <typename... Ts>
71  void SetPositionAllocator(std::string type, Ts&&... args);
72 
81  template <typename... Ts>
82  void SetMobilityModel(std::string type, Ts&&... args);
83 
121  void PushReferenceMobilityModel(std::string referenceName);
127 
132  std::string GetMobilityModelType() const;
133 
144  void Install(Ptr<Node> node) const;
155  void Install(std::string nodeName) const;
156 
168  void Install(NodeContainer container) const;
169 
174  void InstallAll() const;
175 
185  static void EnableAscii(Ptr<OutputStreamWrapper> stream, uint32_t nodeid);
195  static void EnableAscii(Ptr<OutputStreamWrapper> stream, NodeContainer n);
204  static void EnableAsciiAll(Ptr<OutputStreamWrapper> stream);
223  int64_t AssignStreams(NodeContainer c, int64_t stream);
224 
230  static double GetDistanceSquaredBetween(Ptr<Node> n1, Ptr<Node> n2);
231 
232  private:
239  std::vector<Ptr<MobilityModel>> m_mobilityStack;
243 };
244 
245 /***************************************************************
246  * Implementation of the templates declared above.
247  ***************************************************************/
248 
249 template <typename... Ts>
250 void
252 {
253  ObjectFactory pos(type, std::forward<Ts>(args)...);
255 }
256 
257 template <typename... Ts>
258 void
260 {
262  m_mobility.Set(std::forward<Ts>(args)...);
263 }
264 
265 } // namespace ns3
266 
267 #endif /* MOBILITY_HELPER_H */
Helper class used to assign positions and mobility models to nodes.
void PopReferenceMobilityModel()
Remove the top item from the top of the stack of "reference mobility models".
int64_t AssignStreams(NodeContainer c, int64_t stream)
Assign a fixed random variable stream number to the random variables used by the mobility models on t...
static void EnableAsciiAll(Ptr< OutputStreamWrapper > stream)
static double GetDistanceSquaredBetween(Ptr< Node > n1, Ptr< Node > n2)
void Install(Ptr< Node > node) const
"Layout" a single node according to the current position allocator type.
ObjectFactory m_mobility
Object factory to create mobility objects.
static void CourseChanged(Ptr< OutputStreamWrapper > stream, Ptr< const MobilityModel > mobility)
Output course change events from mobility model to output stream.
std::string GetMobilityModelType() const
void SetMobilityModel(std::string type, Ts &&... args)
~MobilityHelper()
Destroy a Mobility Helper.
Ptr< PositionAllocator > m_position
Position allocator for use in hierarchical mobility model.
void PushReferenceMobilityModel(Ptr< Object > reference)
void InstallAll() const
Perform the work of MobilityHelper::Install on all nodes which exist in the simulation.
MobilityHelper()
Construct a Mobility Helper which is used to make life easier when working with mobility models.
void SetPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of every node initiali...
static void EnableAscii(Ptr< OutputStreamWrapper > stream, uint32_t nodeid)
std::vector< Ptr< MobilityModel > > m_mobilityStack
Internal stack of mobility models.
keep track of a set of node pointers.
Instantiate subclasses of ns3::Object.
Ptr< Object > Create() const
Create an Object instance of the configured TypeId.
void Set(const std::string &name, const AttributeValue &value, Args &&... args)
Set an attribute to be set during construction.
void SetTypeId(TypeId tid)
Set the TypeId of the Objects to be created by this factory.
Ptr< T > GetObject() const
Get a pointer to the requested aggregated Object.
Definition: object.h:471
Allocate a set of positions.
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:77
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:105