SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROVehicle.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // A vehicle as used by router
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2001-2013 DLR (http://www.dlr.de/) and contributors
13 /****************************************************************************/
14 //
15 // This file is part of SUMO.
16 // SUMO is free software: you can redistribute it and/or modify
17 // it under the terms of the GNU General Public License as published by
18 // the Free Software Foundation, either version 3 of the License, or
19 // (at your option) any later version.
20 //
21 /****************************************************************************/
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
34 #include <utils/common/ToString.h>
39 #include <string>
40 #include <iostream>
41 #include "RORouteDef.h"
42 #include "ROVehicle.h"
43 #include "RORoute.h"
44 #include "ROHelper.h"
45 
46 #ifdef CHECK_MEMORY_LEAKS
47 #include <foreign/nvwa/debug_new.h>
48 #endif // CHECK_MEMORY_LEAKS
49 
50 
51 // ===========================================================================
52 // method definitions
53 // ===========================================================================
55  RORouteDef* route, const SUMOVTypeParameter* type)
56  : myParameter(pars), myType(type), myRoute(route) {}
57 
58 
60 
61 
62 void
64  OutputDevice* const typeos, bool withExitTimes) const {
65  // check whether the vehicle's type was saved before
66  if (myType != 0 && !myType->saved) {
67  // ... save if not
68  if (typeos != 0) {
69  myType->write(*typeos);
70  } else {
71  myType->write(os);
72  if (altos != 0) {
73  myType->write(*altos);
74  }
75  }
76  myType->saved = true;
77  }
78 
79  // write the vehicle (new style, with included routes)
81  if (altos != 0) {
83  }
84 
85  // check whether the route shall be saved
86  if (!myRoute->isSaved()) {
87  myRoute->writeXMLDefinition(os, this, false, withExitTimes);
88  if (altos != 0) {
89  myRoute->writeXMLDefinition(*altos, this, true, withExitTimes);
90  }
91  }
93  if (altos != 0) {
94  myParameter.writeStops(*altos);
95  }
96  os.closeTag();
97  if (altos != 0) {
98  altos->closeTag();
99  }
100 }
101 
102 
103 SUMOReal
105  return myType->maxSpeed;
106 }
107 
108 
109 ROVehicle*
110 ROVehicle::copy(const std::string& id, unsigned int depTime,
111  RORouteDef* newRoute) const {
113  pars.id = id;
114  pars.depart = depTime;
115  return new ROVehicle(pars, newRoute, myType);
116 }
117 
118 
119 /****************************************************************************/
120