Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
CommonHandler.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-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/****************************************************************************/
18// Collection of functions used in handlers
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
38
39public:
43 CommonHandler(const std::string& filename);
44
46 virtual ~CommonHandler();
47
49 bool isErrorCreatingElement() const;
50
51protected:
53 const std::string myFilename;
54
57
60
62 void parseParameters(const SUMOSAXAttributes& attrs);
63
66
69
71 void checkParsedParent(const SumoXMLTag currentTag, const std::vector<SumoXMLTag>& parentTags, bool& ok);
72
74 bool checkListOfVehicleTypes(const SumoXMLTag tag, const std::string& id, const std::vector<std::string>& vTypeIDs);
75
78
81
84
87
90
92 bool checkNegative(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const int value, const bool canBeZero);
93
95 bool checkNegative(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const double value, const bool canBeZero);
96
98 bool checkNegative(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const SUMOTime value, const bool canBeZero);
99
101 bool checkFileName(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const std::string& value);
102
104 bool checkValidAdditionalID(const SumoXMLTag tag, const std::string& value);
105
107 bool checkValidDetectorID(const SumoXMLTag tag, const std::string& value);
108
110 bool checkValidDemandElementID(const SumoXMLTag tag, const std::string& value);
111
113
115 void writeWarningOverwritting(const SumoXMLTag tag, const std::string& id);
116
118 bool writeWarningDuplicated(const SumoXMLTag tag, const std::string& id, const SumoXMLTag checkedTag);
119
121 bool writeError(const std::string& error);
122
124 bool writeErrorInvalidPosition(const SumoXMLTag tag, const std::string& id);
125
127 bool writeErrorEmptyEdges(const SumoXMLTag tag, const std::string& id);
128
130 bool writeErrorInvalidLanes(const SumoXMLTag tag, const std::string& id);
131
133 bool writeErrorInvalidParent(const SumoXMLTag tag, const std::string& id, const SumoXMLTag parentTag, const std::string& parentID);
134
136 bool writeErrorInvalidParent(const SumoXMLTag tag, const SumoXMLTag parentTag, const std::string& parentID);
137
139 bool writeErrorInvalidParent(const SumoXMLTag tag, const SumoXMLTag parentTag);
140
141private:
143 CommonHandler() = delete;
144
146 CommonHandler(const CommonHandler& s) = delete;
147
150};
long long int SUMOTime
Definition GUI.h:36
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
The XML-Handler for network loading.
bool checkStopParents(CommonXMLStructure::SumoBaseObject *obj)
check stop parents
CommonXMLStructure::SumoBaseObject * getEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get embedded route from children
virtual ~CommonHandler()
Destructor.
void checkParsedParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
check parsed parents
bool checkContainerPlanParents(CommonXMLStructure::SumoBaseObject *obj)
check container plan parents
bool writeError(const std::string &error)
write error and enable error creating element
bool myErrorCreatingElement
flag for mark if a element wasn't created
CommonHandler()=delete
invalidate default onstructor
CommonHandler & operator=(const CommonHandler &s)=delete
invalidate assignment operator
bool checkValidDetectorID(const SumoXMLTag tag, const std::string &value)
check if the given detector ID is valid
bool writeErrorInvalidParent(const SumoXMLTag tag, const std::string &id, const SumoXMLTag parentTag, const std::string &parentID)
write error "invalid parent element" giving ids of current and parent element
bool checkListOfVehicleTypes(const SumoXMLTag tag, const std::string &id, const std::vector< std::string > &vTypeIDs)
check list of IDs
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
bool writeWarningDuplicated(const SumoXMLTag tag, const std::string &id, const SumoXMLTag checkedTag)
write warning duplicated element
void writeWarningOverwritting(const SumoXMLTag tag, const std::string &id)
write warning overwritting element
bool writeErrorEmptyEdges(const SumoXMLTag tag, const std::string &id)
write error "empty edges"
bool checkWithinDistribution(CommonXMLStructure::SumoBaseObject *obj)
check if the given object is within a distribution (VType or routes)
bool checkValidAdditionalID(const SumoXMLTag tag, const std::string &value)
check if the given additional ID is valid
bool checkFileName(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const std::string &value)
check if the given filename is valid
bool writeErrorInvalidPosition(const SumoXMLTag tag, const std::string &id)
write error "invalid position"
CommonXMLStructure myCommonXMLStructure
common XML Structure
bool writeErrorInvalidLanes(const SumoXMLTag tag, const std::string &id)
write error "invalid list of lanes"
bool checkVehicleParents(CommonXMLStructure::SumoBaseObject *obj)
check vehicle parents
const std::string myFilename
filename
bool checkNegative(const SumoXMLTag tag, const std::string &id, const SumoXMLAttr attribute, const int value, const bool canBeZero)
check if the given int value is NOT negative
bool checkValidDemandElementID(const SumoXMLTag tag, const std::string &value)
check if the given demand elmement ID is valid
CommonHandler(const CommonHandler &s)=delete
invalidate copy constructor
bool isErrorCreatingElement() const
get flag for mark if a element wasn't created
bool checkPersonPlanParents(CommonXMLStructure::SumoBaseObject *obj)
check person plan parents
Encapsulated SAX-Attributes.