A Discrete-Event Network Simulator
API
group-mobility-helper.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2008 INRIA
3  * Copyright (c) 2021 University of Washington: Group mobility changes
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  * Adapted from 'mobility-helper.h' for group mobility by Tom Henderson
20  */
21 
22 #ifndef GROUP_MOBILITY_HELPER_H
23 #define GROUP_MOBILITY_HELPER_H
24 
25 #include "ns3/attribute.h"
26 #include "ns3/node-container.h"
27 #include "ns3/object-factory.h"
28 
29 #include <vector>
30 
31 namespace ns3
32 {
33 
34 class PositionAllocator;
35 class MobilityModel;
36 
48 {
49  public:
54 
59 
67 
76  template <typename... Ts>
77  void SetReferencePositionAllocator(std::string type, Ts&&... args);
78 
86 
95  template <typename... Ts>
96  void SetMemberPositionAllocator(std::string type, Ts&&... args);
97 
105 
114  template <typename... Ts>
115  void SetReferenceMobilityModel(std::string type, Ts&&... args);
116 
128  template <typename... Ts>
129  void SetMemberMobilityModel(std::string type, Ts&&... args);
130 
140  void Install(Ptr<Node> node);
150  void Install(std::string nodeName);
151 
162 
181  int64_t AssignStreams(NodeContainer c, int64_t stream);
182 
183  private:
184  // Enable logging from template instantiations
186 
188  false};
195 };
196 
197 /***************************************************************
198  * Implementation of the templates declared above.
199  ***************************************************************/
200 
201 template <typename... Ts>
202 void
204 {
205  ObjectFactory pos(type, std::forward<Ts>(args)...);
207  NS_ABORT_MSG_IF(!m_referencePosition, "Unable to create allocator from TypeId " << type);
208 }
209 
210 template <typename... Ts>
211 void
213 {
214  ObjectFactory pos(type, std::forward<Ts>(args)...);
216  NS_ABORT_MSG_IF(!m_memberPosition, "Unable to create allocator from TypeId " << type);
217 }
218 
219 template <typename... Ts>
220 void
222 {
223  NS_LOG_FUNCTION(this << type);
224  ObjectFactory mob(type, std::forward<Ts>(args)...);
226  NS_ABORT_MSG_IF(!m_referenceMobility, "Unable to create mobility from TypeId " << type);
227 }
228 
229 template <typename... Ts>
230 void
232 {
233  NS_LOG_FUNCTION(this << type);
235  m_memberMobilityFactory.Set(std::forward<Ts>(args)...);
236 }
237 
238 } // namespace ns3
239 
240 #endif /* GROUP_MOBILITY_HELPER_H */
Helper class used to assign positions and mobility models to nodes for a group mobility configuration...
void SetMemberMobilityModel(std::string type, Ts &&... args)
Configure the mobility model which will be installed as the member (child) mobility model during Grou...
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...
ObjectFactory m_memberMobilityFactory
Object factory to create member mobility models.
void SetMemberPositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of the member mobility...
void Install(Ptr< Node > node)
Install and configure a hierarchical mobility model to the given node, based on the configured refere...
void SetReferenceMobilityModel(Ptr< MobilityModel > mobility)
Set the reference mobility model which will be installed as the parent mobility model during GroupMob...
bool m_referencePositionSet
flag for avoiding multiple SetPosition calls on the reference model
~GroupMobilityHelper()
Destroy a group mobility helper.
Ptr< PositionAllocator > m_referencePosition
Position allocator for use as reference position allocator.
Ptr< PositionAllocator > m_memberPosition
Position allocator for use as member position allocator.
void SetReferencePositionAllocator(Ptr< PositionAllocator > allocator)
Set the position allocator which will be used to allocate the initial position of the reference mobil...
NS_LOG_TEMPLATE_DECLARE
the log component
Ptr< MobilityModel > m_referenceMobility
Reference mobility model.
GroupMobilityHelper()
Construct a group mobility helper.
Keep track of the current position and velocity of an object.
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
#define NS_ABORT_MSG_IF(cond, msg)
Abnormal program termination if a condition is true, with a message.
Definition: abort.h:108
#define NS_LOG_FUNCTION(parameters)
If log level LOG_FUNCTION is enabled, this macro will output all input parameters separated by ",...
Every class exported by the ns3 library is enclosed in the ns3 namespace.
mobility
Definition: third.py:105