SUMO - Simulation of Urban MObility

MSRoute.h

Go to the documentation of this file.
00001 /****************************************************************************/
00007 // A vehicle route
00008 /****************************************************************************/
00009 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
00010 // Copyright (C) 2001-2011 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 #ifndef MSRoute_h
00020 #define MSRoute_h
00021 
00022 
00023 // ===========================================================================
00024 // included modules
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 <algorithm>
00036 #include <utils/common/Named.h>
00037 #include <utils/common/RandomDistributor.h>
00038 #include <utils/common/RGBColor.h>
00039 #include <utils/common/SUMOVehicleParameter.h>
00040 
00041 
00042 // ===========================================================================
00043 // class declarations
00044 // ===========================================================================
00045 class MSEdge;
00046 class BinaryInputDevice;
00047 class OutputDevice;
00048 
00049 
00050 typedef std::vector<const MSEdge*> MSEdgeVector;
00051 typedef MSEdgeVector::const_iterator MSRouteIterator;
00052 
00053 
00054 // ===========================================================================
00055 // class definitions
00056 // ===========================================================================
00060 class MSRoute : public Named {
00061 public:
00063     MSRoute(const std::string& id, const MSEdgeVector& edges,
00064             unsigned int references, const RGBColor& c,
00065             const std::vector<SUMOVehicleParameter::Stop> &stops) throw();
00066 
00068     virtual ~MSRoute() throw();
00069 
00071     MSRouteIterator begin() const;
00072 
00074     MSRouteIterator end() const;
00075 
00077     unsigned size() const;
00078 
00080     const MSEdge* getLastEdge() const;
00081 
00083     void addReference() const;
00084 
00086     void release() const;
00087 
00089     void writeEdgeIDs(OutputDevice& os, const MSEdge* const from, const MSEdge* const upTo=0) const;
00090 
00091     bool contains(const MSEdge* const edge) const throw() {
00092         return std::find(myEdges.begin(), myEdges.end(), edge) != myEdges.end();
00093     }
00094 
00095     bool containsAnyOf(const std::vector<MSEdge*> &edgelist) const;
00096 
00097     const MSEdge* operator[](unsigned index) const;
00098 
00099 #ifdef HAVE_MESOSIM
00100 
00101 
00102 
00107     static void dict_saveState(std::ostream& os) throw();
00108 
00109 
00114     static void dict_loadState(BinaryInputDevice& bis) throw();
00116 #endif
00117 
00118     const MSEdgeVector& getEdges() const {
00119         return myEdges;
00120     }
00121 
00122     SUMOReal getLength() const;
00123 
00132     SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge* fromEdge, const MSEdge* toEdge) const;
00133 
00135     const RGBColor& getColor() const;
00136 
00138     const std::vector<SUMOVehicleParameter::Stop> &getStops() const;
00139 
00140 public:
00150     static bool dictionary(const std::string& id, const MSRoute* route);
00151 
00161     static bool dictionary(const std::string& id, RandomDistributor<const MSRoute*> *routeDist);
00162 
00171     static const MSRoute* dictionary(const std::string& id);
00172 
00180     static RandomDistributor<const MSRoute*> *distDictionary(const std::string& id);
00181 
00183     static void clear();
00184 
00185     static void insertIDs(std::vector<std::string> &into);
00186 
00187 
00188 private:
00190     MSEdgeVector myEdges;
00191 
00193     mutable unsigned int myReferenceCounter;
00194 
00196     RGBColor myColor;
00197 
00199     std::vector<SUMOVehicleParameter::Stop> myStops;
00200 
00201 private:
00203     typedef std::map<std::string, const MSRoute*> RouteDict;
00204 
00206     static RouteDict myDict;
00207 
00209     typedef std::map<std::string, RandomDistributor<const MSRoute*>*> RouteDistDict;
00210 
00212     static RouteDistDict myDistDict;
00213 
00214 };
00215 
00216 
00217 #endif
00218 
00219 /****************************************************************************/
00220 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines