Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/handlers/DataHandler.h
169678 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 DataHandler.h
15
/// @author Jakob Erdmann
16
/// @date Jun 2021
17
///
18
// The XML-Handler for data elements loading
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include "CommonHandler.h"
24
25
// ===========================================================================
26
// class definitions
27
// ===========================================================================
28
/**
29
* @class DataHandler
30
* @brief The XML-Handler for network loading
31
*
32
* The SAX2-handler responsible for parsing networks and routes to load.
33
* This is an extension of the MSRouteHandler as routes and vehicles may also
34
* be loaded from network descriptions.
35
*/
36
class DataHandler : public CommonHandler, private SUMOSAXHandler {
37
38
public:
39
/**@brief Constructor
40
* @param[in] filename Name of the parsed file
41
*/
42
DataHandler(const std::string& filename);
43
44
/// @brief Destructor
45
~DataHandler();
46
47
/// @brief parse
48
bool parse();
49
50
/// @brief parse SumoBaseObject (it's called recursivelly)
51
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject* obj);
52
53
/// @brief run post parser tasks
54
virtual bool postParserTasks() = 0;
55
56
/// @name build functions
57
/// @{
58
/**@brief Builds DataInterval
59
* @param[in] sumoBaseObject sumo base object used for build
60
* @param[in] dataSetID interval's dataSet
61
* @param[in] begin interval begin
62
* @param[in] end interval end
63
*/
64
virtual bool buildDataInterval(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& dataSetID,
65
const double begin, const double end) = 0;
66
67
/**@brief Builds edgeData
68
* @param[in] sumoBaseObject sumo base object used for build
69
* @param[in] edgeID edge ID
70
* @param[in] parameters parameters map
71
*/
72
virtual bool buildEdgeData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID,
73
const Parameterised::Map& parameters) = 0;
74
75
/**@brief Builds edgeRelationData
76
* @param[in] sumoBaseObject sumo base object used for build
77
* @param[in] fromEdge edge from
78
* @param[in] toEdge edge to
79
* @param[in] parameters parameters map
80
*/
81
virtual bool buildEdgeRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID,
82
const std::string& toEdgeID, const Parameterised::Map& parameters) = 0;
83
84
/**@brief Builds TAZRelationData
85
* @param[in] sumoBaseObject sumo base object used for build
86
* @param[in] fromTAZ TAZ from
87
* @param[in] toTAZ TAZ to
88
* @param[in] parameters parameters map
89
*/
90
virtual bool buildTAZRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromTAZID,
91
const std::string& toTAZID, const Parameterised::Map& parameters) = 0;
92
/// @}
93
94
private:
95
/// @name inherited from GenericSAXHandler
96
/// @{
97
/** @brief Called on the opening of a tag;
98
*
99
* @param[in] element ID of the currently opened element
100
* @param[in] attrs Attributes within the currently opened element
101
* @exception ProcessError If something fails
102
* @see GenericSAXHandler::myStartElement
103
* @todo Refactor/describe
104
*/
105
virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
106
107
/** @brief Called when a closing tag occurs
108
*
109
* @param[in] element ID of the currently opened element
110
* @exception ProcessError If something fails
111
* @see GenericSAXHandler::myEndElement
112
* @todo Refactor/describe
113
*/
114
virtual void myEndElement(int element);
115
/// @}
116
117
/// @name parse data attributes
118
/// @{
119
/// @brief parse interval attributes
120
void parseInterval(const SUMOSAXAttributes& attrs);
121
122
/// @brief parse edgeData attributes
123
void parseEdgeData(const SUMOSAXAttributes& attrs);
124
125
/// @brief parse edgeRelationData attributes
126
void parseEdgeRelationData(const SUMOSAXAttributes& attrs);
127
128
/// @brief parse TAZRelationData attributes
129
void parseTAZRelationData(const SUMOSAXAttributes& attrs);
130
/// @}
131
132
/// @brief parse attributes as parameters
133
void getAttributes(const SUMOSAXAttributes& attrs, const std::vector<SumoXMLAttr> avoidAttributes) const;
134
135
/// @brief check parents
136
void checkParent(const SumoXMLTag currentTag, const SumoXMLTag parentTag, bool& ok);
137
138
/// @brief invalidate default onstructor
139
DataHandler() = delete;
140
141
/// @brief invalidate copy constructor
142
DataHandler(const DataHandler& s) = delete;
143
144
/// @brief invalidate assignment operator
145
DataHandler& operator=(const DataHandler& s) = delete;
146
};
147
148