Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
CommonXMLStructure.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// Structure for common XML Parsing
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
30
31
32// ===========================================================================
33// class definitions
34// ===========================================================================
35
37
38public:
39
41 class SumoBaseObject;
42
45
46 public:
47 // @brief default constructor
49
52 const SUMOSAXAttributes& attrs, bool& parsedOk);
53
55 void clear();
56
58 bool isSingleEdgePlan() const;
59
62
64 SumoXMLTag getWalkTag() const;
65
68
70 SumoXMLTag getRideTag() const;
71
74
77
80
83
85 std::string fromEdge;
86
88 std::string toEdge;
89
91 std::vector<std::string> consecutiveEdges;
92
94 std::string fromJunction;
95
97 std::string toJunction;
98
100 std::string fromTAZ;
101
103 std::string toTAZ;
104
106 std::string fromBusStop;
107
109 std::string toBusStop;
110
112 std::string fromTrainStop;
113
115 std::string toTrainStop;
116
118 std::string fromContainerStop;
119
121 std::string toContainerStop;
122
125
127 std::string toChargingStation;
128
130 std::string fromParkingArea;
131
133 std::string toParkingArea;
134
136 std::string fromRoute;
137
139 std::string toRoute;
140
141 private:
144
147
149 void resetPreviousFromAttributes(const CommonXMLStructure::SumoBaseObject* previousPlanObj, const std::string& newType, const std::string& newId) const;
150
152 void writeIgnoringMessage(const CommonXMLStructure::SumoBaseObject* previousPlanObj, const std::string& oldType, const std::string& oldId,
153 const std::string& newType, const std::string& newId) const;
154 };
155
158
159 public:
161 SumoBaseObject(SumoBaseObject* sumoBaseObjectParent);
162
165
167 void clear();
168
170 void setTag(const SumoXMLTag tag);
171
173 void markAsCreated();
174
177
179 SumoXMLTag getTag() const;
180
182 bool wasCreated() const;
183
186
188 std::map<std::string, std::string> getAllAttributes() const;
189
191 const std::string& getStringAttribute(const SumoXMLAttr attr) const;
192
194 int getIntAttribute(const SumoXMLAttr attr) const;
195
197 double getDoubleAttribute(const SumoXMLAttr attr) const;
198
200 bool getBoolAttribute(const SumoXMLAttr attr) const;
201
203 const Position& getPositionAttribute(const SumoXMLAttr attr) const;
204
206 SUMOTime getTimeAttribute(const SumoXMLAttr attr) const;
207
210
212 const RGBColor& getColorAttribute(const SumoXMLAttr attr) const;
213
215 const std::vector<std::string>& getStringListAttribute(const SumoXMLAttr attr) const;
216
218 const std::vector<double>& getDoubleListAttribute(const SumoXMLAttr attr) const;
219
222
224 const std::string& getParentID(const SumoXMLTag tag) const;
225
228
231
234
237
239 const std::map<std::string, std::string>& getParameters() const;
240
243
245 const std::vector<SumoBaseObject*>& getSumoBaseObjectChildren() const;
246
248
251
253 bool hasStringAttribute(const SumoXMLAttr attr) const;
254
256 bool hasIntAttribute(const SumoXMLAttr attr) const;
257
259 bool hasDoubleAttribute(const SumoXMLAttr attr) const;
260
262 bool hasBoolAttribute(const SumoXMLAttr attr) const;
263
265 bool hasPositionAttribute(const SumoXMLAttr attr) const;
266
268 bool hasTimeAttribute(const SumoXMLAttr attr) const;
269
271 bool hasColorAttribute(const SumoXMLAttr attr) const;
272
274 bool hasStringListAttribute(const SumoXMLAttr attr) const;
275
277 bool hasDoubleListAttribute(const SumoXMLAttr attr) const;
278
280 bool hasPositionVectorAttribute(const SumoXMLAttr attr) const;
281
283 bool hasParentID(const SumoXMLTag tag) const;
284
286
289
291 void addStringAttribute(const SumoXMLAttr attr, const std::string& value);
292
294 void addIntAttribute(const SumoXMLAttr attr, const int value);
295
297 void addDoubleAttribute(const SumoXMLAttr attr, const double value);
298
300 void addBoolAttribute(const SumoXMLAttr attr, const bool value);
301
303 void addPositionAttribute(const SumoXMLAttr attr, const Position& value);
304
306 void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value);
307
309 void addColorAttribute(const SumoXMLAttr attr, const RGBColor& value);
310
312 void addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value);
313
315 void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value);
316
318 void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value);
319
321 void addParameters(const std::string& value);
322
324 void addParameter(const std::string& key, const std::string& value);
325
327 void addParentID(const SumoXMLTag tag, const std::string& ID);
328
330 void setVClass(SUMOVehicleClass vClass);
331
333 void setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter);
334
336 void setVehicleParameter(const SUMOVehicleParameter* vehicleParameter);
337
339 void setStopParameter(const SUMOVehicleParameter::Stop& stopParameter);
340
342 void setPlanParameters(const CommonXMLStructure::PlanParameters& planParameters);
343
345
346 protected:
349
352
354 bool myWasCreated = false;
355
357 std::map<const SumoXMLAttr, std::string> myStringAttributes;
358
360 std::map<const SumoXMLAttr, int> myIntAttributes;
361
363 std::map<const SumoXMLAttr, double> myDoubleAttributes;
364
366 std::map<const SumoXMLAttr, bool> myBoolAttributes;
367
369 std::map<const SumoXMLAttr, Position> myPositionAttributes;
370
372 std::map<const SumoXMLAttr, SUMOTime> myTimeAttributes;
373
375 std::map<const SumoXMLAttr, RGBColor> myColorAttributes;
376
378 std::map<const SumoXMLAttr, std::vector<std::string> > myStringListAttributes;
379
381 std::map<const SumoXMLAttr, std::vector<double> > myDoubleListAttributes;
382
384 std::map<const SumoXMLAttr, PositionVector> myPositionVectorAttributes;
385
387 std::map<std::string, std::string> myParameters;
388
390 std::map<const SumoXMLTag, std::string> myParentIDs;
391
393 std::vector<SumoBaseObject*> mySumoBaseObjectChildren;
394
397
400
403
406
409
411 void addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
412
414 void removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
415
416 private:
419
422
425
427 void handleAttributeError(const SumoXMLAttr attr, const std::string& type) const;
428
430 SumoBaseObject(const SumoBaseObject& s) = delete;
431
434 };
435
438
441
443 void openSUMOBaseOBject();
444
446 void closeSUMOBaseOBject();
447
449 void abortSUMOBaseOBject();
450
453
456
457protected:
460
463
464private:
467
470};
long long int SUMOTime
Definition GUI.h:36
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
@ SVC_IGNORING
vehicles ignoring classes
SumoXMLTag
Numbers representing SUMO-XML - element names.
@ SUMO_TAG_NOTHING
invalid tag, must be the last one
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
plan parameters (used for group all from-to parameters related with plans)
SumoXMLTag getPersonStopTag() const
get the person stop tag for the current combination of parameters
std::string fromJunction
from junction
SumoXMLTag getRideTag() const
get the ride tag for the current combination of parameters
std::string fromContainerStop
from containerStop
void writeIgnoringMessage(const CommonXMLStructure::SumoBaseObject *previousPlanObj, const std::string &oldType, const std::string &oldId, const std::string &newType, const std::string &newId) const
write ignoring message
int getNumberOfDefinedParameters() const
get number of defined plans
std::string fromTrainStop
from trainStop
SumoXMLTag getPersonTripTag() const
get the personTrip tag for the current combination of parameters
SumoXMLTag getTransportTag() const
get the transport tag for the current combination of parameters
const CommonXMLStructure::SumoBaseObject * getPreviousPlanObj(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get previous plan obj
std::string toParkingArea
to parkingArea
std::vector< std::string > consecutiveEdges
consecutive edges
bool isSingleEdgePlan() const
check if this is a single-edge plan
std::string fromChargingStation
from chargingStation
void updateFromAttributes(const CommonXMLStructure::SumoBaseObject *sumoBaseObject)
update the from attributes
SumoXMLTag getContainerStopTag() const
get the container stop tag for the current combination of parameters
std::string toChargingStation
to chargingStation
std::string fromParkingArea
from parkingArea
std::string toContainerStop
to containerStop
SumoXMLTag getWalkTag() const
get the walk tag for the current combination of parameters
SumoXMLTag getTranshipTag() const
get the tranship tag for the current combination of parameters
void resetPreviousFromAttributes(const CommonXMLStructure::SumoBaseObject *previousPlanObj, const std::string &newType, const std::string &newId) const
reste all previous from attributes
void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector< double > &value)
add double list attribute into current SumoBaseObject node
const std::vector< double > & getDoubleListAttribute(const SumoXMLAttr attr) const
get double list attribute
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
bool hasBoolAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given bool attribute
bool hasParentID(const SumoXMLTag tag) const
check if current SumoBaseObject has the given parent ID
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
const CommonXMLStructure::PlanParameters & getPlanParameters() const
get plan parameteres
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 myWasCreated
flag to check if object was created in build<..> function (by default false)
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
void setPlanParameters(const CommonXMLStructure::PlanParameters &planParameters)
set plan parmeter
std::map< const SumoXMLAttr, double > myDoubleAttributes
double attributes
SUMOVehicleParameter myVehicleParameter
vehicle parameter
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
CommonXMLStructure::PlanParameters myPlanParameters
plan parameters
std::map< const SumoXMLAttr, PositionVector > myPositionVectorAttributes
PositionVector attributes.
SumoXMLTag getTag() const
get XML myTag
const std::string & getParentID(const SumoXMLTag tag) const
get parent ID
void addParameter(const std::string &key, const std::string &value)
add parameter into current SumoBaseObject node
std::map< const SumoXMLTag, std::string > myParentIDs
parent IDs
SumoBaseObject & operator=(const SumoBaseObject &s)=delete
invalidate assignment operator
void addParentID(const SumoXMLTag tag, const std::string &ID)
add parent (string) attribute into current SumoBaseObject node
bool hasColorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given color attribute
void markAsCreated()
mark as successfully created
std::map< const SumoXMLAttr, std::vector< double > > myDoubleListAttributes
stringList attributes
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
bool wasCreated() const
check if the object was successfully created in build<...> function
SUMOTime getPeriodAttribute() const
get 'period' attribute
void setVehicleParameter(const SUMOVehicleParameter *vehicleParameter)
set vehicle parameters
void addStringAttribute(const SumoXMLAttr attr, const std::string &value)
add string attribute into current SumoBaseObject node
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
bool hasDoubleListAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given double list attribute
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 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
void addParameters(const std::string &value)
add parameters into current SumoBaseObject node (format: key=value1|key2=value2|.....
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
std::map< std::string, std::string > myParameters
myParameters
void abortSUMOBaseOBject()
abort SUMOBaseOBject
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::SumoBaseObject * myCurrentSumoBaseObject
last inserted SumoBaseObject
void closeSUMOBaseOBject()
close SUMOBaseOBject
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Encapsulated SAX-Attributes.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.