SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RORouteDef_OrigDest.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // A route where only the origin and the destination edges are known
9 /****************************************************************************/
10 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12 /****************************************************************************/
13 //
14 // This file is part of SUMO.
15 // SUMO is free software: you can redistribute it and/or modify
16 // it under the terms of the GNU General Public License as published by
17 // the Free Software Foundation, either version 3 of the License, or
18 // (at your option) any later version.
19 //
20 /****************************************************************************/
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <iostream>
34 #include <cassert>
35 #include "ROEdge.h"
36 #include "RORouteDef.h"
37 #include "RORoute.h"
38 #include "RORouteDef_OrigDest.h"
40 #include "ROVehicle.h"
41 #include "ROHelper.h"
44 
45 #ifdef CHECK_MEMORY_LEAKS
46 #include <foreign/nvwa/debug_new.h>
47 #endif // CHECK_MEMORY_LEAKS
48 
49 
50 // ===========================================================================
51 // member method definitions
52 // ===========================================================================
54  const RGBColor* const color,
55  const ROEdge* from,
56  const ROEdge* to,
57  bool removeFirst)
58  : RORouteDef(id, color), myFrom(from), myTo(to), myCurrent(0),
59  myRemoveFirst(removeFirst) {}
60 
61 
63  delete myCurrent;
64 }
65 
66 
67 void
69  SUMOTime begin, const ROVehicle& veh) const {
70  std::vector<const ROEdge*> edges;
71  router.compute(myFrom, myTo, &veh, begin, edges);
72  if (myRemoveFirst && edges.size() > 2) {
73  edges.erase(edges.begin());
74  edges.erase(edges.end() - 1);
75  }
76  myPrecomputed = new RORoute(myID, 0, 1, edges, copyColorIfGiven());
77 }
78 
79 
80 void
82  const ROVehicle* const veh, RORoute* current, SUMOTime begin) {
83  myCurrent = current;
84  myStartTime = begin;
85  current->setCosts(router.recomputeCosts(current->getEdgeVector(), veh, begin));
86 }
87 
88 
90 RORouteDef_OrigDest::copy(const std::string& id) const {
93 }
94 
95 
98  OutputDevice& dev, const ROVehicle* const veh, bool asAlternatives, bool withExitTimes) const {
99  return myCurrent->writeXMLDefinition(router, dev, veh, asAlternatives, withExitTimes);
100 }
101 
102 
103 const ROEdge*
105  return myTo;
106 }
107 
108 
109 /****************************************************************************/
110