SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
MSEdge.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A road/street connecting two junctions
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
14 // Copyright (C) 2001-2012 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 MSEdge_h
25 #define MSEdge_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 <vector>
38 #include <map>
39 #include <string>
40 #include <iostream>
41 #include <utils/common/SUMOTime.h>
46 #include "MSVehicleType.h"
47 
48 
49 // ===========================================================================
50 // class declarations
51 // ===========================================================================
52 class MSLaneChanger;
53 class OutputDevice;
54 class SUMOVehicle;
56 class MSVehicle;
57 class MSLane;
58 
59 
60 // ===========================================================================
61 // class definitions
62 // ===========================================================================
70 class MSEdge {
71 public:
90  };
91 
92 
94  typedef std::map< const MSEdge*, std::vector<MSLane*>* > AllowedLanesCont;
95 
97  typedef std::map< SUMOVehicleClass, AllowedLanesCont > ClassedAllowedLanesCont;
98 
99 
100 public:
111  MSEdge(const std::string& id, unsigned int numericalID, const std::string& streetName = "") ;
112 
113 
115  virtual ~MSEdge() ;
116 
117 
124  void initialize(std::vector<MSLane*>* lanes, EdgeBasicFunction function) ;
125 
126 
128  void closeBuilding();
129 
130 
133 
140  MSLane* leftLane(const MSLane* const lane) const ;
141 
142 
149  MSLane* rightLane(const MSLane* const lane) const ;
150 
151 
156  const std::vector<MSLane*> &getLanes() const {
157  return *myLanes;
158  }
159 
160 
169  const std::vector<MSLane*>* allowedLanes(const MSEdge& destination,
170  SUMOVehicleClass vclass = SVC_UNKNOWN) const ;
171 
172 
180  const std::vector<MSLane*>* allowedLanes(SUMOVehicleClass vclass = SVC_UNKNOWN) const ;
182 
183 
184 
187 
191  const std::string& getID() const {
192  return myID;
193  }
194 
195 
201  return myFunction;
202  }
203 
204 
208  unsigned int getNumericalID() const {
209  return myNumericalID;
210  }
211 
212 
215  const std::string& getStreetName() const {
216  return myStreetName;
217  }
219 
220 
221 
224 
228  void addFollower(MSEdge* edge) {
229  mySuccessors.push_back(edge);
230  }
231 
232 
236  const std::vector<MSEdge*> &getIncomingEdges() const {
237  return myPredeccesors;
238  }
239 
240 
244  unsigned int getNoFollowing() const {
245  return (unsigned int) mySuccessors.size();
246  }
247 
252  const MSEdge* getFollower(unsigned int n) const {
253  return mySuccessors[n];
254  }
256 
257 
258 
261 
265  bool isVaporizing() const {
266  return myVaporizationRequests > 0;
267  }
268 
269 
280 
281 
293 
294 
304 
305 
306 
309 
323  bool insertVehicle(SUMOVehicle& v, SUMOTime time) const ;
324 
325 
340  MSLane* getFreeLane(const std::vector<MSLane*>* allowed, const SUMOVehicleClass vclass) const ;
341 
342 
353  MSLane* getDepartLane(const MSVehicle& veh) const ;
354 
355 
361  }
362 
363 
367  inline void setLastFailedInsertionTime(SUMOTime time) const {
369  }
371 
372 
374  virtual void changeLanes(SUMOTime t) ;
375 
376 
377 #ifdef HAVE_INTERNAL_LANES
378 
379  const MSEdge* getInternalFollowingEdge(MSEdge* followerAfterInternal) const ;
380 #endif
381 
383  inline bool prohibits(const SUMOVehicle* const vehicle) const {
384  const SUMOVehicleClass svc = vehicle->getVehicleType().getVehicleClass();
385  return (myCombinedPermissions & svc) != svc;
386  }
387 
388  void rebuildAllowedLanes();
389 
390 
392  SUMOReal getDistanceTo(const MSEdge* other) const;
393 
394 
396  SUMOReal getLength() const;
397 
399  SUMOReal getMaxSpeed() const;
400 
404  static bool dictionary(const std::string& id, MSEdge* edge) ;
405 
407  static MSEdge* dictionary(const std::string& id) ;
408 
410  static MSEdge* dictionary(size_t index) ;
411 
413  static size_t dictSize() ;
414 
416  static void clear() ;
417 
419  static void insertIDs(std::vector<std::string> &into) ;
420 
421 
422 public:
425 
434  static void parseEdgesList(const std::string& desc, std::vector<const MSEdge*> &into,
435  const std::string& rid) ;
436 
437 
444  static void parseEdgesList(const std::vector<std::string> &desc, std::vector<const MSEdge*> &into,
445  const std::string& rid) ;
447 
448 
449 protected:
453  class by_id_sorter {
454  public:
456  explicit by_id_sorter() { }
457 
459  int operator()(const MSEdge* const e1, const MSEdge* const e2) const {
460  return e1->getID() < e2->getID();
461  }
462 
463  };
464 
465 
474  const std::vector<MSLane*>* allowedLanes(const MSEdge* destination,
475  SUMOVehicleClass vclass = SVC_UNKNOWN) const ;
476 
477 
479  const std::vector<MSLane*>* getAllowedLanesWithDefault(const AllowedLanesCont& c, const MSEdge* dest) const;
480 
481 protected:
483  std::string myID;
484 
486  unsigned int myNumericalID;
487 
489  std::vector<MSLane*>* myLanes;
490 
493 
496 
499 
502 
504  std::vector<MSEdge*> mySuccessors;
505 
507  std::vector<MSEdge*> myPredeccesors;
508 
509 
510 
513 
516 
518  // @note: this map is filled on demand
520 
525 
526  std::string myStreetName;
528 
529 
530 
533 
535  typedef std::map< std::string, MSEdge* > DictType;
536 
540  static DictType myDict;
541 
545  static std::vector<MSEdge*> myEdges;
547 
548 
549 
550 private:
552  MSEdge(const MSEdge&);
553 
555  MSEdge& operator=(const MSEdge&);
556 
557 };
558 
559 
560 #endif
561 
562 /****************************************************************************/
563