37 mySumoBaseObjectParent(parent),
40 myVehicleTypeParameter(
""),
41 myDefinedVehicleTypeParameter(false),
42 myDefinedVehicleParameter(false),
43 myDefinedStopParameter(false) {
53 if (mySumoBaseObjectParent) {
54 mySumoBaseObjectParent->removeSumoBaseObjectChild(
this);
57 while (mySumoBaseObjectChildren.size() > 0) {
58 delete mySumoBaseObjectChildren.back();
70 myStringAttributes.clear();
71 myIntAttributes.clear();
72 myDoubleAttributes.clear();
73 myBoolAttributes.clear();
74 myPositionAttributes.clear();
75 myTimeAttributes.clear();
76 myColorAttributes.clear();
77 myStringListAttributes.clear();
78 myDoubleListAttributes.clear();
79 myPositionVectorAttributes.clear();
81 mySumoBaseObjectChildren.clear();
83 myDefinedVehicleTypeParameter =
false;
84 myDefinedVehicleParameter =
false;
85 myDefinedStopParameter =
false;
87 while (mySumoBaseObjectChildren.size() > 0) {
88 delete mySumoBaseObjectChildren.back();
107 return mySumoBaseObjectParent;
111 std::map<std::string, std::string>
113 std::map<std::string, std::string> result;
114 for (
const auto& attr : myStringAttributes) {
115 result[
toString(attr.first)] = attr.second;
117 for (
const auto& attr : myIntAttributes) {
120 for (
const auto& attr : myDoubleAttributes) {
123 for (
const auto& attr : myBoolAttributes) {
126 for (
const auto& attr : myPositionAttributes) {
129 for (
const auto& attr : myTimeAttributes) {
132 for (
const auto& attr : myColorAttributes) {
135 for (
const auto& attr : myStringListAttributes) {
138 for (
const auto& attr : myDoubleListAttributes) {
141 for (
const auto& attr : myPositionVectorAttributes) {
150 if (hasStringAttribute(attr)) {
151 return myStringAttributes.at(attr);
153 handleAttributeError(attr,
"string");
161 if (hasIntAttribute(attr)) {
162 return myIntAttributes.at(attr);
164 handleAttributeError(attr,
"int");
172 if (hasDoubleAttribute(attr)) {
173 return myDoubleAttributes.at(attr);
175 handleAttributeError(attr,
"double");
183 if (hasBoolAttribute(attr)) {
184 return myBoolAttributes.at(attr);
186 handleAttributeError(attr,
"bool");
194 if (hasPositionAttribute(attr)) {
195 return myPositionAttributes.at(attr);
197 handleAttributeError(attr,
"position");
205 if (hasTimeAttribute(attr)) {
206 return myTimeAttributes.at(attr);
208 handleAttributeError(attr,
"time");
217 if (hasTimeAttribute(attr)) {
218 return myTimeAttributes.at(attr);
222 if (hasTimeAttribute(attr)) {
223 return myTimeAttributes.at(attr);
233 if (hasColorAttribute(attr)) {
234 return myColorAttributes.at(attr);
236 handleAttributeError(attr,
"color");
242 const std::vector<std::string>&
244 if (hasStringListAttribute(attr)) {
245 return myStringListAttributes.at(attr);
247 handleAttributeError(attr,
"string list");
253 const std::vector<double>&
255 if (hasDoubleListAttribute(attr)) {
256 return myDoubleListAttributes.at(attr);
258 handleAttributeError(attr,
"double list");
266 if (hasPositionVectorAttribute(attr)) {
267 return myPositionVectorAttributes.at(attr);
269 handleAttributeError(attr,
"position vector");
283 if (myDefinedVehicleTypeParameter) {
284 return myVehicleTypeParameter;
293 if (myDefinedVehicleParameter) {
294 return myVehicleParameter;
303 if (myDefinedStopParameter) {
304 return myStopParameter;
312 const std::map<std::string, std::string>&
318 const std::vector<CommonXMLStructure::SumoBaseObject*>&
320 return mySumoBaseObjectChildren;
326 return myStringAttributes.count(attr) > 0;
332 return myIntAttributes.count(attr) > 0;
338 return myDoubleAttributes.count(attr) > 0;
344 return myBoolAttributes.count(attr) > 0;
350 return myPositionAttributes.count(attr) > 0;
356 return myTimeAttributes.count(attr) > 0;
362 return myColorAttributes.count(attr) > 0;
368 return myStringListAttributes.count(attr) > 0;
374 return myDoubleListAttributes.count(attr) > 0;
380 return myPositionVectorAttributes.count(attr) > 0;
386 myStringAttributes[attr] = value;
392 myIntAttributes[attr] = value;
398 myDoubleAttributes[attr] = value;
404 myBoolAttributes[attr] = value;
410 myPositionAttributes[attr] = value;
416 myTimeAttributes[attr] = value;
422 myColorAttributes[attr] = value;
428 myStringListAttributes[attr] = value;
434 myDoubleListAttributes[attr] = value;
440 myPositionVectorAttributes[attr] = value;
452 myVehicleTypeParameter = *vehicleTypeParameter;
453 myDefinedVehicleTypeParameter =
true;
455 addStringAttribute(
SUMO_ATTR_ID, myVehicleTypeParameter.id);
461 myVehicleParameter = *vehicleParameter;
462 myDefinedVehicleParameter =
true;
464 if (!myVehicleParameter.id.empty()) {
465 addStringAttribute(
SUMO_ATTR_ID, myVehicleParameter.id);
468 if (!vehicleParameter->
routeid.empty()) {
476 myStopParameter = stopParameter;
477 myDefinedStopParameter =
true;
479 if (!myStopParameter.edge.empty()) {
483 if (!myStopParameter.lane.empty()) {
487 if (!myStopParameter.busstop.empty()) {
491 if (!myStopParameter.containerstop.empty()) {
495 if (!myStopParameter.parkingarea.empty()) {
499 if (!myStopParameter.chargingStation.empty()) {
508 if (myDefinedVehicleTypeParameter) {
509 myVehicleTypeParameter.setParameter(key, value);
510 }
else if (myDefinedVehicleParameter) {
511 myVehicleParameter.setParameter(key, value);
512 }
else if (myDefinedStopParameter) {
513 myStopParameter.setParameter(key, value);
515 myParameters[key] = value;
523 mySumoBaseObjectChildren.push_back(sumoBaseObject);
530 auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
532 if (it != mySumoBaseObjectChildren.end()) {
533 mySumoBaseObjectChildren.erase(it);
#define WRITE_ERRORF(...)
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
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
@ SUMO_TAG_ROOTFILE
root file
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_CHARGING_STATION
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
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
const SUMOVehicleParameter::Stop & getStopParameter() const
get stop parameters
const RGBColor & getColorAttribute(const SumoXMLAttr attr) const
get color attribute
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
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
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
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
SUMOVehicleClass getVClass() const
vehicle class
SumoBaseObject * mySumoBaseObjectParent
pointer to SumoBaseObject parent (If is null, then is the root)
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
const SUMOVTypeParameter & getVehicleTypeParameter() const
get current vType
SumoXMLTag getTag() const
get XML myTag
void addParameter(const std::string &key, const std::string &value)
add parameter into current SumoBaseObject node
~SumoBaseObject()
destructor
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
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
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
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
const std::vector< SumoBaseObject * > & getSumoBaseObjectChildren() const
get SumoBaseObject children
CommonXMLStructure::SumoBaseObject * getSumoBaseObjectRoot() const
get SumoBaseObject root
CommonXMLStructure::SumoBaseObject * getCurrentSumoBaseObject() const
get current editedSumoBaseObject
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.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.
std::string routeid
The vehicle's route id.