SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00010 // A vehicle route 00011 /****************************************************************************/ 00012 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00013 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00014 /****************************************************************************/ 00015 // 00016 // This file is part of SUMO. 00017 // SUMO is free software: you can redistribute it and/or modify 00018 // it under the terms of the GNU General Public License as published by 00019 // the Free Software Foundation, either version 3 of the License, or 00020 // (at your option) any later version. 00021 // 00022 /****************************************************************************/ 00023 #ifndef MSRoute_h 00024 #define MSRoute_h 00025 00026 00027 // =========================================================================== 00028 // included modules 00029 // =========================================================================== 00030 #ifdef _MSC_VER 00031 #include <windows_config.h> 00032 #else 00033 #include <config.h> 00034 #endif 00035 00036 #include <string> 00037 #include <map> 00038 #include <vector> 00039 #include <algorithm> 00040 #include <utils/common/Named.h> 00041 #include <utils/common/RandomDistributor.h> 00042 #include <utils/common/RGBColor.h> 00043 #include <utils/common/SUMOVehicleParameter.h> 00044 00045 00046 // =========================================================================== 00047 // class declarations 00048 // =========================================================================== 00049 class MSEdge; 00050 class BinaryInputDevice; 00051 class OutputDevice; 00052 00053 00054 typedef std::vector<const MSEdge*> MSEdgeVector; 00055 typedef MSEdgeVector::const_iterator MSRouteIterator; 00056 00057 00058 // =========================================================================== 00059 // class definitions 00060 // =========================================================================== 00064 class MSRoute : public Named { 00065 public: 00067 MSRoute(const std::string& id, const MSEdgeVector& edges, 00068 unsigned int references, const RGBColor& c, 00069 const std::vector<SUMOVehicleParameter::Stop> &stops) ; 00070 00072 virtual ~MSRoute() ; 00073 00075 MSRouteIterator begin() const; 00076 00078 MSRouteIterator end() const; 00079 00081 unsigned size() const; 00082 00084 const MSEdge* getLastEdge() const; 00085 00087 void addReference() const; 00088 00090 void release() const; 00091 00093 void writeEdgeIDs(OutputDevice& os, const MSEdge* const from, const MSEdge* const upTo = 0) const; 00094 00095 bool contains(const MSEdge* const edge) const { 00096 return std::find(myEdges.begin(), myEdges.end(), edge) != myEdges.end(); 00097 } 00098 00099 bool containsAnyOf(const std::vector<MSEdge*> &edgelist) const; 00100 00101 const MSEdge* operator[](unsigned index) const; 00102 00103 #ifdef HAVE_MESOSIM 00104 00105 00106 00111 static void dict_saveState(std::ostream& os) ; 00112 00113 00118 static void dict_loadState(BinaryInputDevice& bis) ; 00120 #endif 00121 00122 const MSEdgeVector& getEdges() const { 00123 return myEdges; 00124 } 00125 00126 SUMOReal getLength() const; 00127 00136 SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge* fromEdge, const MSEdge* toEdge) const; 00137 00139 const RGBColor& getColor() const; 00140 00142 const std::vector<SUMOVehicleParameter::Stop> &getStops() const; 00143 00144 public: 00154 static bool dictionary(const std::string& id, const MSRoute* route); 00155 00165 static bool dictionary(const std::string& id, RandomDistributor<const MSRoute*> *routeDist); 00166 00175 static const MSRoute* dictionary(const std::string& id); 00176 00184 static RandomDistributor<const MSRoute*> *distDictionary(const std::string& id); 00185 00187 static void clear(); 00188 00189 static void insertIDs(std::vector<std::string> &into); 00190 00191 00192 private: 00194 MSEdgeVector myEdges; 00195 00197 mutable unsigned int myReferenceCounter; 00198 00200 RGBColor myColor; 00201 00203 std::vector<SUMOVehicleParameter::Stop> myStops; 00204 00205 private: 00207 typedef std::map<std::string, const MSRoute*> RouteDict; 00208 00210 static RouteDict myDict; 00211 00213 typedef std::map<std::string, RandomDistributor<const MSRoute*>*> RouteDistDict; 00214 00216 static RouteDistDict myDistDict; 00217 00218 }; 00219 00220 00221 #endif 00222 00223 /****************************************************************************/ 00224