LEFT | RIGHT |
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ | 1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
2 /* | 2 /* |
3 * Copyright (c) 2009 Phillip Sitbon | 3 * Copyright (c) 2009 Phillip Sitbon |
4 * | 4 * |
5 * This program is free software; you can redistribute it and/or modify | 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 | 6 * it under the terms of the GNU General Public License version 2 as |
7 * published by the Free Software Foundation; | 7 * published by the Free Software Foundation; |
8 * | 8 * |
9 * This program is distributed in the hope that it will be useful, | 9 * This program is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
12 * GNU General Public License for more details. | 12 * GNU General Public License for more details. |
13 * | 13 * |
14 * You should have received a copy of the GNU General Public License | 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 | 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 | 16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
17 * | 17 * |
18 * Author: Phillip Sitbon <phillip@sitbon.net> | 18 * Author: Phillip Sitbon <phillip@sitbon.net> |
19 */ | 19 */ |
20 #ifndef WAYPOINT_MOBILITY_MODEL_H | 20 #ifndef WAYPOINT_MOBILITY_MODEL_H |
21 #define WAYPOINT_MOBILITY_MODEL_H | 21 #define WAYPOINT_MOBILITY_MODEL_H |
22 | 22 |
23 #include <stdint.h> | 23 #include <stdint.h> |
24 #include <deque> | 24 #include <deque> |
25 #include "mobility-model.h" | 25 #include "mobility-model.h" |
26 #include "ns3/vector.h" | 26 #include "ns3/vector.h" |
27 #include "waypoint.h" | 27 #include "waypoint.h" |
| 28 |
| 29 class WaypointMobilityModelNotifyTest; |
28 | 30 |
29 namespace ns3 { | 31 namespace ns3 { |
30 | 32 |
31 /** | 33 /** |
32 * \ingroup mobility | 34 * \ingroup mobility |
33 * \brief Waypoint-based mobility model. | 35 * \brief Waypoint-based mobility model. |
34 * | 36 * |
35 * Each object determines its velocity and position at a given time | 37 * Each object determines its velocity and position at a given time |
36 * from a set of ns3::Waypoint objects. Past waypoints are discarded | 38 * from a set of ns3::Waypoint objects. Past waypoints are discarded |
37 * after the current simulation time greater than their time value. | 39 * after the current simulation time greater than their time value. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 * ignored. However, if InitialPositionIsWaypoint is set to true | 79 * ignored. However, if InitialPositionIsWaypoint is set to true |
78 * and SetPosition() is called before any waypoints have been added, | 80 * and SetPosition() is called before any waypoints have been added, |
79 * the SetPosition() call is treated as an initial waypoint at time zero. | 81 * the SetPosition() call is treated as an initial waypoint at time zero. |
80 * In such a case, when SetPosition() is treated as an initial waypoint, | 82 * In such a case, when SetPosition() is treated as an initial waypoint, |
81 * it should be noted that attempts to add a waypoint at the same time | 83 * it should be noted that attempts to add a waypoint at the same time |
82 * will cause the program to fail. | 84 * will cause the program to fail. |
83 */ | 85 */ |
84 class WaypointMobilityModel : public MobilityModel | 86 class WaypointMobilityModel : public MobilityModel |
85 { | 87 { |
86 public: | 88 public: |
| 89 /** |
| 90 * Register this type with the TypeId system. |
| 91 * \return the object TypeId |
| 92 */ |
87 static TypeId GetTypeId (void); | 93 static TypeId GetTypeId (void); |
88 | 94 |
89 /** | 95 /** |
90 * Create a path with no waypoints at location (0,0,0). | 96 * Create a path with no waypoints at location (0,0,0). |
91 */ | 97 */ |
92 WaypointMobilityModel (); | 98 WaypointMobilityModel (); |
93 virtual ~WaypointMobilityModel (); | 99 virtual ~WaypointMobilityModel (); |
94 | 100 |
95 /** | 101 /** |
96 * \param waypoint waypoint to append to the object path. | 102 * \param waypoint waypoint to append to the object path. |
(...skipping 19 matching lines...) Expand all Loading... |
116 | 122 |
117 /** | 123 /** |
118 * Clear any existing waypoints and set the current waypoint | 124 * Clear any existing waypoints and set the current waypoint |
119 * time to infinity. Calling this is only an optimization and | 125 * time to infinity. Calling this is only an optimization and |
120 * not required. After calling this function, adding waypoints | 126 * not required. After calling this function, adding waypoints |
121 * behaves as it would for a new object. | 127 * behaves as it would for a new object. |
122 */ | 128 */ |
123 void EndMobility (void); | 129 void EndMobility (void); |
124 | 130 |
125 private: | 131 private: |
126 friend class WaypointMobilityModelNotifyTest; // To allow Update() calls and a
ccess to m_current | 132 friend class ::WaypointMobilityModelNotifyTest; // To allow Update() calls and
access to m_current |
127 | 133 |
| 134 /** |
| 135 * Update the underlying state corresponding to the stored waypoints |
| 136 */ |
128 virtual void Update (void) const; | 137 virtual void Update (void) const; |
| 138 /** |
| 139 * \brief The dispose method. |
| 140 *· |
| 141 * Subclasses must override this method. |
| 142 */ |
129 virtual void DoDispose (void); | 143 virtual void DoDispose (void); |
| 144 /** |
| 145 * \brief Get current position. |
| 146 * \return A vector with the current position of the node.·· |
| 147 */ |
130 virtual Vector DoGetPosition (void) const; | 148 virtual Vector DoGetPosition (void) const; |
| 149 /** |
| 150 * \brief Sets a new position for the node·· |
| 151 * \param position A vector to be added as the new position |
| 152 */ |
131 virtual void DoSetPosition (const Vector &position); | 153 virtual void DoSetPosition (const Vector &position); |
| 154 /** |
| 155 * \brief Returns the current velocity of a node |
| 156 * \return The velocity vector of a node.· |
| 157 */ |
132 virtual Vector DoGetVelocity (void) const; | 158 virtual Vector DoGetVelocity (void) const; |
133 | 159 |
134 protected: | 160 protected: |
| 161 /** |
| 162 * \brief This variable is set to true if there are no waypoints in the std::d
eque |
| 163 */ |
135 bool m_first; | 164 bool m_first; |
| 165 /** |
| 166 * \brief If true, course change updates are only notified when position |
| 167 * is calculated. |
| 168 */ |
136 bool m_lazyNotify; | 169 bool m_lazyNotify; |
| 170 /** |
| 171 * \brief If true, calling SetPosition with no waypoints creates a waypoint |
| 172 */ |
137 bool m_initialPositionIsWaypoint; | 173 bool m_initialPositionIsWaypoint; |
| 174 /** |
| 175 * \brief The double ended queue containing the ns3::Waypoint objects |
| 176 */ |
138 mutable std::deque<Waypoint> m_waypoints; | 177 mutable std::deque<Waypoint> m_waypoints; |
| 178 /** |
| 179 * \brief The ns3::Waypoint currently being used |
| 180 */ |
139 mutable Waypoint m_current; | 181 mutable Waypoint m_current; |
| 182 /** |
| 183 * \brief The next ns3::Waypoint in the deque |
| 184 */ |
140 mutable Waypoint m_next; | 185 mutable Waypoint m_next; |
| 186 /** |
| 187 * \brief The current velocity vector |
| 188 */ |
141 mutable Vector m_velocity; | 189 mutable Vector m_velocity; |
142 }; | 190 }; |
143 | 191 |
144 } // namespace ns3 | 192 } // namespace ns3 |
145 | 193 |
146 #endif /* WAYPOINT_MOBILITY_MODEL_H */ | 194 #endif /* WAYPOINT_MOBILITY_MODEL_H */ |
147 | 195 |
LEFT | RIGHT |