A Discrete-Event Network Simulator
API
waypoint-mobility-model.h
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright (c) 2009 Phillip Sitbon
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: Phillip Sitbon <phillip@sitbon.net>
19  */
20 #ifndef WAYPOINT_MOBILITY_MODEL_H
21 #define WAYPOINT_MOBILITY_MODEL_H
22 
23 #include <stdint.h>
24 #include <deque>
25 #include "mobility-model.h"
26 #include "ns3/vector.h"
27 #include "waypoint.h"
28 
30 
31 namespace ns3 {
32 
87 {
88 public:
93  static TypeId GetTypeId (void);
94 
99  virtual ~WaypointMobilityModel ();
100 
110  void AddWaypoint (const Waypoint &waypoint);
111 
116  Waypoint GetNextWaypoint (void) const;
117 
123  uint32_t WaypointsLeft (void) const;
124 
131  void EndMobility (void);
132 
133 private:
134  friend class ::WaypointMobilityModelNotifyTest; // To allow Update() calls and access to m_current
135 
139  virtual void Update (void) const;
145  virtual void DoDispose (void);
150  virtual Vector DoGetPosition (void) const;
155  virtual void DoSetPosition (const Vector &position);
160  virtual Vector DoGetVelocity (void) const;
161 
162 protected:
166  bool m_first;
179  mutable std::deque<Waypoint> m_waypoints;
187  mutable Waypoint m_next;
191  mutable Vector m_velocity;
192 };
193 
194 } // namespace ns3
195 
196 #endif /* WAYPOINT_MOBILITY_MODEL_H */
197 
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.
bool m_initialPositionIsWaypoint
If true, calling SetPosition with no waypoints creates a waypoint.
virtual void DoSetPosition(const Vector &position)
Sets a new position for the node
virtual void Update(void) const
Update the underlying state corresponding to the stored waypoints.
static TypeId GetTypeId(void)
Register this type with the TypeId system.
virtual Vector DoGetPosition(void) const
Get current position.
virtual void DoDispose(void)
The dispose method.
WaypointMobilityModel()
Create a path with no waypoints at location (0,0,0).
void EndMobility(void)
Clear any existing waypoints and set the current waypoint time to infinity.
Waypoint GetNextWaypoint(void) const
Get the waypoint that this object is traveling towards.
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.
uint32_t WaypointsLeft(void) const
Get the number of waypoints left for this object, excluding the next one.
Waypoint m_next
The next ns3::Waypoint in the deque.
void AddWaypoint(const Waypoint &waypoint)
virtual Vector DoGetVelocity(void) const
Returns the current velocity of a node.
Every class exported by the ns3 library is enclosed in the ns3 namespace.