SUMO - Simulation of Urban MObility
MSDevice_Vehroutes.h
Go to the documentation of this file.
00001 /****************************************************************************/
00008 // A device which collects info on the vehicle trip
00009 /****************************************************************************/
00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
00012 /****************************************************************************/
00013 //
00014 //   This file is part of SUMO.
00015 //   SUMO is free software: you can redistribute it and/or modify
00016 //   it under the terms of the GNU General Public License as published by
00017 //   the Free Software Foundation, either version 3 of the License, or
00018 //   (at your option) any later version.
00019 //
00020 /****************************************************************************/
00021 #ifndef MSDevice_Vehroutes_h
00022 #define MSDevice_Vehroutes_h
00023 
00024 
00025 // ===========================================================================
00026 // included modules
00027 // ===========================================================================
00028 #ifdef _MSC_VER
00029 #include <windows_config.h>
00030 #else
00031 #include <config.h>
00032 #endif
00033 
00034 #include "MSDevice.h"
00035 #include <microsim/MSNet.h>
00036 #include <utils/common/SUMOTime.h>
00037 
00038 
00039 // ===========================================================================
00040 // class declarations
00041 // ===========================================================================
00042 class MSEdge;
00043 class MSRoute;
00044 
00045 
00046 // ===========================================================================
00047 // class definitions
00048 // ===========================================================================
00057 class MSDevice_Vehroutes : public MSDevice {
00058 public:
00061     static void init();
00062 
00063 
00074     static MSDevice_Vehroutes* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*> &into, unsigned int maxRoutes = INT_MAX) ;
00075 
00076 
00077 public:
00080 
00089     bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason) ;
00090 
00091 
00103     bool notifyLeave(SUMOVehicle& veh, SUMOReal lastPos, Notification reason) ;
00105 
00106 
00113     void generateOutput() const;
00114 
00115 
00121     const MSRoute* getRoute(int index) const;
00122 
00123 
00125     ~MSDevice_Vehroutes() ;
00126 
00127 
00128 private:
00134     MSDevice_Vehroutes(SUMOVehicle& holder, const std::string& id, unsigned int maxRoutes) ;
00135 
00136 
00142     void writeXMLRoute(OutputDevice& os, int index = -1) const;
00143 
00144 
00147     void addRoute();
00148 
00149 
00150 private:
00152     static bool mySaveExits;
00153 
00155     static bool myLastRouteOnly;
00156 
00158     static bool mySorted;
00159 
00161     static bool myWithTaz;
00162 
00163     class StateListener : public MSNet::VehicleStateListener {
00164     public:
00166         ~StateListener() {}
00167 
00172         void vehicleStateChanged(const SUMOVehicle* const vehicle, MSNet::VehicleState to);
00173 
00175         std::map<const SUMOVehicle*, MSDevice_Vehroutes*> myDevices;
00176     };
00177 
00178     static StateListener myStateListener;
00179 
00180     static std::map<const SUMOTime, int> myDepartureCounts;
00181 
00182     static std::map<const SUMOTime, std::string> myRouteInfos;
00183 
00193     class RouteReplaceInfo {
00194     public:
00196         RouteReplaceInfo(const MSEdge* const edge_, const SUMOTime time_, const MSRoute* const route_)
00197             : edge(edge_), time(time_), route(route_) {}
00198 
00200         ~RouteReplaceInfo() { }
00201 
00203         const MSEdge* edge;
00204 
00206         SUMOTime time;
00207 
00209         const MSRoute* route;
00210 
00211     };
00212 
00213     const MSRoute* myCurrentRoute;
00214     std::vector<RouteReplaceInfo> myReplacedRoutes;
00215     std::vector<SUMOTime> myExits;
00216     const unsigned int myMaxRoutes;
00217     const MSEdge* myLastSavedAt;
00218 
00219 private:
00221     MSDevice_Vehroutes(const MSDevice_Vehroutes&);
00222 
00224     MSDevice_Vehroutes& operator=(const MSDevice_Vehroutes&);
00225 
00226 
00227 };
00228 
00229 
00230 #endif
00231 
00232 /****************************************************************************/
00233 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines