]> git.mxchange.org Git - simgear.git/blobdiff - simgear/route/route.hxx
Modified Files:
[simgear.git] / simgear / route / route.hxx
index 326ca88360df882cfca4c91b09daff3bb0d359f3..5d93992da3f07c27e2a70a20e86627bfa152553a 100644 (file)
@@ -19,7 +19,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 // $Id$
 
 #define _ROUTE_HXX
 
 
-#ifndef __cplusplus                                                          
+#ifndef __cplusplus
 # error This library requires C++
-#endif                                   
-
-
-#ifdef HAVE_CONFIG_H
-#  include <config.h>
 #endif
 
+
 #include <simgear/compiler.h>
 
 #include STL_STRING
@@ -74,11 +70,14 @@ public:
     }
 
     /**
-     * Add a waypoint.
+     * Add waypoint (default), or insert waypoint at position n.
      * @param wp a waypoint
      */
-    inline void add_waypoint( const SGWayPoint &wp ) {
-       route.push_back( wp );
+    void add_waypoint( const SGWayPoint &wp, int n = -1 ) {
+        if ( n < 0 || n >= (int)route.size() )
+            route.push_back( wp );
+        else
+            route.insert( route.begin() + n, 1, wp );
 
        int size = route.size();
        if ( size > 1 ) {
@@ -150,10 +149,16 @@ public:
     }
 
     /** Delete the front waypoint */
-    inline void delete_first() {
-       if ( route.size() ) {
-           route.erase( route.begin() );
-       }
+    inline void delete_first() { delete_waypoint(0); }
+
+    /** Delete waypoint waypoint with index n  (last one if n < 0) */
+    void delete_waypoint( int n = 0 ) {
+        if ( !route.size() )
+            return;
+        if ( n < 0 || n >= (int)route.size() )
+            n = route.size() - 1;
+
+        route.erase( route.begin() + n );
     }
 
     /**