Path: blob/main/src/netimport/NIXMLTrafficLightsHandler.h
169666 views
/****************************************************************************/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 NIXMLTrafficLightsHandler.h14/// @author Jakob Erdmann15/// @date 2011-10-0516///17// Importer for traffic lights stored in XML18/****************************************************************************/19#pragma once20#include <config.h>2122#include <utils/xml/SUMOSAXHandler.h>23#include <netbuild/NBConnection.h>242526// ===========================================================================27// class declarations28// ===========================================================================29class NBEdge;30class NBEdgeCont;31class MsgHandler;32class NBLoadedSUMOTLDef;33class NBTrafficLightLogicCont;343536// ===========================================================================37// class definitions38// ===========================================================================39/**40* @class NIXMLTrafficLightsHandler41* @brief Importer for edge connections stored in XML42*43* This importer parses connections, and prohibitions, and is able44* to reset connections between edges.45*/46class NIXMLTrafficLightsHandler : public SUMOSAXHandler {47public:48/** @brief Constructor49* @param[in] ec The traffic light container into which to load logics50*/51NIXMLTrafficLightsHandler(NBTrafficLightLogicCont& tlCont, NBEdgeCont& ec, bool ignoreUnknown = false);525354/// @brief Destructor55~NIXMLTrafficLightsHandler();5657const std::set<std::string>& getSeenIDs() {58return mySeenIDs;59}606162protected:63/// @name inherited from GenericSAXHandler64//@{6566/** @brief Called on the opening of a tag;67*68* @param[in] element ID of the currently opened element69* @param[in] attrs Attributes within the currently opened element70* @exception ProcessError If something fails71* @see GenericSAXHandler::myStartElement72*/73void myStartElement(int element, const SUMOSAXAttributes& attrs);747576/** @brief Called when a closing tag occurs77*78* @param[in] element ID of the currently opened element79* @exception ProcessError If something fails80* @see GenericSAXHandler::myEndElement81*/82void myEndElement(int element);83//@}84858687private:88/// @brief The traffic light container to fill89NBTrafficLightLogicCont& myTLLCont;9091/// @brief The edge container for retrieving edges92NBEdgeCont& myEdgeCont;9394/// @brief The currently parsed traffic light95NBLoadedSUMOTLDef* myCurrentTL;9697/// @brief whether phases of a previously loaded traffic light must be reset98bool myResetPhases;99100/** begins the reading of a traffic lights logic101* This differs from NIImporter_SUMO::initTrafficLightLogic insofar as102* partial definitions (diffs) are allowed in an xml file103*/104NBLoadedSUMOTLDef* initTrafficLightLogic(const SUMOSAXAttributes& attrs, NBLoadedSUMOTLDef* currentTL);105106/// @brief reads and adds tl-controlled connection107void addTlConnection(const SUMOSAXAttributes& attrs);108109/// @brief reads and removes tl-controlled connection110void removeTlConnection(const SUMOSAXAttributes& attrs);111112/// parses and edge id an returns an existing edge113NBEdge* retrieveEdge(const SUMOSAXAttributes& attrs, SumoXMLAttr attr, bool& ok);114115/// parses a lane index and verifies its correctness116int retrieveLaneIndex(const SUMOSAXAttributes& attrs, SumoXMLAttr attr, NBEdge* edge, bool& ok, bool isDelete = false);117118/// @brief whether definitions for unknown traffic lights shall be silently ignored119bool myIgnoreUnknown;120121/// @brief list of traffic light logics that were found122std::set<std::string> mySeenIDs;123124private:125/// @brief invalidated copy constructor126NIXMLTrafficLightsHandler(const NIXMLTrafficLightsHandler& s);127128/// @brief invalidated assignment operator129NIXMLTrafficLightsHandler& operator=(const NIXMLTrafficLightsHandler& s);130131132};133134135