SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSRoute.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A vehicle route
11 /****************************************************************************/
12 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14 /****************************************************************************/
15 //
16 // This file is part of SUMO.
17 // SUMO is free software: you can redistribute it and/or modify
18 // it under the terms of the GNU General Public License as published by
19 // the Free Software Foundation, either version 3 of the License, or
20 // (at your option) any later version.
21 //
22 /****************************************************************************/
23 #ifndef MSRoute_h
24 #define MSRoute_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <string>
37 #include <map>
38 #include <vector>
39 #include <algorithm>
40 #include <utils/common/Named.h>
42 #include <utils/common/RGBColor.h>
44 
45 
46 // ===========================================================================
47 // class declarations
48 // ===========================================================================
49 class MSEdge;
50 class BinaryInputDevice;
52 
53 
54 typedef std::vector<const MSEdge*> MSEdgeVector;
55 typedef MSEdgeVector::const_iterator MSRouteIterator;
56 
57 
58 // ===========================================================================
59 // class definitions
60 // ===========================================================================
64 class MSRoute : public Named {
65 public:
67  MSRoute(const std::string& id, const MSEdgeVector& edges,
68  unsigned int references, const RGBColor* const c,
69  const std::vector<SUMOVehicleParameter::Stop>& stops);
70 
72  virtual ~MSRoute();
73 
75  MSRouteIterator begin() const;
76 
78  MSRouteIterator end() const;
79 
81  unsigned size() const;
82 
84  const MSEdge* getLastEdge() const;
85 
87  void addReference() const;
88 
90  void release() const;
91 
98  int writeEdgeIDs(OutputDevice& os, const MSEdge* const from, const MSEdge* const upTo = 0) const;
99 
100  bool contains(const MSEdge* const edge) const {
101  return std::find(myEdges.begin(), myEdges.end(), edge) != myEdges.end();
102  }
103 
104  bool containsAnyOf(const std::vector<MSEdge*>& edgelist) const;
105 
106  const MSEdge* operator[](unsigned index) const;
107 
108 #ifdef HAVE_INTERNAL
109 
110 
111 
116  static void dict_saveState(std::ostream& os);
117 
118 
123  static void dict_loadState(BinaryInputDevice& bis);
125 #endif
126 
127  const MSEdgeVector& getEdges() const {
128  return myEdges;
129  }
130 
131  SUMOReal getLength() const;
132 
141  SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge* fromEdge, const MSEdge* toEdge) const;
142 
144  const RGBColor& getColor() const;
145 
147  const std::vector<SUMOVehicleParameter::Stop>& getStops() const;
148 
149 public:
159  static bool dictionary(const std::string& id, const MSRoute* route);
160 
170  static bool dictionary(const std::string& id, RandomDistributor<const MSRoute*>* routeDist);
171 
180  static const MSRoute* dictionary(const std::string& id);
181 
189  static RandomDistributor<const MSRoute*>* distDictionary(const std::string& id);
190 
192  static void clear();
193 
194  static void insertIDs(std::vector<std::string>& into);
195 
197  static void releaseRoute(const MSRoute* route) {
198  route->release();
199  }
200 
201  static void setMaxRouteDistSize(unsigned int size) {
203  }
204 
205  static unsigned int getMaxRouteDistSize() {
206  return MaxRouteDistSize;
207  }
208 
209 private:
212 
214  mutable unsigned int myReferenceCounter;
215 
217  const RGBColor* const myColor;
218 
220  std::vector<SUMOVehicleParameter::Stop> myStops;
221 
222 private:
224  typedef std::map<std::string, const MSRoute*> RouteDict;
225 
228 
230  typedef std::map<std::string, RandomDistributor<const MSRoute*>*> RouteDistDict;
231 
234 
236  static unsigned int MaxRouteDistSize;
237 
238 private:
240  MSRoute& operator=(const MSRoute& s);
241 
242 };
243 
244 
245 #endif
246 
247 /****************************************************************************/
248