Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
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-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// Collection of functions used in handlers
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
38
39public:
42
44 virtual ~CommonHandler();
45
47 bool isErrorCreatingElement() const;
48
49protected:
52
55
57 void parseParameters(const SUMOSAXAttributes& attrs);
58
62 void checkParsedParent(const SumoXMLTag currentTag, const std::vector<SumoXMLTag>& parentTags, bool& ok);
63
65 bool checkListOfVehicleTypes(const SumoXMLTag tag, const std::string& id, const std::vector<std::string>& vTypeIDs);
66
68 bool checkNegative(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const int value, const bool canBeZero);
69
71 bool checkNegative(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const double value, const bool canBeZero);
72
74 bool checkNegative(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const SUMOTime value, const bool canBeZero);
75
77 bool checkFileName(const SumoXMLTag tag, const std::string& id, const SumoXMLAttr attribute, const std::string &value);
78
80 bool checkValidAdditionalID(const SumoXMLTag tag, const std::string& value);
81
83 bool checkValidDetectorID(const SumoXMLTag tag, const std::string& value);
84
86 bool checkValidDemandElementID(const SumoXMLTag tag, const std::string& value);
87
89
91 bool writeError(const std::string& error);
92
94 bool writeErrorInvalidPosition(const SumoXMLTag tag, const std::string& id);
95
97 bool writeErrorDuplicated(const SumoXMLTag tag, const std::string& id, const SumoXMLTag checkedTag);
98
100 bool writeErrorInvalidLanes(const SumoXMLTag tag, const std::string& id);
101
103 bool writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string& id);
104
106 bool writeErrorInvalidParent(const SumoXMLTag tag, const std::string& id, const SumoXMLTag parentTag, const std::string& parentID);
107
109 bool writeErrorInvalidParent(const SumoXMLTag tag, const SumoXMLTag parentTag, const std::string& parentID);
110
112 bool writeErrorInvalidParent(const SumoXMLTag tag, const SumoXMLTag parentTag);
113
114
115
116private:
118 CommonHandler(const CommonHandler& s) = delete;
119
122};
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 writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string &id)
write error "invalid distribution"
virtual ~CommonHandler()
Destructor.
void checkParsedParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
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()
Constructor.
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 writeErrorDuplicated(const SumoXMLTag tag, const std::string &id, const SumoXMLTag checkedTag)
write error "duplicated additional"
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 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
Encapsulated SAX-Attributes.