Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
CommonXMLStructure.cpp
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#include <config.h>
21
25
26#include "CommonXMLStructure.h"
27
28
29// ===========================================================================
30// method definitions
31// ===========================================================================
32
33// ---------------------------------------------------------------------------
34// CommonXMLStructure::PlanParameters - methods
35// ---------------------------------------------------------------------------
36
38
39
41 const SUMOSAXAttributes& attrs, bool& parsedOk) {
42 if (sumoBaseObject->getParentSumoBaseObject() != nullptr) {
43 // get plan parent ID (first check if exist!)
44 const auto planParentID = sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) ?
45 sumoBaseObject->getParentSumoBaseObject()->getStringAttribute(SUMO_ATTR_ID).c_str() : "";
46 // edges
47 fromEdge = attrs.getOpt<std::string>(SUMO_ATTR_FROM, planParentID, parsedOk, "");
48 toEdge = attrs.getOpt<std::string>(SUMO_ATTR_TO, planParentID, parsedOk, "");
49 if (toEdge.empty()) {
50 toEdge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, planParentID, parsedOk, "");
51 }
52 consecutiveEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EDGES, planParentID, parsedOk);
53 // junctions
54 fromJunction = attrs.getOpt<std::string>(SUMO_ATTR_FROM_JUNCTION, planParentID, parsedOk, "");
55 toJunction = attrs.getOpt<std::string>(SUMO_ATTR_TO_JUNCTION, planParentID, parsedOk, "");
56 // TAZs
57 fromTAZ = attrs.getOpt<std::string>(SUMO_ATTR_FROM_TAZ, planParentID, parsedOk, "");
58 toTAZ = attrs.getOpt<std::string>(SUMO_ATTR_TO_TAZ, planParentID, parsedOk, "");
59 // bus stops
60 fromBusStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_BUSSTOP, planParentID, parsedOk, "");
61 toBusStop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, planParentID, parsedOk, "");
62 // train stops
63 fromTrainStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_TRAINSTOP, planParentID, parsedOk, "");
64 toTrainStop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, planParentID, parsedOk, "");
65 // container stops
66 fromContainerStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_CONTAINERSTOP, planParentID, parsedOk, "");
67 toContainerStop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, planParentID, parsedOk, "");
68 // charging stations
69 fromChargingStation = attrs.getOpt<std::string>(GNE_ATTR_FROM_CHARGINGSTATION, planParentID, parsedOk, "");
70 toChargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, planParentID, parsedOk, "");
71 // parking areas
72 fromParkingArea = attrs.getOpt<std::string>(GNE_ATTR_FROM_PARKINGAREA, planParentID, parsedOk, "");
73 toParkingArea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, planParentID, parsedOk, "");
74 // routes
75 fromRoute = attrs.getOpt<std::string>(GNE_ATTR_FROM_ROUTE, planParentID, parsedOk, "");
76 toRoute = attrs.getOpt<std::string>(SUMO_ATTR_ROUTE, planParentID, parsedOk, "");
77 // update from attributes
78 updateFromAttributes(sumoBaseObject);
79 }
80}
81
82
83void
85 fromJunction.clear();
86 toJunction.clear();
87 fromEdge.clear();
88 toEdge.clear();
89 fromTAZ.clear();
90 toTAZ.clear();
91 fromBusStop.clear();
92 toBusStop.clear();
93 fromTrainStop.clear();
94 toTrainStop.clear();
95 fromContainerStop.clear();
96 toContainerStop.clear();
97 fromChargingStation.clear();
98 toChargingStation.clear();
99 fromParkingArea.clear();
100 toParkingArea.clear();
101 consecutiveEdges.clear();
102 fromRoute.clear();
103 toRoute.clear();
104}
105
106
107bool
109 if (fromEdge.empty()) {
110 return false;
111 } else {
112 return getNumberOfDefinedParameters() == 1;
113 }
114}
115
116
117int
119 return (int)consecutiveEdges.size() +
120 (fromJunction.empty() ? 0 : 1) +
121 (toJunction.empty() ? 0 : 1) +
122 (fromEdge.empty() ? 0 : 1) +
123 (toEdge.empty() ? 0 : 1) +
124 (fromTAZ.empty() ? 0 : 1) +
125 (toTAZ.empty() ? 0 : 1) +
126 (fromBusStop.empty() ? 0 : 1) +
127 (toBusStop.empty() ? 0 : 1) +
128 (fromTrainStop.empty() ? 0 : 1) +
129 (toTrainStop.empty() ? 0 : 1) +
130 (fromContainerStop.empty() ? 0 : 1) +
131 (toContainerStop.empty() ? 0 : 1) +
132 (fromChargingStation.empty() ? 0 : 1) +
133 (toChargingStation.empty() ? 0 : 1) +
134 (fromParkingArea.empty() ? 0 : 1) +
135 (toParkingArea.empty() ? 0 : 1) +
136 (fromRoute.empty() ? 0 : 1) +
137 (toRoute.empty() ? 0 : 1);
138}
139
140
143 // first check if object exist
144 if (sumoBaseObject == nullptr) {
145 return nullptr;
146 }
147 // check if object has parent
148 const CommonXMLStructure::SumoBaseObject* parentObject = sumoBaseObject->getParentSumoBaseObject();
149 if (parentObject == nullptr) {
150 return nullptr;
151 }
152 // check number of children
153 if (parentObject->getSumoBaseObjectChildren().size() < 2) {
154 return nullptr;
155 }
156 // search position of the given plan obj in the parent children
157 const auto objIterator = std::find(parentObject->getSumoBaseObjectChildren().begin(), parentObject->getSumoBaseObjectChildren().end(), sumoBaseObject);
158 // if obj is the first plan of person/container parent, then return null. If not, return previous object
159 if (objIterator == parentObject->getSumoBaseObjectChildren().begin()) {
160 return nullptr;
161 } else {
162 return *(objIterator - 1);
163 }
164}
165
166
167void
169 // check if previous plan object was defined but not the from
170 const auto previousPlanObj = getPreviousPlanObj(sumoBaseObject);
171 if (previousPlanObj) {
172 // ge previous plan parameters
173 const auto previousPlanParameters = previousPlanObj->getPlanParameters();
174 if (!previousPlanParameters.toEdge.empty()) {
175 // edge (to)
176 resetPreviousFromAttributes(previousPlanObj, "edge", previousPlanParameters.toEdge);
177 fromEdge = previousPlanParameters.toEdge;
178 } else if (!previousPlanParameters.consecutiveEdges.empty()) {
179 // consecutive edge
180 resetPreviousFromAttributes(previousPlanObj, "consecutive edge", previousPlanParameters.consecutiveEdges.back());
181 fromEdge = previousPlanParameters.consecutiveEdges.back();
182 } else if (!previousPlanParameters.toRoute.empty()) {
183 // route
184 resetPreviousFromAttributes(previousPlanObj, "route edge", previousPlanParameters.toRoute);
185 fromRoute = previousPlanParameters.toRoute;
186 } else if (!previousPlanParameters.toJunction.empty()) {
187 // junction
188 resetPreviousFromAttributes(previousPlanObj, "junction", previousPlanParameters.toJunction);
189 fromJunction = previousPlanParameters.toJunction;
190 } else if (!previousPlanParameters.toTAZ.empty()) {
191 // TAZ
192 resetPreviousFromAttributes(previousPlanObj, "TAZ", previousPlanParameters.toTAZ);
193 fromTAZ = previousPlanParameters.toTAZ;
194 } else if (!previousPlanParameters.toBusStop.empty()) {
195 // busStop
196 resetPreviousFromAttributes(previousPlanObj, "bus stop", previousPlanParameters.toBusStop);
197 fromBusStop = previousPlanParameters.toBusStop;
198 } else if (!previousPlanParameters.toTrainStop.empty()) {
199 // trainStop
200 resetPreviousFromAttributes(previousPlanObj, "train stop", previousPlanParameters.toTrainStop);
201 fromTrainStop = previousPlanParameters.toTrainStop;
202 } else if (!previousPlanParameters.toContainerStop.empty()) {
203 // containerStop
204 resetPreviousFromAttributes(previousPlanObj, "container stop", previousPlanParameters.toContainerStop);
205 fromContainerStop = previousPlanParameters.toContainerStop;
206 } else if (!previousPlanParameters.toChargingStation.empty()) {
207 // chargingStation
208 resetPreviousFromAttributes(previousPlanObj, "charging station", previousPlanParameters.toChargingStation);
209 fromChargingStation = previousPlanParameters.toChargingStation;
210 } else if (!previousPlanParameters.toParkingArea.empty()) {
211 // parkingArea
212 resetPreviousFromAttributes(previousPlanObj, "parking area", previousPlanParameters.toParkingArea);
213 fromParkingArea = previousPlanParameters.toParkingArea;
214 }
215 }
216}
217
218
219void
221 const std::string& newType, const std::string& newId) const {
222 if (!fromEdge.empty()) {
223 writeIgnoringMessage(previousPlanObj, "edge", fromEdge, newType, newId);
224 }
225 if (!fromJunction.empty()) {
226 writeIgnoringMessage(previousPlanObj, "junction", fromJunction, newType, newId);
227 }
228 if (!fromTAZ.empty()) {
229 writeIgnoringMessage(previousPlanObj, "TAZ", fromTAZ, newType, newId);
230 }
231 if (!fromBusStop.empty()) {
232 writeIgnoringMessage(previousPlanObj, "bus stop", fromBusStop, newType, newId);
233 }
234 if (!fromTrainStop.empty()) {
235 writeIgnoringMessage(previousPlanObj, "train stop", fromTrainStop, newType, newId);
236 }
237 if (!fromContainerStop.empty()) {
238 writeIgnoringMessage(previousPlanObj, "container stop", fromContainerStop, newType, newId);
239 }
240 if (!fromChargingStation.empty()) {
241 writeIgnoringMessage(previousPlanObj, "charging station", fromChargingStation, newType, newId);
242 }
243 if (!fromParkingArea.empty()) {
244 writeIgnoringMessage(previousPlanObj, "parking area", fromParkingArea, newType, newId);
245 }
246}
247
248
249void
251 const std::string& oldType, const std::string& oldId, const std::string& newType, const std::string& newId) const {
252 WRITE_WARNING(TLF("Ignoring from % '%' used in % '%' and using instead the previous end element % '%'",
253 oldType, oldId,
254 toString(previousPlanObj->getParentSumoBaseObject()->getTag()),
256 newType, newId));
257}
258
259// ---------------------------------------------------------------------------
260// CommonXMLStructure::SumoBaseObject - methods
261// ---------------------------------------------------------------------------
262
264 mySumoBaseObjectParent(parent),
265 myVehicleTypeParameter("") {
266 // add this SumoBaseObject into parent children
269 }
270}
271
272
274 // remove this SumoBaseObject from parent children
275 if (mySumoBaseObjectParent) {
276 mySumoBaseObjectParent->removeSumoBaseObjectChild(this);
277 }
278 // delete all SumoBaseObjectChildrens
279 while (mySumoBaseObjectChildren.size() > 0) {
280 delete mySumoBaseObjectChildren.back();
281 }
282}
283
284
285void
287 // reset tag
288 myTag = SUMO_TAG_NOTHING;
289 // reset vClass
290 myVClass = SVC_IGNORING;
291 // clear containers
292 myStringAttributes.clear();
293 myIntAttributes.clear();
294 myDoubleAttributes.clear();
295 myBoolAttributes.clear();
296 myPositionAttributes.clear();
297 myTimeAttributes.clear();
298 myColorAttributes.clear();
299 myStringListAttributes.clear();
300 myDoubleListAttributes.clear();
301 myPositionVectorAttributes.clear();
302 myParameters.clear();
303 mySumoBaseObjectChildren.clear();
304 // reset flags
305 myDefinedVehicleTypeParameter = false;
306 myDefinedVehicleParameter = false;
307 myDefinedStopParameter = false;
308 // delete all SumoBaseObjectChildrens
309 while (mySumoBaseObjectChildren.size() > 0) {
310 delete mySumoBaseObjectChildren.back();
311 }
312}
313
314
315void
319
320
321void
325
326
329 return myTag;
330}
331
332
333bool
335 return myWasCreated;
336}
337
338
341 return mySumoBaseObjectParent;
342}
343
344
345std::map<std::string, std::string>
347 std::map<std::string, std::string> result;
348 for (const auto& attr : myStringAttributes) {
349 result[toString(attr.first)] = attr.second;
350 }
351 for (const auto& attr : myIntAttributes) {
352 result[toString(attr.first)] = toString(attr.second);
353 }
354 for (const auto& attr : myDoubleAttributes) {
355 result[toString(attr.first)] = toString(attr.second);
356 }
357 for (const auto& attr : myBoolAttributes) {
358 result[toString(attr.first)] = toString(attr.second);
359 }
360 for (const auto& attr : myPositionAttributes) {
361 result[toString(attr.first)] = toString(attr.second);
362 }
363 for (const auto& attr : myTimeAttributes) {
364 result[toString(attr.first)] = time2string(attr.second);
365 }
366 for (const auto& attr : myColorAttributes) {
367 result[toString(attr.first)] = toString(attr.second);
368 }
369 for (const auto& attr : myStringListAttributes) {
370 result[toString(attr.first)] = toString(attr.second);
371 }
372 for (const auto& attr : myDoubleListAttributes) {
373 result[toString(attr.first)] = toString(attr.second);
374 }
375 for (const auto& attr : myPositionVectorAttributes) {
376 result[toString(attr.first)] = toString(attr.second);
377 }
378 return result;
379}
380
381
382const std::string&
384 if (hasStringAttribute(attr)) {
385 return myStringAttributes.at(attr);
386 } else {
387 handleAttributeError(attr, "string");
388 throw ProcessError();
389 }
390}
391
392
393int
395 if (hasIntAttribute(attr)) {
396 return myIntAttributes.at(attr);
397 } else {
398 handleAttributeError(attr, "int");
399 throw ProcessError();
400 }
401}
402
403
404double
406 if (hasDoubleAttribute(attr)) {
407 return myDoubleAttributes.at(attr);
408 } else {
409 handleAttributeError(attr, "double");
410 throw ProcessError();
411 }
412}
413
414
415bool
417 if (hasBoolAttribute(attr)) {
418 return myBoolAttributes.at(attr);
419 } else {
420 handleAttributeError(attr, "bool");
421 throw ProcessError();
422 }
423}
424
425
426const Position&
428 if (hasPositionAttribute(attr)) {
429 return myPositionAttributes.at(attr);
430 } else {
431 handleAttributeError(attr, "position");
432 throw ProcessError();
433 }
434}
435
436
439 if (hasTimeAttribute(attr)) {
440 return myTimeAttributes.at(attr);
441 } else {
442 handleAttributeError(attr, "time");
443 throw ProcessError();
444 }
445}
446
447
451 if (hasTimeAttribute(attr)) {
452 return myTimeAttributes.at(attr);
453 } else {
454 // try 'freq' as alias for 'period'
455 attr = SUMO_ATTR_FREQUENCY;
456 if (hasTimeAttribute(attr)) {
457 return myTimeAttributes.at(attr);
458 }
459 handleAttributeError(SUMO_ATTR_PERIOD, "time");
460 throw ProcessError();
461 }
462}
463
464
465const RGBColor&
467 if (hasColorAttribute(attr)) {
468 return myColorAttributes.at(attr);
469 } else {
470 handleAttributeError(attr, "color");
471 throw ProcessError();
472 }
473}
474
475
476const std::vector<std::string>&
478 if (hasStringListAttribute(attr)) {
479 return myStringListAttributes.at(attr);
480 } else {
481 handleAttributeError(attr, "string list");
482 throw ProcessError();
483 }
484}
485
486
487const std::vector<double>&
489 if (hasDoubleListAttribute(attr)) {
490 return myDoubleListAttributes.at(attr);
491 } else {
492 handleAttributeError(attr, "double list");
493 throw ProcessError();
494 }
495}
496
497
498const PositionVector&
500 if (hasPositionVectorAttribute(attr)) {
501 return myPositionVectorAttributes.at(attr);
502 } else {
503 handleAttributeError(attr, "position vector");
504 throw ProcessError();
505 }
506}
507
508
511 return myVClass;
512}
513
514
517 if (myDefinedVehicleTypeParameter) {
518 return myVehicleTypeParameter;
519 } else {
520 throw ProcessError(TL("Undefined vehicleType parameter"));
521 }
522}
523
524
527 if (myDefinedVehicleParameter) {
528 return myVehicleParameter;
529 } else {
530 throw ProcessError(TL("Undefined vehicle parameter"));
531 }
532}
533
534
537 if (myDefinedStopParameter) {
538 return myStopParameter;
539 } else {
540 throw ProcessError(TL("Undefined stop parameter"));
541 }
542
543}
544
545
546const std::map<std::string, std::string>&
548 return myParameters;
549}
550
551
554 return myPlanParameters;
555}
556
557
558const std::vector<CommonXMLStructure::SumoBaseObject*>&
560 return mySumoBaseObjectChildren;
561}
562
563
564bool
566 return myStringAttributes.count(attr) > 0;
567}
568
569
570bool
572 return myIntAttributes.count(attr) > 0;
573}
574
575
576bool
578 return myDoubleAttributes.count(attr) > 0;
579}
580
581
582bool
584 return myBoolAttributes.count(attr) > 0;
585}
586
587
588bool
590 return myPositionAttributes.count(attr) > 0;
591}
592
593
594bool
596 return myTimeAttributes.count(attr) > 0;
597}
598
599
600bool
602 return myColorAttributes.count(attr) > 0;
603}
604
605
606bool
608 return myStringListAttributes.count(attr) > 0;
609}
610
611
612bool
614 return myDoubleListAttributes.count(attr) > 0;
615}
616
617
618bool
620 return myPositionVectorAttributes.count(attr) > 0;
621}
622
623
624void
626 myStringAttributes[attr] = value;
627}
628
629
630void
632 myIntAttributes[attr] = value;
633}
634
635
636void
638 myDoubleAttributes[attr] = value;
639}
640
641
642void
644 myBoolAttributes[attr] = value;
645}
646
647
648void
650 myPositionAttributes[attr] = value;
651}
652
653
654void
656 myTimeAttributes[attr] = value;
657}
658
659
660void
662 myColorAttributes[attr] = value;
663}
664
665
666void
667CommonXMLStructure::SumoBaseObject::addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value) {
668 myStringListAttributes[attr] = value;
669}
670
671
672void
673CommonXMLStructure::SumoBaseObject::addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value) {
674 myDoubleListAttributes[attr] = value;
675}
676
677
678void
680 myPositionVectorAttributes[attr] = value;
681}
682
683
684void
685CommonXMLStructure::SumoBaseObject::addParameter(const std::string& key, const std::string& value) {
686 // check if we have to insert in vType, vehicle or stop parameters
687 if (myDefinedVehicleTypeParameter) {
688 myVehicleTypeParameter.setParameter(key, value);
689 } else if (myDefinedVehicleParameter) {
690 myVehicleParameter.setParameter(key, value);
691 } else if (myDefinedStopParameter) {
692 myStopParameter.setParameter(key, value);
693 } else {
694 myParameters[key] = value;
695 }
696}
697
698
699void
703
704
705void
707 myVehicleTypeParameter = *vehicleTypeParameter;
708 myDefinedVehicleTypeParameter = true;
709 // set attribute id
710 addStringAttribute(SUMO_ATTR_ID, myVehicleTypeParameter.id);
711}
712
713
714void
716 myVehicleParameter = *vehicleParameter;
717 myDefinedVehicleParameter = true;
718 // set attribute id
719 if (!myVehicleParameter.id.empty()) {
720 addStringAttribute(SUMO_ATTR_ID, myVehicleParameter.id);
721 }
722 // set attribute route
723 if (!vehicleParameter->routeid.empty()) {
724 addStringAttribute(SUMO_ATTR_ROUTE, myVehicleParameter.routeid);
725 }
726}
727
728
729void
731 myStopParameter = stopParameter;
732 myDefinedStopParameter = true;
733 // set attribute edge
734 if (!myStopParameter.edge.empty()) {
735 addStringAttribute(SUMO_ATTR_EDGE, myStopParameter.edge);
736 }
737 // set attribute lane
738 if (!myStopParameter.lane.empty()) {
739 addStringAttribute(SUMO_ATTR_LANE, myStopParameter.lane);
740 }
741 // set attribute busStop
742 if (!myStopParameter.busstop.empty()) {
743 addStringAttribute(SUMO_ATTR_BUS_STOP, myStopParameter.busstop);
744 }
745 // set attribute containerstop
746 if (!myStopParameter.containerstop.empty()) {
747 addStringAttribute(SUMO_ATTR_CONTAINER_STOP, myStopParameter.containerstop);
748 }
749 // set attribute parkingarea
750 if (!myStopParameter.parkingarea.empty()) {
751 addStringAttribute(SUMO_ATTR_PARKING_AREA, myStopParameter.parkingarea);
752 }
753 // set attribute chargingStation
754 if (!myStopParameter.chargingStation.empty()) {
755 addStringAttribute(SUMO_ATTR_CHARGING_STATION, myStopParameter.chargingStation);
756 }
757}
758
759
760void
762 myPlanParameters = planParameters;
763}
764
765void
767 // just add it into mySumoBaseObjectChildren
768 mySumoBaseObjectChildren.push_back(sumoBaseObject);
769}
770
771
772void
774 // find sumoBaseObject
775 auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
776 // check iterator
777 if (it != mySumoBaseObjectChildren.end()) {
778 mySumoBaseObjectChildren.erase(it);
779 }
780}
781
782
783void
785 WRITE_ERRORF(TL("Trying to get undefined % attribute '%' in SUMOBaseObject '%'"), type, toString(attr), toString(myTag));
786}
787
788// ---------------------------------------------------------------------------
789// CommonXMLStructure - methods
790// ---------------------------------------------------------------------------
791
797
798
800 // delete mySumoBaseObjectRoot (this will also delete all SumoBaseObjectChildrens)
803 }
804}
805
806
807void
809 // first check if root is empty
810 if (mySumoBaseObjectRoot == nullptr) {
811 // create root
813 // set tag
815 // update last inserted Root
817 } else {
818 // create new node
819 SumoBaseObject* newSumoBaseObject = new SumoBaseObject(myCurrentSumoBaseObject);
820 // update last inserted node
821 myCurrentSumoBaseObject = newSumoBaseObject;
822 }
823}
824
825
826void
828 // check that myCurrentSumoBaseObject is valid
830 // check if last inserted SumoBaseObject is the root
832 // reset both pointers
833 myCurrentSumoBaseObject = nullptr;
834 mySumoBaseObjectRoot = nullptr;
835 } else {
836 // update last inserted SumoBaseObject
838 }
839 }
840}
841
842
843void
845 // delete current sumo base object and use their parent as sumo base object
849 myCurrentSumoBaseObject = nullptr;
850 mySumoBaseObjectRoot = nullptr;
851 } else {
852 auto parentSumoBaseObject = myCurrentSumoBaseObject->getParentSumoBaseObject();
854 myCurrentSumoBaseObject = parentSumoBaseObject;
855 }
856 }
857}
858
859
864
865
870
871/****************************************************************************/
long long int SUMOTime
Definition GUI.h:36
#define WRITE_ERRORF(...)
Definition MsgHandler.h:305
#define WRITE_WARNING(msg)
Definition MsgHandler.h:295
#define TL(string)
Definition MsgHandler.h:315
#define TLF(string,...)
Definition MsgHandler.h:317
std::string time2string(SUMOTime t, bool humanReadable)
convert SUMOTime to string (independently of global format setting)
Definition SUMOTime.cpp:69
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.
@ GNE_ATTR_FROM_TRAINSTOP
@ SUMO_ATTR_LANE
@ GNE_ATTR_FROM_BUSSTOP
@ SUMO_ATTR_FROM_JUNCTION
@ SUMO_ATTR_CONTAINER_STOP
@ SUMO_ATTR_PARKING_AREA
@ SUMO_ATTR_EDGE
@ SUMO_ATTR_BUS_STOP
@ SUMO_ATTR_TRAIN_STOP
@ SUMO_ATTR_TO_JUNCTION
@ SUMO_ATTR_EDGES
the edges of a route
@ SUMO_ATTR_CHARGING_STATION
@ GNE_ATTR_FROM_PARKINGAREA
@ GNE_ATTR_FROM_CONTAINERSTOP
@ SUMO_ATTR_PERIOD
@ SUMO_ATTR_TO_TAZ
@ SUMO_ATTR_FREQUENCY
@ SUMO_ATTR_TO
@ SUMO_ATTR_FROM
@ SUMO_ATTR_FROM_TAZ
@ GNE_ATTR_FROM_ROUTE
@ GNE_ATTR_FROM_CHARGINGSTATION
@ SUMO_ATTR_ROUTE
@ SUMO_ATTR_ID
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
plan parameters (used for group all from-to parameters related with plans)
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
const CommonXMLStructure::SumoBaseObject * getPreviousPlanObj(const CommonXMLStructure::SumoBaseObject *sumoBaseObject) const
get previous plan obj
bool isSingleEdgePlan() const
check if this is a single-edge plan
void updateFromAttributes(const CommonXMLStructure::SumoBaseObject *sumoBaseObject)
update the from attributes
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
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
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
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
void setPlanParameters(const CommonXMLStructure::PlanParameters &planParameters)
set plan parmeter
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
bool hasColorAttribute(const SumoXMLAttr attr) const
check if current SumoBaseObject has the given color attribute
void markAsCreated()
mark as successfully created
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
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
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 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
void abortSUMOBaseOBject()
abort SUMOBaseOBject
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 SUMOBaseOBject
A point in 2D or 3D with translation and scaling methods.
Definition Position.h:37
A list of positions.
Encapsulated SAX-Attributes.
T getOpt(int attr, const char *objectid, bool &ok, T defaultValue=T(), bool report=true) const
Tries to read given attribute assuming it is an int.
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.