Eclipse SUMO - Simulation of Urban MObility
CommonXMLStructure.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 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// Structure for common XML Parsing
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
29
30
31// ===========================================================================
32// class definitions
33// ===========================================================================
34
36
37public:
40
41 public:
43 SumoBaseObject(SumoBaseObject* sumoBaseObjectParent);
44
47
49 void clear();
50
52 void setTag(const SumoXMLTag tag);
53
57 SumoXMLTag getTag() const;
58
61
63 std::map<std::string, std::string> getAllAttributes() const;
64
66 const std::string& getStringAttribute(const SumoXMLAttr attr) const;
67
69 int getIntAttribute(const SumoXMLAttr attr) const;
70
72 double getDoubleAttribute(const SumoXMLAttr attr) const;
73
75 bool getBoolAttribute(const SumoXMLAttr attr) const;
76
78 const Position& getPositionAttribute(const SumoXMLAttr attr) const;
79
81 SUMOTime getTimeAttribute(const SumoXMLAttr attr) const;
82
85
87 const RGBColor& getColorAttribute(const SumoXMLAttr attr) const;
88
90 const std::vector<std::string>& getStringListAttribute(const SumoXMLAttr attr) const;
91
94
97
100
103
106
108 const std::map<std::string, std::string>& getParameters() const;
109
111 const std::vector<SumoBaseObject*>& getSumoBaseObjectChildren() const;
113
116
118 bool hasStringAttribute(const SumoXMLAttr attr) const;
119
121 bool hasIntAttribute(const SumoXMLAttr attr) const;
122
124 bool hasDoubleAttribute(const SumoXMLAttr attr) const;
125
127 bool hasBoolAttribute(const SumoXMLAttr attr) const;
128
130 bool hasPositionAttribute(const SumoXMLAttr attr) const;
131
133 bool hasTimeAttribute(const SumoXMLAttr attr) const;
134
136 bool hasColorAttribute(const SumoXMLAttr attr) const;
137
139 bool hasStringListAttribute(const SumoXMLAttr attr) const;
140
142 bool hasPositionVectorAttribute(const SumoXMLAttr attr) const;
143
145
149 void addStringAttribute(const SumoXMLAttr attr, const std::string& value);
150
152 void addIntAttribute(const SumoXMLAttr attr, const int value);
153
155 void addDoubleAttribute(const SumoXMLAttr attr, const double value);
156
158 void addBoolAttribute(const SumoXMLAttr attr, const bool value);
159
161 void addPositionAttribute(const SumoXMLAttr attr, const Position& value);
162
164 void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value);
165
167 void addColorAttribute(const SumoXMLAttr attr, const RGBColor& value);
168
170 void addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value);
171
173 void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value);
174
176 void setVClass(SUMOVehicleClass vClass);
177
179 void setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter);
180
182 void setVehicleParameter(const SUMOVehicleParameter* vehicleParameter);
183
185 void setStopParameter(const SUMOVehicleParameter::Stop& stopParameter);
186
188 void addParameter(const std::string& key, const std::string& value);
190
191 protected:
194
197
199 std::map<const SumoXMLAttr, std::string> myStringAttributes;
200
202 std::map<const SumoXMLAttr, int> myIntAttributes;
203
205 std::map<const SumoXMLAttr, double> myDoubleAttributes;
206
208 std::map<const SumoXMLAttr, bool> myBoolAttributes;
209
211 std::map<const SumoXMLAttr, Position> myPositionAttributes;
212
214 std::map<const SumoXMLAttr, SUMOTime> myTimeAttributes;
215
217 std::map<const SumoXMLAttr, RGBColor> myColorAttributes;
218
220 std::map<const SumoXMLAttr, std::vector<std::string> > myStringListAttributes;
221
223 std::map<const SumoXMLAttr, PositionVector> myPositionVectorAttributes;
224
226 std::map<std::string, std::string> myParameters;
227
229 std::vector<SumoBaseObject*> mySumoBaseObjectChildren;
230
233
236
239
242
244 void addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
245
247 void removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
248
249 private:
252
255
258
260 void handleAttributeError(const SumoXMLAttr attr, const std::string& type) const;
261
263 SumoBaseObject(const SumoBaseObject& s) = delete;
264
267 };
268
271
274
276 void openSUMOBaseOBject();
277
279 void closeSUMOBaseOBject();
280
283
286
287protected:
290
293
294private:
297
300};
long long int SUMOTime
Definition: GUI.h:36
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
void addIntAttribute(const SumoXMLAttr attr, const int value)
add int attribute into current SumoBaseObject node
void setVehicleTypeParameter(const SUMOVTypeParameter *vehicleTypeParameter)
set vehicle type parameters
void addSumoBaseObjectChild(SumoBaseObject *sumoBaseObject)
add SumoBaseObject child
SUMOVehicleParameter::Stop myStopParameter
stop parameter
std::map< const SumoXMLAttr, std::vector< std::string > > myStringListAttributes
stringList attributes
std::map< const SumoXMLAttr, SUMOTime > myTimeAttributes
SUMOTime attributes.
bool myDefinedVehicleParameter
flag for defined vehicle parameter
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
std::vector< SumoBaseObject * > mySumoBaseObjectChildren
SumoBaseObject children.
SUMOTime getTimeAttribute(const SumoXMLAttr attr) const
get time attribute
const PositionVector & getPositionVectorAttribute(const SumoXMLAttr attr) const
get PositionVector attribute
SumoBaseObject(SumoBaseObject *sumoBaseObjectParent)
constructor
bool hasBoolAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given bool attribute
bool myDefinedStopParameter
flag for defined stop parameter
bool myDefinedVehicleTypeParameter
flag for defined vehicle type parameter
void removeSumoBaseObjectChild(SumoBaseObject *sumoBaseObject)
remove SumoBaseObject child
bool hasStringAttribute(const SumoXMLAttr attr) const
has function
std::map< std::string, std::string > getAllAttributes() const
get all attributes in string format
bool hasPositionAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given bool attribute
std::map< const SumoXMLAttr, RGBColor > myColorAttributes
RGBColor attributes.
void setTag(const SumoXMLTag tag)
set SumoBaseObject tag
SumoBaseObject * getParentSumoBaseObject() const
get pointer to mySumoBaseObjectParent SumoBaseObject (if is null, then is the root)
const Position & getPositionAttribute(const SumoXMLAttr attr) const
get Position attribute
std::map< const SumoXMLAttr, bool > myBoolAttributes
bool attributes
void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector &value)
add PositionVector attribute into current SumoBaseObject node
const std::map< std::string, std::string > & getParameters() const
get parameters
SUMOVTypeParameter myVehicleTypeParameter
vehicle type parameter
SUMOVehicleClass getVClass() const
vehicle class
SumoBaseObject * mySumoBaseObjectParent
pointer to SumoBaseObject parent (If is null, then is the root)
SumoBaseObject(const SumoBaseObject &s)=delete
invalidate copy constructor
bool hasPositionVectorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given positionVector attribute
bool hasTimeAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given time attribute
void addBoolAttribute(const SumoXMLAttr attr, const bool value)
add bool attribute into current SumoBaseObject node
std::map< const SumoXMLAttr, double > myDoubleAttributes
double attributes
SUMOVehicleParameter myVehicleParameter
vehicle parameter
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
std::map< const SumoXMLAttr, PositionVector > myPositionVectorAttributes
PositionVector attributes.
void addParameter(const std::string &key, const std::string &value)
add parameter into current SumoBaseObject node
SumoBaseObject & operator=(const SumoBaseObject &s)=delete
invalidate assignment operator
bool hasColorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given color attribute
void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value)
add time attribute into current SumoBaseObject node
void addStringListAttribute(const SumoXMLAttr attr, const std::vector< std::string > &value)
add string list attribute into current SumoBaseObject node
std::map< const SumoXMLAttr, std::string > myStringAttributes
string attributes
bool hasIntAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given int attribute
int getIntAttribute(const SumoXMLAttr attr) const
get int attribute
void addDoubleAttribute(const SumoXMLAttr attr, const double value)
add double attribute into current SumoBaseObject node
void handleAttributeError(const SumoXMLAttr attr, const std::string &type) const
handle attribute error
bool hasDoubleAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given double attribute
void addPositionAttribute(const SumoXMLAttr attr, const Position &value)
add Position attribute into current SumoBaseObject node
bool getBoolAttribute(const SumoXMLAttr attr) const
get bool attribute
void setVClass(SUMOVehicleClass vClass)
set vehicle class
SUMOTime getPeriodAttribute() const
get 'period' attribute
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
std::map< const SumoXMLAttr, Position > myPositionAttributes
Position attributes.
void setStopParameter(const SUMOVehicleParameter::Stop &stopParameter)
add stop parameters
double getDoubleAttribute(const SumoXMLAttr attr) const
get double attribute
const SUMOVehicleParameter & getVehicleParameter() const
get vehicle parameters
const std::vector< std::string > & getStringListAttribute(const SumoXMLAttr attr) const
get string list attribute
bool hasStringListAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given string list attribute
SUMOVehicleClass myVClass
vehicle class
void clear()
clear SumoBaseObject
void addColorAttribute(const SumoXMLAttr attr, const RGBColor &value)
add color attribute into current SumoBaseObject node
const std::string & getStringAttribute(const SumoXMLAttr attr) const
get string attribute
std::map< const SumoXMLAttr, int > myIntAttributes
int attributes
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
std::map< std::string, std::string > myParameters
myParameters
CommonXMLStructure::SumoBaseObject * getSumoBaseObjectRoot() const
get SumoBaseObject root
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
CommonXMLStructure(const CommonXMLStructure &s)=delete
invalidate copy constructor
CommonXMLStructure & operator=(const CommonXMLStructure &s)=delete
invalidate assignment operator
void openSUMOBaseOBject()
open SUMOBaseOBject
CommonXMLStructure::SumoBaseObject * mySumoBaseObjectRoot
SumoBaseObject root.
CommonXMLStructure()
Constructor.
CommonXMLStructure::SumoBaseObject * myCurrentSumoBaseObject
last inserted SumoBaseObject
void closeSUMOBaseOBject()
close myTag
~CommonXMLStructure()
Destructor.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
A list of positions.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.