1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file NLEdgeControlBuilder.h 11 /// @author Daniel Krajzewicz 12 /// @author Jakob Erdmann 13 /// @author Michael Behrisch 14 /// @author Leonhard Luecken 15 /// @date Mon, 9 Jul 2001 16 /// @version $Id$ 17 /// 18 // Interface for building edges 19 /****************************************************************************/ 20 #ifndef NLEdgeControlBuilder_h 21 #define NLEdgeControlBuilder_h 22 23 24 // =========================================================================== 25 // included modules 26 // =========================================================================== 27 #include <config.h> 28 29 #include <string> 30 #include <vector> 31 #include <microsim/MSEdge.h> 32 #include <utils/geom/PositionVector.h> 33 34 35 // =========================================================================== 36 // class declarations 37 // =========================================================================== 38 class MSEdgeControl; 39 class MSLane; 40 class MSNet; 41 class OutputDevice; 42 43 44 // =========================================================================== 45 // class definitions 46 // =========================================================================== 47 /** 48 * @class NLEdgeControlBuilder 49 * @brief Interface for building edges 50 * 51 * This class is the container for MSEdge-instances while they are build. 52 * 53 * While building instances of MSEdge, these are stored in a list. The list of 54 * edges is later split into two lists, one containing single-lane-edges and 55 * one containing multi-lane-edges. 56 * @todo Assignment of lanes is not really well. Should be reworked after shapes are given as params. 57 */ 58 class NLEdgeControlBuilder { 59 60 public: 61 /// @brief Constructor 62 NLEdgeControlBuilder(); 63 64 65 /// @brief Destructor 66 virtual ~NLEdgeControlBuilder(); 67 68 69 /** @brief Begins building of an MSEdge 70 * 71 * Builds an instance of MSEdge using "buildEdge". Stores it 72 * as the current edge in "myActiveEdge" and appends it to the list 73 * of built edges ("myEdges"). 74 * 75 * The given information is used to build the edge. 76 * @param[in] id The id of the edge 77 * @param[in] function The function of the edge 78 * @param[in] streetName The street name of the edge 79 * @exception InvalidArgument If an edge with the same name was already built 80 */ 81 void beginEdgeParsing(const std::string& id, const SumoXMLEdgeFunc function, 82 const std::string& streetName, const std::string& edgeType, 83 int priority, 84 const std::string& bidi); 85 86 87 /** @brief Adds a lane to the current edge 88 * 89 * @param[in] id The lane's id 90 * @param[in] maxSpeed The speed allowed on this lane 91 * @param[in] length The lane's length 92 * @param[in] shape The shape of the lane 93 * @param[in] width The width of the lane 94 * @param[in] permissions Encoding of vehicle classes that may drive on this lane 95 * @param[in] index The index of this lane within its parent edge 96 * @see SUMOVehicleClass 97 * @see MSLane 98 * @todo Definitely not a good way 99 */ 100 virtual MSLane* addLane(const std::string& id, double maxSpeed, 101 double length, const PositionVector& shape, 102 double width, 103 SVCPermissions permissions, int index, bool isRampAccel); 104 105 /** @brief process a stopOffset element (originates either from the active edge or lane). 106 */ 107 void addStopOffsets(const std::map<SVCPermissions, double>& stopOffsets); 108 109 110 /** @brief Return info about currently processed edge or lane 111 */ 112 std::string reportCurrentEdgeOrLane() const; 113 114 115 /** @brief Adds a neighbor to the current lane 116 * 117 * @param[in] id The lane's id 118 * @see MSLane 119 */ 120 virtual void addNeigh(const std::string id); 121 122 123 /** @brief Closes the building of an edge; 124 The edge is completely described by now and may not be opened again */ 125 virtual MSEdge* closeEdge(); 126 127 /** @brief Closes the building of a lane; 128 The edge is completely described by now and may not be opened again */ 129 void closeLane(); 130 131 /// builds the MSEdgeControl-class which holds all edges 132 MSEdgeControl* build(double networkVersion); 133 134 135 /** @brief Builds an edge instance (MSEdge in this case) 136 * 137 * Builds an MSEdge-instance using the given name and the current index 138 * "myCurrentNumericalEdgeID". Post-increments the index, returns 139 * the built edge. 140 * 141 * @param[in] id The id of the edge to build 142 * @param[in] streetName The street name of the edge to build 143 */ 144 virtual MSEdge* buildEdge(const std::string& id, const SumoXMLEdgeFunc function, 145 const std::string& streetName, const std::string& edgeType, const int priority); 146 147 /** @brief add the crossingEdges in a crossing edge if present 148 * 149 * @param[in] the vector of crossed edges id 150 */ 151 virtual void addCrossingEdges(const std::vector<std::string>&); 152 153 protected: 154 /// @brief A running number for lane numbering 155 int myCurrentNumericalLaneID; 156 157 /// @brief A running number for edge numbering 158 int myCurrentNumericalEdgeID; 159 160 /// @brief Temporary, internal storage for built edges 161 MSEdgeVector myEdges; 162 163 /// @brief pointer to the currently chosen edge 164 MSEdge* myActiveEdge; 165 166 /// @brief The default stop offset for all lanes belonging to the active edge (this is set if the edge was given a stopOffset child) 167 std::map<SVCPermissions, double> myCurrentDefaultStopOffsets; 168 169 /// @brief The index of the currently active lane (-1 if none is active) 170 int myCurrentLaneIndex; 171 172 /// @brief pointer to a temporary lane storage 173 std::vector<MSLane*>* myLaneStorage; 174 175 /// @brief temporary storage for bidi attributes (to be resolved after loading all edges) 176 std::map<MSEdge*, std::string> myBidiEdges; 177 178 179 /** @brief set the stopOffset for the last added lane. 180 */ 181 void updateCurrentLaneStopOffsets(const std::map<SVCPermissions, double>& stopOffsets); 182 183 /** @brief set the stopOffset for the last added lane. 184 */ 185 void setDefaultStopOffsets(std::map<SVCPermissions, double> stopOffsets); 186 187 /** @brief 188 */ 189 void applyDefaultStopOffsetsToLanes(); 190 191 private: 192 /// @brief invalidated copy constructor 193 NLEdgeControlBuilder(const NLEdgeControlBuilder& s); 194 195 /// @brief invalidated assignment operator 196 NLEdgeControlBuilder& operator=(const NLEdgeControlBuilder& s); 197 198 }; 199 200 201 #endif 202 203 /****************************************************************************/ 204 205