SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ROEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
10 // A basic edge for routing applications
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 ROEdge_h
24 #define ROEdge_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>
43 #include "RONode.h"
44 #include "ROVehicle.h"
45 
46 
47 // ===========================================================================
48 // class declarations
49 // ===========================================================================
50 class ROLane;
51 class ROVehicle;
52 
53 
54 // ===========================================================================
55 // class definitions
56 // ===========================================================================
66 class ROEdge {
67 public:
72  enum EdgeType {
81  };
82 
83 
91  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index);
92 
93 
95  virtual ~ROEdge() ;
96 
97 
99 
100 
109  virtual void addLane(ROLane* lane) ;
110 
111 
119  virtual void addFollower(ROEdge* s, std::string dir="");
120 
121 
125  void setType(EdgeType type) ;
126 
127 
137  void buildTimeLines(const std::string& measure) ;
139 
140 
141 
143 
144 
148  const std::string& getID() const {
149  return myID;
150  }
151 
152 
157  EdgeType getType() const {
158  return myType;
159  }
160 
161 
165  SUMOReal getLength() const {
166  return myLength;
167  }
168 
172  unsigned int getNumericalID() const {
173  return myIndex;
174  }
175 
176 
180  SUMOReal getSpeed() const {
181  return mySpeed;
182  }
183 
184 
188  unsigned int getLaneNo() const {
189  return (unsigned int) myLanes.size();
190  }
191 
192 
196  RONode* getFromNode() const {
197  return myFromNode;
198  }
199 
200 
204  RONode* getToNode() const {
205  return myToNode;
206  }
207 
208 
214  bool isConnectedTo(const ROEdge* const e) const {
215  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
216  }
217 
218 
223  inline bool prohibits(const ROVehicle* const vehicle) const {
224  const SUMOVehicleClass vclass = vehicle->getVClass();
225  return (myCombinedPermissions & vclass) != vclass;
226  }
227 
229  return myCombinedPermissions;
230  }
231 
232 
237  bool allFollowersProhibit(const ROVehicle* const vehicle) const ;
239 
240 
241 
243 
244 
251  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd) ;
252 
253 
260  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd) ;
261 
262 
270  unsigned int getNoFollowing() const ;
271 
272 
277  ROEdge* getFollower(unsigned int pos) const {
278  return myFollowingEdges[pos];
279  }
280 
281 
282 #ifdef HAVE_MESOSIM // catchall for internal stuff
283 
290  unsigned int getNumApproaching() const ;
291 
292 
297  ROEdge* getApproaching(unsigned int pos) const {
298  return myApproachingEdges[pos];
299  }
300 #endif
301 
302 
310  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const ;
311 
312 
320  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const ;
321 
322 
328  SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const ;
329 
330 
331  SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const ;
332  SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const ;
333  SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const ;
334  SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const ;
335  SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const ;
336  SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const ;
337  SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const ;
339 
340 
342  SUMOReal getDistanceTo(const ROEdge* other) const;
343 
344 
346  static ROEdge* dictionary(size_t index) ;
347 
349  static size_t dictSize() {
350  return myEdges.size();
351  };
352 
353  static void setTimeLineOptions(
354  bool useBoundariesOnOverrideTT,
355  bool useBoundariesOnOverrideE,
356  bool interpolate) {
357  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
358  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
359  myInterpolate = interpolate;
360  }
361 
362 
363 protected:
370  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const ;
371 
372 
373 
374 protected:
376  std::string myID;
377 
380 
382  unsigned int myIndex;
383 
386 
387 
394 
401 
403  static bool myInterpolate;
404 
406  static bool myHaveEWarned;
408  static bool myHaveTTWarned;
409 
411  std::vector<ROEdge*> myFollowingEdges;
412 
413 #ifdef HAVE_MESOSIM // catchall for internal stuff
414 
415  std::vector<ROEdge*> myApproachingEdges;
416 #endif
417 
420 
422  std::vector<ROLane*> myLanes;
423 
426 
429 
430  static std::vector<ROEdge*> myEdges;
431 
432 private:
434  ROEdge(const ROEdge& src);
435 
437  ROEdge& operator=(const ROEdge& src);
438 
439 };
440 
441 
442 #endif
443 
444 /****************************************************************************/
445