ROVehicle.cpp

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

Generated on Wed May 5 00:06:36 2010 for Sumo - Simulation of Urban MObility by  doxygen 1.5.6