|
SUMO - Simulation of Urban MObility
|
00001 /****************************************************************************/ 00008 // The dijkstra-router 00009 /****************************************************************************/ 00010 // SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/ 00011 // Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors 00012 /****************************************************************************/ 00013 // 00014 // This file is part of SUMO. 00015 // SUMO is free software: you can redistribute it and/or modify 00016 // it under the terms of the GNU General Public License as published by 00017 // the Free Software Foundation, either version 3 of the License, or 00018 // (at your option) any later version. 00019 // 00020 /****************************************************************************/ 00021 #ifndef SUMOAbstractRouter_h 00022 #define SUMOAbstractRouter_h 00023 00024 00025 // =========================================================================== 00026 // included modules 00027 // =========================================================================== 00028 #ifdef _MSC_VER 00029 #include <windows_config.h> 00030 #else 00031 #include <config.h> 00032 #endif 00033 00034 #include <string> 00035 #include <vector> 00036 #include <algorithm> 00037 #include <utils/common/SUMOTime.h> 00038 00039 00040 // =========================================================================== 00041 // class definitions 00042 // =========================================================================== 00047 template<class E, class V> 00048 class SUMOAbstractRouter { 00049 public: 00054 class ROAbstractEdgeEffortRetriever { 00055 public: 00057 ROAbstractEdgeEffortRetriever() { } 00058 00060 virtual ~ROAbstractEdgeEffortRetriever() { } 00061 00063 virtual SUMOReal getEffort(const V* const, SUMOTime time, const E* const edge, 00064 SUMOReal dist) const = 0; 00065 00067 virtual const std::string& getID() const = 0; 00068 00069 }; 00070 00071 00072 public: 00074 SUMOAbstractRouter() { } 00075 00077 virtual ~SUMOAbstractRouter() { } 00078 00081 virtual void compute(const E* from, const E* to, const V* const vehicle, 00082 SUMOTime msTime, std::vector<const E*> &into) = 0; 00083 00084 virtual SUMOReal recomputeCosts(const std::vector<const E*> &edges, 00085 const V* const v, SUMOTime msTime) const = 0; 00086 00087 }; 00088 00089 00090 template<class E, class V> 00091 struct prohibited_withRestrictions { 00092 public: 00093 inline bool operator()(const E* edge, const V* vehicle) const { 00094 if (std::find(myProhibited.begin(), myProhibited.end(), edge) != myProhibited.end()) { 00095 return true; 00096 } 00097 return edge->prohibits(vehicle); 00098 } 00099 00100 void prohibit(const std::vector<E*> &toProhibit) { 00101 myProhibited = toProhibit; 00102 } 00103 00104 protected: 00105 std::vector<E*> myProhibited; 00106 00107 }; 00108 00109 template<class E, class V> 00110 struct prohibited_noRestrictions { 00111 public: 00112 inline bool operator()(const E*, const V*) const { 00113 return false; 00114 } 00115 }; 00116 00117 00118 00119 00120 #endif 00121 00122 /****************************************************************************/ 00123