SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
RORoute.cpp
Go to the documentation of this file.
1 /****************************************************************************/
8 // A complete router's route
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 <utils/common/Named.h>
36 #include <utils/common/StdDefs.h>
37 #include "ROEdge.h"
38 #include "RORoute.h"
39 #include "ROHelper.h"
41 
42 #ifdef CHECK_MEMORY_LEAKS
43 #include <foreign/nvwa/debug_new.h>
44 #endif // CHECK_MEMORY_LEAKS
45 
46 
47 // ===========================================================================
48 // method definitions
49 // ===========================================================================
50 RORoute::RORoute(const std::string& id, SUMOReal costs, SUMOReal prop,
51  const std::vector<const ROEdge*>& route,
52  const RGBColor* const color)
53  : Named(StringUtils::convertUmlaute(id)), myCosts(costs),
54  myProbability(prop), myRoute(route), myColor(color) {}
55 
56 
58  : Named(src.myID), myCosts(src.myCosts),
59  myProbability(src.myProbability), myRoute(src.myRoute), myColor(0) {
60  if (src.myColor != 0) {
61  myColor = new RGBColor(*src.myColor);
62  }
63 }
64 
65 
67  delete myColor;
68 }
69 
70 
71 void
73  myRoute.push_back(edge);
74 }
75 
76 
77 void
79  myCosts = costs;
80 }
81 
82 
83 void
85  myProbability = prob;
86 }
87 
88 
89 void
92 }
93 
94 
97  const bool withCosts,
98  const bool withExitTimes) const {
100  if (withCosts) {
102  dev.setPrecision(8);
104  dev.setPrecision();
105  }
106  if (myColor != 0) {
108  }
110  if (withExitTimes) {
111  std::string exitTimes;
112  SUMOReal time = STEPS2TIME(veh->getDepartureTime());
113  for (std::vector<const ROEdge*>::const_iterator i = myRoute.begin(); i != myRoute.end(); ++i) {
114  if (i != myRoute.begin()) {
115  exitTimes += " ";
116  }
117  time += (*i)->getTravelTime(veh, time);
118  exitTimes += toString(time);
119  }
120  dev.writeAttr("exitTimes", exitTimes);
121  }
122  dev.closeTag(true);
123  return dev;
124 }
125 
126 
127 
128 
129 /****************************************************************************/
130