/****************************************************************************/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 DataHandler.h14/// @author Jakob Erdmann15/// @date Jun 202116///17// The XML-Handler for data elements loading18/****************************************************************************/19#pragma once20#include <config.h>2122#include "CommonHandler.h"2324// ===========================================================================25// class definitions26// ===========================================================================27/**28* @class DataHandler29* @brief The XML-Handler for network loading30*31* The SAX2-handler responsible for parsing networks and routes to load.32* This is an extension of the MSRouteHandler as routes and vehicles may also33* be loaded from network descriptions.34*/35class DataHandler : public CommonHandler, private SUMOSAXHandler {3637public:38/**@brief Constructor39* @param[in] filename Name of the parsed file40*/41DataHandler(const std::string& filename);4243/// @brief Destructor44~DataHandler();4546/// @brief parse47bool parse();4849/// @brief parse SumoBaseObject (it's called recursivelly)50void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject* obj);5152/// @brief run post parser tasks53virtual bool postParserTasks() = 0;5455/// @name build functions56/// @{57/**@brief Builds DataInterval58* @param[in] sumoBaseObject sumo base object used for build59* @param[in] dataSetID interval's dataSet60* @param[in] begin interval begin61* @param[in] end interval end62*/63virtual bool buildDataInterval(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& dataSetID,64const double begin, const double end) = 0;6566/**@brief Builds edgeData67* @param[in] sumoBaseObject sumo base object used for build68* @param[in] edgeID edge ID69* @param[in] parameters parameters map70*/71virtual bool buildEdgeData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& edgeID,72const Parameterised::Map& parameters) = 0;7374/**@brief Builds edgeRelationData75* @param[in] sumoBaseObject sumo base object used for build76* @param[in] fromEdge edge from77* @param[in] toEdge edge to78* @param[in] parameters parameters map79*/80virtual bool buildEdgeRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromEdgeID,81const std::string& toEdgeID, const Parameterised::Map& parameters) = 0;8283/**@brief Builds TAZRelationData84* @param[in] sumoBaseObject sumo base object used for build85* @param[in] fromTAZ TAZ from86* @param[in] toTAZ TAZ to87* @param[in] parameters parameters map88*/89virtual bool buildTAZRelationData(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& fromTAZID,90const std::string& toTAZID, const Parameterised::Map& parameters) = 0;91/// @}9293private:94/// @name inherited from GenericSAXHandler95/// @{96/** @brief Called on the opening of a tag;97*98* @param[in] element ID of the currently opened element99* @param[in] attrs Attributes within the currently opened element100* @exception ProcessError If something fails101* @see GenericSAXHandler::myStartElement102* @todo Refactor/describe103*/104virtual void myStartElement(int element, const SUMOSAXAttributes& attrs);105106/** @brief Called when a closing tag occurs107*108* @param[in] element ID of the currently opened element109* @exception ProcessError If something fails110* @see GenericSAXHandler::myEndElement111* @todo Refactor/describe112*/113virtual void myEndElement(int element);114/// @}115116/// @name parse data attributes117/// @{118/// @brief parse interval attributes119void parseInterval(const SUMOSAXAttributes& attrs);120121/// @brief parse edgeData attributes122void parseEdgeData(const SUMOSAXAttributes& attrs);123124/// @brief parse edgeRelationData attributes125void parseEdgeRelationData(const SUMOSAXAttributes& attrs);126127/// @brief parse TAZRelationData attributes128void parseTAZRelationData(const SUMOSAXAttributes& attrs);129/// @}130131/// @brief parse attributes as parameters132void getAttributes(const SUMOSAXAttributes& attrs, const std::vector<SumoXMLAttr> avoidAttributes) const;133134/// @brief check parents135void checkParent(const SumoXMLTag currentTag, const SumoXMLTag parentTag, bool& ok);136137/// @brief invalidate default onstructor138DataHandler() = delete;139140/// @brief invalidate copy constructor141DataHandler(const DataHandler& s) = delete;142143/// @brief invalidate assignment operator144DataHandler& operator=(const DataHandler& s) = delete;145};146147148