MSRoute.h
Go to the documentation of this file.00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef MSRoute_h
00020 #define MSRoute_h
00021
00022
00023
00024
00025
00026 #ifdef _MSC_VER
00027 #include <windows_config.h>
00028 #else
00029 #include <config.h>
00030 #endif
00031
00032 #include <string>
00033 #include <map>
00034 #include <vector>
00035 #include <utils/common/Named.h>
00036 #include <utils/common/RandomDistributor.h>
00037 #include <utils/common/RGBColor.h>
00038 #include <utils/common/SUMOVehicleParameter.h>
00039
00040
00041
00042
00043
00044 class MSEdge;
00045 class BinaryInputDevice;
00046 class OutputDevice;
00047
00048
00049 typedef std::vector<const MSEdge*> MSEdgeVector;
00050 typedef MSEdgeVector::const_iterator MSRouteIterator;
00051
00052
00053
00054
00055
00059 class MSRoute : public Named {
00060 public:
00062 MSRoute(const std::string &id, const MSEdgeVector &edges,
00063 bool multipleReferenced, const RGBColor &c,
00064 const std::vector<SUMOVehicleParameter::Stop> &stops) throw();
00065
00067 virtual ~MSRoute() throw();
00068
00070 MSRouteIterator begin() const;
00071
00073 MSRouteIterator end() const;
00074
00076 unsigned size() const;
00077
00079 const MSEdge *getLastEdge() const;
00080
00083 bool inFurtherUse() const;
00084
00086 void writeEdgeIDs(OutputDevice &os, const MSEdge *upTo=0) const;
00087
00088 bool contains(const MSEdge * const edge) const throw() {
00089 return find(edge)!=myEdges.end();
00090 }
00091
00092 bool containsAnyOf(const std::vector<MSEdge*> &edgelist) const;
00093
00094 const MSEdge *operator[](unsigned index) const;
00095
00096 #ifdef HAVE_MESOSIM
00099
00100
00104 static void dict_saveState(std::ostream &os) throw();
00105
00106
00111 static void dict_loadState(BinaryInputDevice &bis) throw();
00113 #endif
00114
00115 unsigned posInRoute(const MSRouteIterator ¤tEdge) const;
00116
00117 const MSEdgeVector &getEdges() const {
00118 return myEdges;
00119 }
00120
00121 SUMOReal getLength() const;
00122
00131 SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge* fromEdge, const MSEdge* toEdge) const;
00132
00134 const RGBColor &getColor() const;
00135
00137 const std::vector<SUMOVehicleParameter::Stop> &getStops() const;
00138
00139 public:
00149 static bool dictionary(const std::string &id, const MSRoute *route);
00150
00160 static bool dictionary(const std::string &id, RandomDistributor<const MSRoute*> *routeDist);
00161
00170 static const MSRoute *dictionary(const std::string &id);
00171
00179 static RandomDistributor<const MSRoute*> *distDictionary(const std::string &id);
00180
00182 static void clear();
00183
00185 static void erase(std::string id);
00186
00187 static void insertIDs(std::vector<std::string> &into);
00188
00189 MSRouteIterator find(const MSEdge *e) const;
00190 MSRouteIterator find(const MSEdge *e, const MSRouteIterator &startingAt) const;
00191
00192
00193 private:
00195 MSEdgeVector myEdges;
00196
00198 bool myMultipleReferenced;
00199
00201 RGBColor myColor;
00202
00204 std::vector<SUMOVehicleParameter::Stop> myStops;
00205
00206 private:
00208 typedef std::map<std::string, const MSRoute*> RouteDict;
00209
00211 static RouteDict myDict;
00212
00214 typedef std::map<std::string, RandomDistributor<const MSRoute*>*> RouteDistDict;
00215
00217 static RouteDistDict myDistDict;
00218
00219 };
00220
00221
00222 #endif
00223
00224
00225