Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
DataHandler.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2001-2024 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/****************************************************************************/
18// The XML-Handler for data elements loading
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25
26
27// ===========================================================================
28// class definitions
29// ===========================================================================
38class DataHandler : private SUMOSAXHandler {
39
40public:
44 DataHandler(const std::string& file);
45
48
50 bool parse();
51
54
57
63 virtual void buildDataInterval(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& dataSetID,
64 const double begin, const double end) = 0;
65
71 virtual void buildEdgeData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID,
72 const Parameterised::Map& parameters) = 0;
73
80 virtual void buildEdgeRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID,
81 const std::string& toEdgeID, const Parameterised::Map& parameters) = 0;
82
89 virtual void buildTAZRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromTAZID,
90 const std::string& toTAZID, const Parameterised::Map& parameters) = 0;
92
94 bool isErrorCreatingElement() const;
95
96protected:
98 void writeError(const std::string& error);
99
100private:
103
106
109
117 virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);
118
126 virtual void myEndElement(int element);
128
132 void parseInterval(const SUMOSAXAttributes& attrs);
133
135 void parseEdgeData(const SUMOSAXAttributes& attrs);
136
138 void parseEdgeRelationData(const SUMOSAXAttributes& attrs);
139
141 void parseTAZRelationData(const SUMOSAXAttributes& attrs);
143
145 void getAttributes(const SUMOSAXAttributes& attrs, const std::vector<SumoXMLAttr> avoidAttributes) const;
146
148 void checkParent(const SumoXMLTag currentTag, const SumoXMLTag parentTag, bool& ok);
149
151 DataHandler(const DataHandler& s) = delete;
152
154 DataHandler& operator=(const DataHandler& s) = delete;
155};
SumoXMLTag
Numbers representing SUMO-XML - element names.
The XML-Handler for network loading.
Definition DataHandler.h:38
void parseTAZRelationData(const SUMOSAXAttributes &attrs)
parse TAZRelationData attributes
~DataHandler()
Destructor.
bool myErrorCreatingElement
flag for check if a element wasn't created
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
bool parse()
parse
void writeError(const std::string &error)
write error and enable error creating element
void parseEdgeRelationData(const SUMOSAXAttributes &attrs)
parse edgeRelationData attributes
virtual void myEndElement(int element)
Called when a closing tag occurs.
DataHandler(const DataHandler &s)=delete
invalidate copy constructor
void checkParent(const SumoXMLTag currentTag, const SumoXMLTag parentTag, bool &ok)
check parents
virtual void buildTAZRelationData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromTAZID, const std::string &toTAZID, const Parameterised::Map &parameters)=0
Builds TAZRelationData.
void parseEdgeData(const SUMOSAXAttributes &attrs)
parse edgeData attributes
virtual void buildDataInterval(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &dataSetID, const double begin, const double end)=0
Builds DataInterval.
virtual void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
virtual void buildEdgeData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &edgeID, const Parameterised::Map &parameters)=0
Builds edgeData.
void getAttributes(const SUMOSAXAttributes &attrs, const std::vector< SumoXMLAttr > avoidAttributes) const
parse attributes as parameters
DataHandler & operator=(const DataHandler &s)=delete
invalidate assignment operator
CommonXMLStructure myCommonXMLStructure
common XML Structure
void parseInterval(const SUMOSAXAttributes &attrs)
virtual void buildEdgeRelationData(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &fromEdgeID, const std::string &toEdgeID, const Parameterised::Map &parameters)=0
Builds edgeRelationData.
bool isErrorCreatingElement() const
get flag for check if a element wasn't created
void error(const XERCES_CPP_NAMESPACE::SAXParseException &exception)
Handler for XML-errors.
std::map< std::string, std::string > Map
parameters map
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.