Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/utils/handlers/DataHandler.h
193744 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2026 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] bucket FileBucket in which place the element
41
*/
42
DataHandler(FileBucket* fileBucket);
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
/// @name build functions
54
/// @{
55
/**@brief Builds DataInterval
56
* @param[in] sumoBaseObject sumo base object used for build
57
* @param[in] dataSetID interval's dataSet
58
* @param[in] begin interval begin
59
* @param[in] end interval end
60
*/
61
virtual bool buildDataInterval(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& dataSetID,
62
const double begin, const double end) = 0;
63
64
/**@brief Builds edgeData
65
* @param[in] sumoBaseObject sumo base object used for build
66
* @param[in] edgeID edge ID
67
* @param[in] parameters parameters map
68
*/
69
virtual bool buildEdgeData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID,
70
const Parameterised::Map& parameters) = 0;
71
72
/**@brief Builds edgeRelationData
73
* @param[in] sumoBaseObject sumo base object used for build
74
* @param[in] fromEdge edge from
75
* @param[in] toEdge edge to
76
* @param[in] parameters parameters map
77
*/
78
virtual bool buildEdgeRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID,
79
const std::string& toEdgeID, const Parameterised::Map& parameters) = 0;
80
81
/**@brief Builds TAZRelationData
82
* @param[in] sumoBaseObject sumo base object used for build
83
* @param[in] fromTAZ TAZ from
84
* @param[in] toTAZ TAZ to
85
* @param[in] parameters parameters map
86
*/
87
virtual bool buildTAZRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromTAZID,
88
const std::string& toTAZID, const Parameterised::Map& parameters) = 0;
89
/// @}
90
91
private:
92
/// @name inherited from GenericSAXHandler
93
/// @{
94
/** @brief Called on the opening of a tag;
95
*
96
* @param[in] element ID of the currently opened element
97
* @param[in] attrs Attributes within the currently opened element
98
* @exception ProcessError If something fails
99
* @see GenericSAXHandler::myStartElement
100
* @todo Refactor/describe
101
*/
102
virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
103
104
/** @brief Called when a closing tag occurs
105
*
106
* @param[in] element ID of the currently opened element
107
* @exception ProcessError If something fails
108
* @see GenericSAXHandler::myEndElement
109
* @todo Refactor/describe
110
*/
111
virtual void myEndElement(int element);
112
/// @}
113
114
/// @name parse data attributes
115
/// @{
116
/// @brief parse interval attributes
117
void parseInterval(const SUMOSAXAttributes& attrs);
118
119
/// @brief parse edgeData attributes
120
void parseEdgeData(const SUMOSAXAttributes& attrs);
121
122
/// @brief parse edgeRelationData attributes
123
void parseEdgeRelationData(const SUMOSAXAttributes& attrs);
124
125
/// @brief parse TAZRelationData attributes
126
void parseTAZRelationData(const SUMOSAXAttributes& attrs);
127
/// @}
128
129
/// @brief parse attributes as parameters
130
void getAttributes(const SUMOSAXAttributes& attrs, const std::vector<SumoXMLAttr> avoidAttributes) const;
131
132
/// @brief check parents
133
void checkParent(const SumoXMLTag currentTag, const SumoXMLTag parentTag, bool& ok);
134
135
/// @brief invalidate default onstructor
136
DataHandler() = delete;
137
138
/// @brief invalidate copy constructor
139
DataHandler(const DataHandler& s) = delete;
140
141
/// @brief invalidate assignment operator
142
DataHandler& operator=(const DataHandler& s) = delete;
143
};
144
145