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>
29 
30 
31 // ===========================================================================
32 // class definitions
33 // ===========================================================================
34 
36 
37 public:
40 
41  public:
43  SumoBaseObject(SumoBaseObject* sumoBaseObjectParent);
44 
47 
49  void clear();
50 
52  void setTag(const SumoXMLTag tag);
53 
56 
58  SumoXMLTag getTag() const;
59 
62 
64  std::map<std::string, std::string> getAllAttributes() const;
65 
67  const std::string& getStringAttribute(const SumoXMLAttr attr) const;
68 
70  int getIntAttribute(const SumoXMLAttr attr) const;
71 
73  double getDoubleAttribute(const SumoXMLAttr attr) const;
74 
76  bool getBoolAttribute(const SumoXMLAttr attr) const;
77 
79  const Position& getPositionAttribute(const SumoXMLAttr attr) const;
80 
82  SUMOTime getTimeAttribute(const SumoXMLAttr attr) const;
83 
86 
88  const RGBColor& getColorAttribute(const SumoXMLAttr attr) const;
89 
91  const std::vector<std::string>& getStringListAttribute(const SumoXMLAttr attr) const;
92 
94  const std::vector<double>& getDoubleListAttribute(const SumoXMLAttr attr) const;
95 
97  const PositionVector& getPositionVectorAttribute(const SumoXMLAttr attr) const;
98 
100  SUMOVehicleClass getVClass() const;
101 
104 
107 
110 
112  const std::map<std::string, std::string>& getParameters() const;
113 
115  const std::vector<SumoBaseObject*>& getSumoBaseObjectChildren() const;
116 
118 
121 
123  bool hasStringAttribute(const SumoXMLAttr attr) const;
124 
126  bool hasIntAttribute(const SumoXMLAttr attr) const;
127 
129  bool hasDoubleAttribute(const SumoXMLAttr attr) const;
130 
132  bool hasBoolAttribute(const SumoXMLAttr attr) const;
133 
135  bool hasPositionAttribute(const SumoXMLAttr attr) const;
136 
138  bool hasTimeAttribute(const SumoXMLAttr attr) const;
139 
141  bool hasColorAttribute(const SumoXMLAttr attr) const;
142 
144  bool hasStringListAttribute(const SumoXMLAttr attr) const;
145 
147  bool hasDoubleListAttribute(const SumoXMLAttr attr) const;
148 
150  bool hasPositionVectorAttribute(const SumoXMLAttr attr) const;
151 
153 
156 
158  void addStringAttribute(const SumoXMLAttr attr, const std::string& value);
159 
161  void addIntAttribute(const SumoXMLAttr attr, const int value);
162 
164  void addDoubleAttribute(const SumoXMLAttr attr, const double value);
165 
167  void addBoolAttribute(const SumoXMLAttr attr, const bool value);
168 
170  void addPositionAttribute(const SumoXMLAttr attr, const Position& value);
171 
173  void addTimeAttribute(const SumoXMLAttr attr, const SUMOTime value);
174 
176  void addColorAttribute(const SumoXMLAttr attr, const RGBColor& value);
177 
179  void addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value);
180 
182  void addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value);
183 
185  void addPositionVectorAttribute(const SumoXMLAttr attr, const PositionVector& value);
186 
188  void setVClass(SUMOVehicleClass vClass);
189 
191  void setVehicleTypeParameter(const SUMOVTypeParameter* vehicleTypeParameter);
192 
194  void setVehicleParameter(const SUMOVehicleParameter* vehicleParameter);
195 
197  void setStopParameter(const SUMOVehicleParameter::Stop& stopParameter);
198 
200  void addParameter(const std::string& key, const std::string& value);
201 
203 
204  protected:
207 
210 
212  std::map<const SumoXMLAttr, std::string> myStringAttributes;
213 
215  std::map<const SumoXMLAttr, int> myIntAttributes;
216 
218  std::map<const SumoXMLAttr, double> myDoubleAttributes;
219 
221  std::map<const SumoXMLAttr, bool> myBoolAttributes;
222 
224  std::map<const SumoXMLAttr, Position> myPositionAttributes;
225 
227  std::map<const SumoXMLAttr, SUMOTime> myTimeAttributes;
228 
230  std::map<const SumoXMLAttr, RGBColor> myColorAttributes;
231 
233  std::map<const SumoXMLAttr, std::vector<std::string> > myStringListAttributes;
234 
236  std::map<const SumoXMLAttr, std::vector<double> > myDoubleListAttributes;
237 
239  std::map<const SumoXMLAttr, PositionVector> myPositionVectorAttributes;
240 
242  std::map<std::string, std::string> myParameters;
243 
245  std::vector<SumoBaseObject*> mySumoBaseObjectChildren;
246 
249 
252 
255 
258 
260  void addSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
261 
263  void removeSumoBaseObjectChild(SumoBaseObject* sumoBaseObject);
264 
265  private:
268 
271 
274 
276  void handleAttributeError(const SumoXMLAttr attr, const std::string& type) const;
277 
279  SumoBaseObject(const SumoBaseObject& s) = delete;
280 
283  };
284 
287 
290 
292  void openSUMOBaseOBject();
293 
295  void closeSUMOBaseOBject();
296 
299 
302 
303 protected:
306 
309 
310 private:
313 
316 };
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.
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
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.
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 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
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.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.