/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file NIXMLConnectionsHandler.h14/// @author Daniel Krajzewicz15/// @author Jakob Erdmann16/// @author Michael Behrisch17/// @date Tue, 20 Nov 200118///19// Importer for edge connections stored in XML20/****************************************************************************/21#pragma once22#include <config.h>2324#include <utils/xml/SUMOSAXHandler.h>25#include <netbuild/NBConnection.h>262728// ===========================================================================29// class declarations30// ===========================================================================31class NBEdge;32class NBEdgeCont;33class NBNodeCont;34class NBTrafficLightLogicCont;35class MsgHandler;36class GeoConvHelper;373839// ===========================================================================40// class definitions41// ===========================================================================42/**43* @class NIXMLConnectionsHandler44* @brief Importer for edge connections stored in XML45*46* This importer parses connections, and prohibitions, and is able47* to reset connections between edges.48*/49class NIXMLConnectionsHandler : public SUMOSAXHandler {50public:51/** @brief Constructor52* @param[in] ec The edge container which includes the edges to change connections of53*/54NIXMLConnectionsHandler(NBEdgeCont& ec, NBNodeCont& nc, NBTrafficLightLogicCont& tlc);555657/// @brief Destructor58~NIXMLConnectionsHandler();596061protected:62/// @name inherited from GenericSAXHandler63//@{6465/** @brief Called on the opening of a tag;66*67* @param[in] element ID of the currently opened element68* @param[in] attrs Attributes within the currently opened element69* @exception ProcessError If something fails70* @see GenericSAXHandler::myStartElement71*/72void myStartElement(int element,73const SUMOSAXAttributes& attrs);7475/** @brief Called when a closing tag occurs76*77* @param[in] element ID of the currently opened element78* @exception ProcessError If something fails79* @see GenericSAXHandler::myEndElement80*/81void myEndElement(int element);82//@}8384private:85/** @brief Returns the connection described by def86*87* def should have the following format <FROM_EDGE_ID>[_<FROM_LANE_NO>]-><TO_EDGE_ID>[_<TO_LANE_NO>].88*89* @param[in] defRole "prohibitor" or "prohibited" - used for error reporting90* @param[in] def The definition of the connection91* @return The parsed connection92*/93NBConnection parseConnectionDef(const std::string& defRole, const std::string& def);949596/** @brief Parses a connection when it describes a lane-2-lane relationship97* @param[in] attrs The attributes to get further information about the connection from98* @param[in] from The edge at which the connection starts (the on incoming into a node)99* @param[in] to The edge at which the connection ends (the on outgoing from a node)100*/101void parseLaneBound(const SUMOSAXAttributes& attrs, NBEdge* from, NBEdge* to);102103104/** @brief Parses information about lane-2-lane connection when it describes a lane-2-lane relationship105* @param[in] attrs The attributes to get further information about the connection from106* @param[in] fromEdge The edge at which the connection starts (the on incoming into a node)107* @param[in] toEdge The edge at which the connection ends (the on outgoing from a node)108* @param[out] fromLane The lane at which connection starts109* @param[out] toLane The lane at which connection ends110*/111bool parseLaneInfo(const SUMOSAXAttributes& attributes, NBEdge* fromEdge, NBEdge* toEdge, int* fromLane, int* toLane);112113114/** @brief Parses information about lane-2-lane connection in deprecated format.115* @param[in] attrs The attributes to get further information about the connection from116* @param[in] fromEdge The edge at which the connection starts (the on incoming into a node)117* @param[in] toEdge The edge at which the connection ends (the on outgoing from a node)118* @param[out] fromLane The lane at which connection starts119* @param[out] toLane The lane at which connection ends120*/121inline bool parseDeprecatedLaneDefinition(const SUMOSAXAttributes& attributes,122NBEdge* fromEdge, NBEdge* toEdge,123int* fromLane, int* toLane);124125126/** @brief Parses information about lane-2-lane connection.127* @param[in] attrs The attributes to get further information about the connection from128* @param[out] fromLane The lane at which connection starts129* @param[out] toLane The lane at which connection ends130*/131inline bool parseLaneDefinition(const SUMOSAXAttributes& attributes, int* fromLane, int* toLane);132133/** @brief Parses a delete element that specifies a connection to delete134* @param[in] attrs The attributes to get the deleted connections values from135*/136void delConnection(const SUMOSAXAttributes& attrs);137138/** @brief Parses a connection and adds it to the referenced edge139* @param[in] attrs The attributes to get the connections's values from140*/141void parseConnection(const SUMOSAXAttributes& attrs);142143/** @brief Parses a crossing and updates the referenced node144* @param[in] attrs The attributes to get the crossings's values from145*/146void addCrossing(const SUMOSAXAttributes& attrs);147148/** @brief Parses a walkingArea and updates the referenced node149* @param[in] attrs The attributes to get the crossings's values from150*/151void addWalkingArea(const SUMOSAXAttributes& attrs);152153/** @brief Parses a prohibition and updates the referenced node154* @param[in] attrs The attributes to get the prohibition's values from155*/156void addProhibition(const SUMOSAXAttributes& attrs);157private:158/// @brief The edge container to fill159NBEdgeCont& myEdgeCont;160161/// @brief The edge container to fill162NBNodeCont& myNodeCont;163164/** @brief The traffic lights container to add built tls to (when165* invalidating tls) */166NBTrafficLightLogicCont& myTLLogicCont;167168/// @brief Information whether we have a deprecated attribute169bool myHaveWarnedAboutDeprecatedLanes;170171/// @brief the handler for loading errors172MsgHandler* const myErrorMsgHandler;173174/// @brief The coordinate transformation which was used compute the custom shape coordinates for connections and crossings175GeoConvHelper* myLocation;176177/// @brief last item the could receive parameters178Parameterised* myLastParameterised;179180private:181/// @brief invalidated copy constructor182NIXMLConnectionsHandler(const NIXMLConnectionsHandler& s);183184/// @brief invalidated assignment operator185NIXMLConnectionsHandler& operator=(const NIXMLConnectionsHandler& s);186187188};189190191