A Discrete-Event Network Simulator
API
waypoint-mobility-model.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009 Phillip Sitbon
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: Phillip Sitbon <phillip@sitbon.net>
18  */
19 #ifndef WAYPOINT_MOBILITY_MODEL_H
20 #define WAYPOINT_MOBILITY_MODEL_H
21 
22 #include "mobility-model.h"
23 #include "waypoint.h"
24 
25 #include "ns3/vector.h"
26 
27 #include <deque>
28 #include <stdint.h>
29 
31 
32 namespace ns3
33 {
34 
89 {
90  public:
95  static TypeId GetTypeId();
96 
101  ~WaypointMobilityModel() override;
102 
112  void AddWaypoint(const Waypoint& waypoint);
113 
118  Waypoint GetNextWaypoint() const;
119 
125  uint32_t WaypointsLeft() const;
126 
133  void EndMobility();
134 
135  private:
136  friend class ::WaypointMobilityModelNotifyTest; // To allow Update() calls and access to
137  // m_current
138 
142  virtual void Update() const;
148  void DoDispose() override;
153  Vector DoGetPosition() const override;
158  void DoSetPosition(const Vector& position) override;
163  Vector DoGetVelocity() const override;
164 
165  protected:
169  bool m_first;
182  mutable std::deque<Waypoint> m_waypoints;
190  mutable Waypoint m_next;
194  mutable Vector m_velocity;
195 };
196 
197 } // namespace ns3
198 
199 #endif /* WAYPOINT_MOBILITY_MODEL_H */
Waypoint Mobility Model Notify Test.
Keep track of the current position and velocity of an object.
a unique identifier for an interface.
Definition: type-id.h:59
a (time, location) pair.
Definition: waypoint.h:36
Waypoint-based mobility model.
Vector m_velocity
The current velocity vector.
void DoDispose() override
The dispose method.
Waypoint GetNextWaypoint() const
Get the waypoint that this object is traveling towards.
bool m_initialPositionIsWaypoint
If true, calling SetPosition with no waypoints creates a waypoint.
virtual void Update() const
Update the underlying state corresponding to the stored waypoints.
Vector DoGetVelocity() const override
Returns the current velocity of a node.
WaypointMobilityModel()
Create a path with no waypoints at location (0,0,0).
uint32_t WaypointsLeft() const
Get the number of waypoints left for this object, excluding the next one.
Waypoint m_current
The ns3::Waypoint currently being used.
bool m_first
This variable is set to true if there are no waypoints in the std::deque.
std::deque< Waypoint > m_waypoints
The double ended queue containing the ns3::Waypoint objects.
bool m_lazyNotify
If true, course change updates are only notified when position is calculated.
void EndMobility()
Clear any existing waypoints and set the current waypoint time to infinity.
void DoSetPosition(const Vector &position) override
Sets a new position for the node.
Vector DoGetPosition() const override
Get current position.
Waypoint m_next
The next ns3::Waypoint in the deque.
static TypeId GetTypeId()
Register this type with the TypeId system.
void AddWaypoint(const Waypoint &waypoint)
Every class exported by the ns3 library is enclosed in the ns3 namespace.