Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netimport/NIXMLTrafficLightsHandler.h
169666 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 German Aerospace Center (DLR) and others.
4
// This program and the accompanying materials are made available under the
5
// terms of the Eclipse Public License 2.0 which is available at
6
// https://www.eclipse.org/legal/epl-2.0/
7
// This Source Code may also be made available under the following Secondary
8
// Licenses when the conditions for such availability set forth in the Eclipse
9
// Public License 2.0 are satisfied: GNU General Public License, version 2
10
// or later which is available at
11
// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13
/****************************************************************************/
14
/// @file NIXMLTrafficLightsHandler.h
15
/// @author Jakob Erdmann
16
/// @date 2011-10-05
17
///
18
// Importer for traffic lights stored in XML
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <utils/xml/SUMOSAXHandler.h>
24
#include <netbuild/NBConnection.h>
25
26
27
// ===========================================================================
28
// class declarations
29
// ===========================================================================
30
class NBEdge;
31
class NBEdgeCont;
32
class MsgHandler;
33
class NBLoadedSUMOTLDef;
34
class NBTrafficLightLogicCont;
35
36
37
// ===========================================================================
38
// class definitions
39
// ===========================================================================
40
/**
41
* @class NIXMLTrafficLightsHandler
42
* @brief Importer for edge connections stored in XML
43
*
44
* This importer parses connections, and prohibitions, and is able
45
* to reset connections between edges.
46
*/
47
class NIXMLTrafficLightsHandler : public SUMOSAXHandler {
48
public:
49
/** @brief Constructor
50
* @param[in] ec The traffic light container into which to load logics
51
*/
52
NIXMLTrafficLightsHandler(NBTrafficLightLogicCont& tlCont, NBEdgeCont& ec, bool ignoreUnknown = false);
53
54
55
/// @brief Destructor
56
~NIXMLTrafficLightsHandler();
57
58
const std::set<std::string>& getSeenIDs() {
59
return mySeenIDs;
60
}
61
62
63
protected:
64
/// @name inherited from GenericSAXHandler
65
//@{
66
67
/** @brief Called on the opening of a tag;
68
*
69
* @param[in] element ID of the currently opened element
70
* @param[in] attrs Attributes within the currently opened element
71
* @exception ProcessError If something fails
72
* @see GenericSAXHandler::myStartElement
73
*/
74
void myStartElement(int element, const SUMOSAXAttributes& attrs);
75
76
77
/** @brief Called when a closing tag occurs
78
*
79
* @param[in] element ID of the currently opened element
80
* @exception ProcessError If something fails
81
* @see GenericSAXHandler::myEndElement
82
*/
83
void myEndElement(int element);
84
//@}
85
86
87
88
private:
89
/// @brief The traffic light container to fill
90
NBTrafficLightLogicCont& myTLLCont;
91
92
/// @brief The edge container for retrieving edges
93
NBEdgeCont& myEdgeCont;
94
95
/// @brief The currently parsed traffic light
96
NBLoadedSUMOTLDef* myCurrentTL;
97
98
/// @brief whether phases of a previously loaded traffic light must be reset
99
bool myResetPhases;
100
101
/** begins the reading of a traffic lights logic
102
* This differs from NIImporter_SUMO::initTrafficLightLogic insofar as
103
* partial definitions (diffs) are allowed in an xml file
104
*/
105
NBLoadedSUMOTLDef* initTrafficLightLogic(const SUMOSAXAttributes& attrs, NBLoadedSUMOTLDef* currentTL);
106
107
/// @brief reads and adds tl-controlled connection
108
void addTlConnection(const SUMOSAXAttributes& attrs);
109
110
/// @brief reads and removes tl-controlled connection
111
void removeTlConnection(const SUMOSAXAttributes& attrs);
112
113
/// parses and edge id an returns an existing edge
114
NBEdge* retrieveEdge(const SUMOSAXAttributes& attrs, SumoXMLAttr attr, bool& ok);
115
116
/// parses a lane index and verifies its correctness
117
int retrieveLaneIndex(const SUMOSAXAttributes& attrs, SumoXMLAttr attr, NBEdge* edge, bool& ok, bool isDelete = false);
118
119
/// @brief whether definitions for unknown traffic lights shall be silently ignored
120
bool myIgnoreUnknown;
121
122
/// @brief list of traffic light logics that were found
123
std::set<std::string> mySeenIDs;
124
125
private:
126
/// @brief invalidated copy constructor
127
NIXMLTrafficLightsHandler(const NIXMLTrafficLightsHandler& s);
128
129
/// @brief invalidated assignment operator
130
NIXMLTrafficLightsHandler& operator=(const NIXMLTrafficLightsHandler& s);
131
132
133
};
134
135