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-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// 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 std::string fromEdge;
65
67 std::string toEdge;
68
70 std::vector<std::string> consecutiveEdges;
71
73 std::string fromJunction;
74
76 std::string toJunction;
77
79 std::string fromTAZ;
80
82 std::string toTAZ;
83
85 std::string fromBusStop;
86
88 std::string toBusStop;
89
91 std::string fromTrainStop;
92
94 std::string toTrainStop;
95
97 std::string fromContainerStop;
98
100 std::string toContainerStop;
101
104
106 std::string toChargingStation;
107
109 std::string fromParkingArea;
110
112 std::string toParkingArea;
113
115 std::string fromRoute;
116
118 std::string toRoute;
119
120 private:
123
126
128 void resetPreviousFromAttributes(const CommonXMLStructure::SumoBaseObject* previousPlanObj, const std::string& newType, const std::string& newId) const;
129
131 void writeIgnoringMessage(const CommonXMLStructure::SumoBaseObject* previousPlanObj, const std::string& oldType, const std::string& oldId,
132 const std::string& newType, const std::string& newId) const;
133 };
134
137
138 public:
140 SumoBaseObject(SumoBaseObject* sumoBaseObjectParent);
141
144
146 void clear();
147
149 void setTag(const SumoXMLTag tag);
150
152 void markAsCreated();
153
156
158 SumoXMLTag getTag() const;
159
161 bool wasCreated() const;
162
165
167 std::map<std::string, std::string> getAllAttributes() const;
168
170 const std::string& getStringAttribute(const SumoXMLAttr attr) const;
171
173 int getIntAttribute(const SumoXMLAttr attr) const;
174
176 double getDoubleAttribute(const SumoXMLAttr attr) const;
177
179 bool getBoolAttribute(const SumoXMLAttr attr) const;
180
182 const Position& getPositionAttribute(const SumoXMLAttr attr) const;
183
185 SUMOTime getTimeAttribute(const SumoXMLAttr attr) const;
186
189
191 const RGBColor& getColorAttribute(const SumoXMLAttr attr) const;
192
194 const std::vector<std::string>& getStringListAttribute(const SumoXMLAttr attr) const;
195
197 const std::vector<double>& getDoubleListAttribute(const SumoXMLAttr attr) const;
198
201
204
207
210
213
215 const std::map<std::string, std::string>& getParameters() const;
216
219
221 const std::vector<SumoBaseObject*>& getSumoBaseObjectChildren() const;
222
224
227
229 bool hasStringAttribute(const SumoXMLAttr attr) const;
230
232 bool hasIntAttribute(const SumoXMLAttr attr) const;
233
235 bool hasDoubleAttribute(const SumoXMLAttr attr) const;
236
238 bool hasBoolAttribute(const SumoXMLAttr attr) const;
239
241 bool hasPositionAttribute(const SumoXMLAttr attr) const;
242
244 bool hasTimeAttribute(const SumoXMLAttr attr) const;
245
247 bool hasColorAttribute(const SumoXMLAttr attr) const;
248
250 bool hasStringListAttribute(const SumoXMLAttr attr) const;
251
253 bool hasDoubleListAttribute(const SumoXMLAttr attr) const;
254
256 bool hasPositionVectorAttribute(const SumoXMLAttr attr) const;
257
259
262
264 void addStringAttribute(const SumoXMLAttr attr, const std::string& value);
265
267 void addIntAttribute(const SumoXMLAttr attr, const int value);
268
270 void addDoubleAttribute(const SumoXMLAttr attr, const double value);
271
273 void addBoolAttribute(const SumoXMLAttr attr, const bool value);
274
276 void addPositionAttribute(const SumoXMLAttr attr, const Position& value);
277
279 void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value);
280
282 void addColorAttribute(const SumoXMLAttr attr, const RGBColor& value);
283
285 void addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value);
286
288 void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value);
289
291 void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value);
292
294 void addParameter(const std::string& key, const std::string& value);
295
297 void setVClass(SUMOVehicleClass vClass);
298
300 void setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter);
301
303 void setVehicleParameter(const SUMOVehicleParameter* vehicleParameter);
304
306 void setStopParameter(const SUMOVehicleParameter::Stop& stopParameter);
307
309 void setPlanParameters(const CommonXMLStructure::PlanParameters& planParameters);
310
312
313 protected:
316
319
321 bool myWasCreated = false;
322
324 std::map<const SumoXMLAttr, std::string> myStringAttributes;
325
327 std::map<const SumoXMLAttr, int> myIntAttributes;
328
330 std::map<const SumoXMLAttr, double> myDoubleAttributes;
331
333 std::map<const SumoXMLAttr, bool> myBoolAttributes;
334
336 std::map<const SumoXMLAttr, Position> myPositionAttributes;
337
339 std::map<const SumoXMLAttr, SUMOTime> myTimeAttributes;
340
342 std::map<const SumoXMLAttr, RGBColor> myColorAttributes;
343
345 std::map<const SumoXMLAttr, std::vector<std::string> > myStringListAttributes;
346
348 std::map<const SumoXMLAttr, std::vector<double> > myDoubleListAttributes;
349
351 std::map<const SumoXMLAttr, PositionVector> myPositionVectorAttributes;
352
354 std::map<std::string, std::string> myParameters;
355
357 std::vector<SumoBaseObject*> mySumoBaseObjectChildren;
358
361
364
367
370
373
375 void addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
376
378 void removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
379
380 private:
383
386
389
391 void handleAttributeError(const SumoXMLAttr attr, const std::string& type) const;
392
394 SumoBaseObject(const SumoBaseObject& s) = delete;
395
398 };
399
402
405
407 void openSUMOBaseOBject();
408
410 void closeSUMOBaseOBject();
411
413 void abortSUMOBaseOBject();
414
417
420
421protected:
424
427
428private:
431
434};
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)
std::string fromJunction
from junction
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
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
std::string toChargingStation
to chargingStation
std::string fromParkingArea
from parkingArea
std::string toContainerStop
to containerStop
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 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
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 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
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()
Constructor.
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.