SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00009 // A vehicle as used by router 00010 /****************************************************************************/ 00011 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00012 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00013 /****************************************************************************/ 00014 // 00015 // This file is part of SUMO. 00016 // SUMO is free software: you can redistribute it and/or modify 00017 // it under the terms of the GNU General Public License as published by 00018 // the Free Software Foundation, either version 3 of the License, or 00019 // (at your option) any later version. 00020 // 00021 /****************************************************************************/ 00022 00023 00024 // =========================================================================== 00025 // included modules 00026 // =========================================================================== 00027 #ifdef _MSC_VER 00028 #include <windows_config.h> 00029 #else 00030 #include <config.h> 00031 #endif 00032 00033 #include <utils/common/TplConvert.h> 00034 #include <utils/common/ToString.h> 00035 #include <utils/common/MsgHandler.h> 00036 #include <utils/common/SUMOVTypeParameter.h> 00037 #include <utils/options/OptionsCont.h> 00038 #include <utils/iodevices/OutputDevice.h> 00039 #include <string> 00040 #include <iostream> 00041 #include "RORouteDef.h" 00042 #include "ROVehicle.h" 00043 #include "RORouteDef_Alternatives.h" 00044 #include "RORoute.h" 00045 #include "ROHelper.h" 00046 00047 #ifdef CHECK_MEMORY_LEAKS 00048 #include <foreign/nvwa/debug_new.h> 00049 #endif // CHECK_MEMORY_LEAKS 00050 00051 00052 // =========================================================================== 00053 // method definitions 00054 // =========================================================================== 00055 ROVehicle::ROVehicle(const SUMOVehicleParameter& pars, 00056 RORouteDef* route, SUMOVTypeParameter* type) 00057 : myParameter(pars), myType(type), myRoute(route) {} 00058 00059 00060 ROVehicle::~ROVehicle() {} 00061 00062 00063 void 00064 ROVehicle::saveAllAsXML(SUMOAbstractRouter<ROEdge, ROVehicle> &router, OutputDevice& os, 00065 OutputDevice* const altos, OutputDevice* const typeos, bool withExitTimes) const { 00066 // check whether the vehicle's type was saved before 00067 if (myType != 0 && !myType->saved) { 00068 // ... save if not 00069 if (typeos != 0) { 00070 myType->write(*typeos); 00071 } else { 00072 myType->write(os); 00073 if (altos != 0) { 00074 myType->write(*altos); 00075 } 00076 } 00077 myType->saved = true; 00078 } 00079 00080 // write the vehicle (new style, with included routes) 00081 myParameter.writeAs("vehicle", os, OptionsCont::getOptions()); 00082 if (altos != 0) { 00083 myParameter.writeAs("vehicle", *altos, OptionsCont::getOptions()); 00084 } 00085 00086 // check whether the route shall be saved 00087 if (!myRoute->isSaved()) { 00088 myRoute->writeXMLDefinition(router, os, this, false, withExitTimes); 00089 if (altos != 0) { 00090 myRoute->writeXMLDefinition(router, *altos, this, true, withExitTimes); 00091 } 00092 } 00093 os.closeTag(); 00094 if (altos != 0) { 00095 altos->closeTag(); 00096 } 00097 } 00098 00099 00100 SUMOReal 00101 ROVehicle::getMaxSpeed() const { 00102 return myType->maxSpeed; 00103 } 00104 00105 00106 ROVehicle* 00107 ROVehicle::copy(const std::string& id, unsigned int depTime, 00108 RORouteDef* newRoute) { 00109 SUMOVehicleParameter pars(myParameter); 00110 pars.id = id; 00111 pars.depart = depTime; 00112 return new ROVehicle(pars, newRoute, myType); 00113 } 00114 00115 00116 /****************************************************************************/ 00117