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.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 
23 #include <utils/common/SUMOTime.h>
24 #include <utils/common/RGBColor.h>
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
35 
37 
38 public:
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 
61  int getNumberOfDefinedParameters() const;
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 
103  std::string fromChargingStation;
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 
125  void updateFromAttributes(const CommonXMLStructure::SumoBaseObject* sumoBaseObject);
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 
143  ~SumoBaseObject();
144 
146  void clear();
147 
149  void setTag(const SumoXMLTag tag);
150 
153 
155  SumoXMLTag getTag() const;
156 
159 
161  std::map<std::string, std::string> getAllAttributes() const;
162 
164  const std::string& getStringAttribute(const SumoXMLAttr attr) const;
165 
167  int getIntAttribute(const SumoXMLAttr attr) const;
168 
170  double getDoubleAttribute(const SumoXMLAttr attr) const;
171 
173  bool getBoolAttribute(const SumoXMLAttr attr) const;
174 
176  const Position& getPositionAttribute(const SumoXMLAttr attr) const;
177 
179  SUMOTime getTimeAttribute(const SumoXMLAttr attr) const;
180 
183 
185  const RGBColor& getColorAttribute(const SumoXMLAttr attr) const;
186 
188  const std::vector<std::string>& getStringListAttribute(const SumoXMLAttr attr) const;
189 
191  const std::vector<double>& getDoubleListAttribute(const SumoXMLAttr attr) const;
192 
194  const PositionVector& getPositionVectorAttribute(const SumoXMLAttr attr) const;
195 
197  SUMOVehicleClass getVClass() const;
198 
201 
204 
207 
209  const std::map<std::string, std::string>& getParameters() const;
210 
213 
215  const std::vector<SumoBaseObject*>& getSumoBaseObjectChildren() const;
216 
218 
221 
223  bool hasStringAttribute(const SumoXMLAttr attr) const;
224 
226  bool hasIntAttribute(const SumoXMLAttr attr) const;
227 
229  bool hasDoubleAttribute(const SumoXMLAttr attr) const;
230 
232  bool hasBoolAttribute(const SumoXMLAttr attr) const;
233 
235  bool hasPositionAttribute(const SumoXMLAttr attr) const;
236 
238  bool hasTimeAttribute(const SumoXMLAttr attr) const;
239 
241  bool hasColorAttribute(const SumoXMLAttr attr) const;
242 
244  bool hasStringListAttribute(const SumoXMLAttr attr) const;
245 
247  bool hasDoubleListAttribute(const SumoXMLAttr attr) const;
248 
250  bool hasPositionVectorAttribute(const SumoXMLAttr attr) const;
251 
253 
256 
258  void addStringAttribute(const SumoXMLAttr attr, const std::string& value);
259 
261  void addIntAttribute(const SumoXMLAttr attr, const int value);
262 
264  void addDoubleAttribute(const SumoXMLAttr attr, const double value);
265 
267  void addBoolAttribute(const SumoXMLAttr attr, const bool value);
268 
270  void addPositionAttribute(const SumoXMLAttr attr, const Position& value);
271 
273  void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value);
274 
276  void addColorAttribute(const SumoXMLAttr attr, const RGBColor& value);
277 
279  void addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value);
280 
282  void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value);
283 
285  void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value);
286 
288  void addParameter(const std::string& key, const std::string& value);
289 
291  void setVClass(SUMOVehicleClass vClass);
292 
294  void setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter);
295 
297  void setVehicleParameter(const SUMOVehicleParameter* vehicleParameter);
298 
300  void setStopParameter(const SUMOVehicleParameter::Stop& stopParameter);
301 
303  void setPlanParameters(const CommonXMLStructure::PlanParameters& planParameters);
304 
306 
307  protected:
310 
313 
315  std::map<const SumoXMLAttr, std::string> myStringAttributes;
316 
318  std::map<const SumoXMLAttr, int> myIntAttributes;
319 
321  std::map<const SumoXMLAttr, double> myDoubleAttributes;
322 
324  std::map<const SumoXMLAttr, bool> myBoolAttributes;
325 
327  std::map<const SumoXMLAttr, Position> myPositionAttributes;
328 
330  std::map<const SumoXMLAttr, SUMOTime> myTimeAttributes;
331 
333  std::map<const SumoXMLAttr, RGBColor> myColorAttributes;
334 
336  std::map<const SumoXMLAttr, std::vector<std::string> > myStringListAttributes;
337 
339  std::map<const SumoXMLAttr, std::vector<double> > myDoubleListAttributes;
340 
342  std::map<const SumoXMLAttr, PositionVector> myPositionVectorAttributes;
343 
345  std::map<std::string, std::string> myParameters;
346 
348  std::vector<SumoBaseObject*> mySumoBaseObjectChildren;
349 
352 
355 
358 
361 
364 
366  void addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
367 
369  void removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
370 
371  private:
374 
377 
380 
382  void handleAttributeError(const SumoXMLAttr attr, const std::string& type) const;
383 
385  SumoBaseObject(const SumoBaseObject& s) = delete;
386 
389  };
390 
393 
396 
398  void openSUMOBaseOBject();
399 
401  void closeSUMOBaseOBject();
402 
405 
408 
409 protected:
412 
415 
416 private:
419 
422 };
long long int SUMOTime
Definition: GUI.h:35
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.
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
std::string toTrainStop
to trainStop
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::string fromBusStop
from busStop
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
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
SumoBaseObject & operator=(const SumoBaseObject &s)=delete
invalidate assignment operator
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 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
bool hasColorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given color attribute
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
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
CommonXMLStructure::SumoBaseObject * getSumoBaseObjectRoot() const
get SumoBaseObject root
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
CommonXMLStructure(const CommonXMLStructure &s)=delete
invalidate copy constructor
void openSUMOBaseOBject()
open SUMOBaseOBject
CommonXMLStructure::SumoBaseObject * mySumoBaseObjectRoot
SumoBaseObject root.
CommonXMLStructure()
Constructor.
CommonXMLStructure & operator=(const CommonXMLStructure &s)=delete
invalidate assignment operator
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.
Encapsulated SAX-Attributes.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.