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 /****************************************************************************/
11 // A vehicle route
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
14 // Copyright (C) 2002-2014 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSRoute_h
25 #define MSRoute_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <string>
38 #include <map>
39 #include <vector>
40 #include <algorithm>
41 #include <utils/common/Named.h>
43 #include <utils/common/RGBColor.h>
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class MSEdge;
52 class BinaryInputDevice;
54 
55 
56 // ===========================================================================
57 // types definitions
58 // ===========================================================================
59 typedef std::vector<const MSEdge*> MSEdgeVector;
60 typedef MSEdgeVector::const_iterator MSRouteIterator;
61 
62 
63 // ===========================================================================
64 // class definitions
65 // ===========================================================================
69 class MSRoute : public Named, public Parameterised {
70 public:
72  MSRoute(const std::string& id, const MSEdgeVector& edges,
73  const bool isPermanent, const RGBColor* const c,
74  const std::vector<SUMOVehicleParameter::Stop>& stops);
75 
77  virtual ~MSRoute();
78 
80  MSRouteIterator begin() const;
81 
83  MSRouteIterator end() const;
84 
86  unsigned size() const;
87 
89  const MSEdge* getLastEdge() const;
90 
92  void addReference() const;
93 
95  void release() const;
96 
103  int writeEdgeIDs(OutputDevice& os, const MSEdge* const from, const MSEdge* const upTo = 0) const;
104 
105  bool contains(const MSEdge* const edge) const {
106  return std::find(myEdges.begin(), myEdges.end(), edge) != myEdges.end();
107  }
108 
109  bool containsAnyOf(const std::vector<MSEdge*>& edgelist) const;
110 
111  const MSEdge* operator[](unsigned index) const;
112 
115 
120  static void dict_saveState(OutputDevice& out);
122 
123  const MSEdgeVector& getEdges() const {
124  return myEdges;
125  }
126 
127  SUMOReal getLength() const;
128 
137  SUMOReal getDistanceBetween(SUMOReal fromPos, SUMOReal toPos, const MSEdge* fromEdge, const MSEdge* toEdge) const;
138 
140  const RGBColor& getColor() const;
141 
143  const std::vector<SUMOVehicleParameter::Stop>& getStops() const;
144 
145 public:
155  static bool dictionary(const std::string& id, const MSRoute* route);
156 
167  static bool dictionary(const std::string& id, RandomDistributor<const MSRoute*>* const routeDist, const bool permanent = true);
168 
177  static const MSRoute* dictionary(const std::string& id);
178 
186  static RandomDistributor<const MSRoute*>* distDictionary(const std::string& id);
187 
189  static void clear();
190 
192  static void checkDist(const std::string& id);
193 
194  static void insertIDs(std::vector<std::string>& into);
195 
196 private:
199 
201  const bool myAmPermanent;
202 
204  mutable unsigned int myReferenceCounter;
205 
207  const RGBColor* const myColor;
208 
210  std::vector<SUMOVehicleParameter::Stop> myStops;
211 
212 private:
214  typedef std::map<std::string, const MSRoute*> RouteDict;
215 
218 
220  typedef std::map<std::string, std::pair<RandomDistributor<const MSRoute*>*, bool> > RouteDistDict;
221 
224 
225 private:
227  MSRoute& operator=(const MSRoute& s);
228 
229 };
230 
231 
232 #endif
233 
234 /****************************************************************************/
235