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-2013 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>
40 #include <utils/common/Named.h>
44 #include "RONode.h"
45 #include "ROVehicle.h"
46 
47 
48 // ===========================================================================
49 // class declarations
50 // ===========================================================================
51 class ROLane;
52 class ROVehicle;
53 
54 
55 // ===========================================================================
56 // class definitions
57 // ===========================================================================
67 class ROEdge : public Named {
68 public:
73  enum EdgeType {
82  };
83 
84 
92  ROEdge(const std::string& id, RONode* from, RONode* to, unsigned int index, const int priority);
93 
94 
96  virtual ~ROEdge();
97 
98 
100 
101 
110  virtual void addLane(ROLane* lane);
111 
112 
120  virtual void addFollower(ROEdge* s, std::string dir = "");
121 
122 
126  void setType(EdgeType type);
127 
128 
138  void buildTimeLines(const std::string& measure);
140 
141 
142 
144 
145 
150  EdgeType getType() const {
151  return myType;
152  }
153 
154 
158  SUMOReal getLength() const {
159  return myLength;
160  }
161 
165  unsigned int getNumericalID() const {
166  return myIndex;
167  }
168 
169 
173  SUMOReal getSpeed() const {
174  return mySpeed;
175  }
176 
177 
181  unsigned int getLaneNo() const {
182  return (unsigned int) myLanes.size();
183  }
184 
185 
189  RONode* getFromNode() const {
190  return myFromNode;
191  }
192 
193 
197  RONode* getToNode() const {
198  return myToNode;
199  }
200 
201 
207  bool isConnectedTo(const ROEdge* const e) const {
208  return std::find(myFollowingEdges.begin(), myFollowingEdges.end(), e) != myFollowingEdges.end();
209  }
210 
211 
216  inline bool prohibits(const ROVehicle* const vehicle) const {
217  const SUMOVehicleClass vclass = vehicle->getVClass();
218  return (myCombinedPermissions & vclass) != vclass;
219  }
220 
222  return myCombinedPermissions;
223  }
224 
225 
230  bool allFollowersProhibit(const ROVehicle* const vehicle) const;
232 
233 
234 
236 
237 
244  void addEffort(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
245 
246 
253  void addTravelTime(SUMOReal value, SUMOReal timeBegin, SUMOReal timeEnd);
254 
255 
263  unsigned int getNoFollowing() const;
264 
265 
270  ROEdge* getFollower(unsigned int pos) const {
271  return myFollowingEdges[pos];
272  }
273 
274 
275 #ifdef HAVE_INTERNAL // catchall for internal stuff
276 
283  unsigned int getNumApproaching() const;
284 
285 
290  ROEdge* getApproaching(unsigned int pos) const {
291  return myApproachingEdges[pos];
292  }
293 #endif
294 
295 
303  SUMOReal getEffort(const ROVehicle* const veh, SUMOReal time) const;
304 
305 
312  SUMOReal getTravelTime(const ROVehicle* const veh, SUMOReal time) const;
313 
314 
321  SUMOReal getTravelTime(const SUMOReal maxSpeed, SUMOReal time) const;
322 
323 
329  SUMOReal getMinimumTravelTime(const ROVehicle* const veh) const;
330 
331 
332  SUMOReal getCOEffort(const ROVehicle* const veh, SUMOReal time) const;
333  SUMOReal getCO2Effort(const ROVehicle* const veh, SUMOReal time) const;
334  SUMOReal getPMxEffort(const ROVehicle* const veh, SUMOReal time) const;
335  SUMOReal getHCEffort(const ROVehicle* const veh, SUMOReal time) const;
336  SUMOReal getNOxEffort(const ROVehicle* const veh, SUMOReal time) const;
337  SUMOReal getFuelEffort(const ROVehicle* const veh, SUMOReal time) const;
338  SUMOReal getNoiseEffort(const ROVehicle* const veh, SUMOReal time) const;
340 
341 
343  SUMOReal getDistanceTo(const ROEdge* other) const;
344 
345 
347  static ROEdge* dictionary(size_t index);
348 
350  static size_t dictSize() {
351  return myEdges.size();
352  };
353 
354  static void setTimeLineOptions(
355  bool useBoundariesOnOverrideTT,
356  bool useBoundariesOnOverrideE,
357  bool interpolate) {
358  myUseBoundariesOnOverrideTT = useBoundariesOnOverrideTT;
359  myUseBoundariesOnOverrideE = useBoundariesOnOverrideE;
360  myInterpolate = interpolate;
361  }
362 
364  int getPriority() const {
365  return myPriority;
366  }
367 
368 protected:
375  bool getStoredEffort(SUMOReal time, SUMOReal& ret) const;
376 
377 
378 
379 protected:
381  RONode* const myFromNode, * const myToNode;
382 
384  const unsigned int myIndex;
385 
387  const int myPriority;
388 
391 
394 
395 
402 
409 
411  static bool myInterpolate;
412 
414  static bool myHaveEWarned;
416  static bool myHaveTTWarned;
417 
419  std::vector<ROEdge*> myFollowingEdges;
420 
421 #ifdef HAVE_INTERNAL // catchall for internal stuff
422 
423  std::vector<ROEdge*> myApproachingEdges;
424 #endif
425 
428 
430  std::vector<ROLane*> myLanes;
431 
434 
435  static std::vector<ROEdge*> myEdges;
436 
437 
438 private:
445  SUMOReal getTravelTime(SUMOReal time) const;
446 
447 private:
449  ROEdge(const ROEdge& src);
450 
452  ROEdge& operator=(const ROEdge& src);
453 
454 };
455 
456 
457 #endif
458 
459 /****************************************************************************/
460