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 // get plan parent ID (first check if exist!)
43 const auto planParentID = sumoBaseObject->getParentSumoBaseObject()->hasStringAttribute(SUMO_ATTR_ID) ?
44 sumoBaseObject->getParentSumoBaseObject()->getStringAttribute(SUMO_ATTR_ID).c_str() : "";
45 // edges
46 fromEdge = attrs.getOpt<std::string>(SUMO_ATTR_FROM, planParentID, parsedOk, "");
47 toEdge = attrs.getOpt<std::string>(SUMO_ATTR_TO, planParentID, parsedOk, "");
48 if (toEdge.empty()) {
49 toEdge = attrs.getOpt<std::string>(SUMO_ATTR_EDGE, planParentID, parsedOk, "");
50 }
51 consecutiveEdges = attrs.getOpt<std::vector<std::string> >(SUMO_ATTR_EDGES, planParentID, parsedOk);
52 // junctions
53 fromJunction = attrs.getOpt<std::string>(SUMO_ATTR_FROM_JUNCTION, planParentID, parsedOk, "");
54 toJunction = attrs.getOpt<std::string>(SUMO_ATTR_TO_JUNCTION, planParentID, parsedOk, "");
55 // TAZs
56 fromTAZ = attrs.getOpt<std::string>(SUMO_ATTR_FROM_TAZ, planParentID, parsedOk, "");
57 toTAZ = attrs.getOpt<std::string>(SUMO_ATTR_TO_TAZ, planParentID, parsedOk, "");
58 // bus stops
59 fromBusStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_BUSSTOP, planParentID, parsedOk, "");
60 toBusStop = attrs.getOpt<std::string>(SUMO_ATTR_BUS_STOP, planParentID, parsedOk, "");
61 // train stops
62 fromTrainStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_TRAINSTOP, planParentID, parsedOk, "");
63 toTrainStop = attrs.getOpt<std::string>(SUMO_ATTR_TRAIN_STOP, planParentID, parsedOk, "");
64 // container stops
65 fromContainerStop = attrs.getOpt<std::string>(GNE_ATTR_FROM_CONTAINERSTOP, planParentID, parsedOk, "");
66 toContainerStop = attrs.getOpt<std::string>(SUMO_ATTR_CONTAINER_STOP, planParentID, parsedOk, "");
67 // charging stations
68 fromChargingStation = attrs.getOpt<std::string>(GNE_ATTR_FROM_CHARGINGSTATION, planParentID, parsedOk, "");
69 toChargingStation = attrs.getOpt<std::string>(SUMO_ATTR_CHARGING_STATION, planParentID, parsedOk, "");
70 // parking areas
71 fromParkingArea = attrs.getOpt<std::string>(GNE_ATTR_FROM_PARKINGAREA, planParentID, parsedOk, "");
72 toParkingArea = attrs.getOpt<std::string>(SUMO_ATTR_PARKING_AREA, planParentID, parsedOk, "");
73 // routes
74 fromRoute = attrs.getOpt<std::string>(GNE_ATTR_FROM_ROUTE, planParentID, parsedOk, "");
75 toRoute = attrs.getOpt<std::string>(SUMO_ATTR_ROUTE, planParentID, parsedOk, "");
76 // update from attributes
77 updateFromAttributes(sumoBaseObject);
78}
79
80
81void
83 fromJunction.clear();
84 toJunction.clear();
85 fromEdge.clear();
86 toEdge.clear();
87 fromTAZ.clear();
88 toTAZ.clear();
89 fromBusStop.clear();
90 toBusStop.clear();
91 fromTrainStop.clear();
92 toTrainStop.clear();
93 fromContainerStop.clear();
94 toContainerStop.clear();
95 fromChargingStation.clear();
96 toChargingStation.clear();
97 fromParkingArea.clear();
98 toParkingArea.clear();
99 consecutiveEdges.clear();
100 fromRoute.clear();
101 toRoute.clear();
102}
103
104
105bool
107 if (fromEdge.empty()) {
108 return false;
109 } else {
110 return getNumberOfDefinedParameters() == 1;
111 }
112}
113
114
115int
117 return (int)consecutiveEdges.size() +
118 (fromJunction.empty() ? 0 : 1) +
119 (toJunction.empty() ? 0 : 1) +
120 (fromEdge.empty() ? 0 : 1) +
121 (toEdge.empty() ? 0 : 1) +
122 (fromTAZ.empty() ? 0 : 1) +
123 (toTAZ.empty() ? 0 : 1) +
124 (fromBusStop.empty() ? 0 : 1) +
125 (toBusStop.empty() ? 0 : 1) +
126 (fromTrainStop.empty() ? 0 : 1) +
127 (toTrainStop.empty() ? 0 : 1) +
128 (fromContainerStop.empty() ? 0 : 1) +
129 (toContainerStop.empty() ? 0 : 1) +
130 (fromChargingStation.empty() ? 0 : 1) +
131 (toChargingStation.empty() ? 0 : 1) +
132 (fromParkingArea.empty() ? 0 : 1) +
133 (toParkingArea.empty() ? 0 : 1) +
134 (fromRoute.empty() ? 0 : 1) +
135 (toRoute.empty() ? 0 : 1);
136}
137
138
141 // first check if object exist
142 if (sumoBaseObject == nullptr) {
143 return nullptr;
144 }
145 // check if object has parent
146 const CommonXMLStructure::SumoBaseObject* parentObject = sumoBaseObject->getParentSumoBaseObject();
147 if (parentObject == nullptr) {
148 return nullptr;
149 }
150 // check number of children
151 if (parentObject->getSumoBaseObjectChildren().size() < 2) {
152 return nullptr;
153 }
154 // search position of the given plan obj in the parent children
155 const auto objIterator = std::find(parentObject->getSumoBaseObjectChildren().begin(), parentObject->getSumoBaseObjectChildren().end(), sumoBaseObject);
156 // if obj is the first plan of person/container parent, then return null. If not, return previous object
157 if (objIterator == parentObject->getSumoBaseObjectChildren().begin()) {
158 return nullptr;
159 } else {
160 return *(objIterator - 1);
161 }
162}
163
164
165void
167 // check if previous plan object was defined but not the from
168 const auto previousPlanObj = getPreviousPlanObj(sumoBaseObject);
169 if (previousPlanObj) {
170 // ge previous plan parameters
171 const auto previousPlanParameters = previousPlanObj->getPlanParameters();
172 if (!previousPlanParameters.toEdge.empty()) {
173 // edge (to)
174 resetPreviousFromAttributes(previousPlanObj, "edge", previousPlanParameters.toEdge);
175 fromEdge = previousPlanParameters.toEdge;
176 } else if (!previousPlanParameters.consecutiveEdges.empty()) {
177 // consecutive edge
178 resetPreviousFromAttributes(previousPlanObj, "consecutive edge", previousPlanParameters.consecutiveEdges.back());
179 fromEdge = previousPlanParameters.consecutiveEdges.back();
180 } else if (!previousPlanParameters.toRoute.empty()) {
181 // route
182 resetPreviousFromAttributes(previousPlanObj, "route edge", previousPlanParameters.toRoute);
183 fromRoute = previousPlanParameters.toRoute;
184 } else if (!previousPlanParameters.toJunction.empty()) {
185 // junction
186 resetPreviousFromAttributes(previousPlanObj, "junction", previousPlanParameters.toJunction);
187 fromJunction = previousPlanParameters.toJunction;
188 } else if (!previousPlanParameters.toTAZ.empty()) {
189 // TAZ
190 resetPreviousFromAttributes(previousPlanObj, "TAZ", previousPlanParameters.toTAZ);
191 fromTAZ = previousPlanParameters.toTAZ;
192 } else if (!previousPlanParameters.toBusStop.empty()) {
193 // busStop
194 resetPreviousFromAttributes(previousPlanObj, "bus stop", previousPlanParameters.toBusStop);
195 fromBusStop = previousPlanParameters.toBusStop;
196 } else if (!previousPlanParameters.toTrainStop.empty()) {
197 // trainStop
198 resetPreviousFromAttributes(previousPlanObj, "train stop", previousPlanParameters.toTrainStop);
199 fromTrainStop = previousPlanParameters.toTrainStop;
200 } else if (!previousPlanParameters.toContainerStop.empty()) {
201 // containerStop
202 resetPreviousFromAttributes(previousPlanObj, "container stop", previousPlanParameters.toContainerStop);
203 fromContainerStop = previousPlanParameters.toContainerStop;
204 } else if (!previousPlanParameters.toChargingStation.empty()) {
205 // chargingStation
206 resetPreviousFromAttributes(previousPlanObj, "charging station", previousPlanParameters.toChargingStation);
207 fromChargingStation = previousPlanParameters.toChargingStation;
208 } else if (!previousPlanParameters.toParkingArea.empty()) {
209 // parkingArea
210 resetPreviousFromAttributes(previousPlanObj, "parking area", previousPlanParameters.toParkingArea);
211 fromParkingArea = previousPlanParameters.toParkingArea;
212 }
213 }
214}
215
216
217void
219 const std::string& newType, const std::string& newId) const {
220 if (!fromEdge.empty()) {
221 writeIgnoringMessage(previousPlanObj, "edge", fromEdge, newType, newId);
222 }
223 if (!fromJunction.empty()) {
224 writeIgnoringMessage(previousPlanObj, "junction", fromJunction, newType, newId);
225 }
226 if (!fromTAZ.empty()) {
227 writeIgnoringMessage(previousPlanObj, "TAZ", fromTAZ, newType, newId);
228 }
229 if (!fromBusStop.empty()) {
230 writeIgnoringMessage(previousPlanObj, "bus stop", fromBusStop, newType, newId);
231 }
232 if (!fromTrainStop.empty()) {
233 writeIgnoringMessage(previousPlanObj, "train stop", fromTrainStop, newType, newId);
234 }
235 if (!fromContainerStop.empty()) {
236 writeIgnoringMessage(previousPlanObj, "container stop", fromContainerStop, newType, newId);
237 }
238 if (!fromChargingStation.empty()) {
239 writeIgnoringMessage(previousPlanObj, "charging station", fromChargingStation, newType, newId);
240 }
241 if (!fromParkingArea.empty()) {
242 writeIgnoringMessage(previousPlanObj, "parking area", fromParkingArea, newType, newId);
243 }
244}
245
246
247void
249 const std::string& oldType, const std::string& oldId, const std::string& newType, const std::string& newId) const {
250 WRITE_WARNING(TLF("Ignoring from % '%' used in % '%' and using instead the previous end element % '%'",
251 oldType, oldId,
252 toString(previousPlanObj->getParentSumoBaseObject()->getTag()),
254 newType, newId));
255}
256
257// ---------------------------------------------------------------------------
258// CommonXMLStructure::SumoBaseObject - methods
259// ---------------------------------------------------------------------------
260
262 mySumoBaseObjectParent(parent),
263 myTag(SUMO_TAG_NOTHING),
264 myVClass(SVC_IGNORING),
265 myVehicleTypeParameter(""),
266 myDefinedVehicleTypeParameter(false),
267 myDefinedVehicleParameter(false),
268 myDefinedStopParameter(false) {
269 // add this SumoBaseObject into parent children
272 }
273}
274
275
277 // remove this SumoBaseObject from parent children
278 if (mySumoBaseObjectParent) {
279 mySumoBaseObjectParent->removeSumoBaseObjectChild(this);
280 }
281 // delete all SumoBaseObjectChildrens
282 while (mySumoBaseObjectChildren.size() > 0) {
283 delete mySumoBaseObjectChildren.back();
284 }
285}
286
287
288void
290 // reset tag
291 myTag = SUMO_TAG_NOTHING;
292 // reset vClass
293 myVClass = SVC_IGNORING;
294 // clear containers
295 myStringAttributes.clear();
296 myIntAttributes.clear();
297 myDoubleAttributes.clear();
298 myBoolAttributes.clear();
299 myPositionAttributes.clear();
300 myTimeAttributes.clear();
301 myColorAttributes.clear();
302 myStringListAttributes.clear();
303 myDoubleListAttributes.clear();
304 myPositionVectorAttributes.clear();
305 myParameters.clear();
306 mySumoBaseObjectChildren.clear();
307 // reset flags
308 myDefinedVehicleTypeParameter = false;
309 myDefinedVehicleParameter = false;
310 myDefinedStopParameter = false;
311 // delete all SumoBaseObjectChildrens
312 while (mySumoBaseObjectChildren.size() > 0) {
313 delete mySumoBaseObjectChildren.back();
314 }
315}
316
317
318void
322
323
326 return myTag;
327}
328
329
332 return mySumoBaseObjectParent;
333}
334
335
336std::map<std::string, std::string>
338 std::map<std::string, std::string> result;
339 for (const auto& attr : myStringAttributes) {
340 result[toString(attr.first)] = attr.second;
341 }
342 for (const auto& attr : myIntAttributes) {
343 result[toString(attr.first)] = toString(attr.second);
344 }
345 for (const auto& attr : myDoubleAttributes) {
346 result[toString(attr.first)] = toString(attr.second);
347 }
348 for (const auto& attr : myBoolAttributes) {
349 result[toString(attr.first)] = toString(attr.second);
350 }
351 for (const auto& attr : myPositionAttributes) {
352 result[toString(attr.first)] = toString(attr.second);
353 }
354 for (const auto& attr : myTimeAttributes) {
355 result[toString(attr.first)] = time2string(attr.second);
356 }
357 for (const auto& attr : myColorAttributes) {
358 result[toString(attr.first)] = toString(attr.second);
359 }
360 for (const auto& attr : myStringListAttributes) {
361 result[toString(attr.first)] = toString(attr.second);
362 }
363 for (const auto& attr : myDoubleListAttributes) {
364 result[toString(attr.first)] = toString(attr.second);
365 }
366 for (const auto& attr : myPositionVectorAttributes) {
367 result[toString(attr.first)] = toString(attr.second);
368 }
369 return result;
370}
371
372
373const std::string&
375 if (hasStringAttribute(attr)) {
376 return myStringAttributes.at(attr);
377 } else {
378 handleAttributeError(attr, "string");
379 throw ProcessError();
380 }
381}
382
383
384int
386 if (hasIntAttribute(attr)) {
387 return myIntAttributes.at(attr);
388 } else {
389 handleAttributeError(attr, "int");
390 throw ProcessError();
391 }
392}
393
394
395double
397 if (hasDoubleAttribute(attr)) {
398 return myDoubleAttributes.at(attr);
399 } else {
400 handleAttributeError(attr, "double");
401 throw ProcessError();
402 }
403}
404
405
406bool
408 if (hasBoolAttribute(attr)) {
409 return myBoolAttributes.at(attr);
410 } else {
411 handleAttributeError(attr, "bool");
412 throw ProcessError();
413 }
414}
415
416
417const Position&
419 if (hasPositionAttribute(attr)) {
420 return myPositionAttributes.at(attr);
421 } else {
422 handleAttributeError(attr, "position");
423 throw ProcessError();
424 }
425}
426
427
430 if (hasTimeAttribute(attr)) {
431 return myTimeAttributes.at(attr);
432 } else {
433 handleAttributeError(attr, "time");
434 throw ProcessError();
435 }
436}
437
438
442 if (hasTimeAttribute(attr)) {
443 return myTimeAttributes.at(attr);
444 } else {
445 // try 'freq' as alias for 'period'
446 attr = SUMO_ATTR_FREQUENCY;
447 if (hasTimeAttribute(attr)) {
448 return myTimeAttributes.at(attr);
449 }
450 handleAttributeError(SUMO_ATTR_PERIOD, "time");
451 throw ProcessError();
452 }
453}
454
455
456const RGBColor&
458 if (hasColorAttribute(attr)) {
459 return myColorAttributes.at(attr);
460 } else {
461 handleAttributeError(attr, "color");
462 throw ProcessError();
463 }
464}
465
466
467const std::vector<std::string>&
469 if (hasStringListAttribute(attr)) {
470 return myStringListAttributes.at(attr);
471 } else {
472 handleAttributeError(attr, "string list");
473 throw ProcessError();
474 }
475}
476
477
478const std::vector<double>&
480 if (hasDoubleListAttribute(attr)) {
481 return myDoubleListAttributes.at(attr);
482 } else {
483 handleAttributeError(attr, "double list");
484 throw ProcessError();
485 }
486}
487
488
489const PositionVector&
491 if (hasPositionVectorAttribute(attr)) {
492 return myPositionVectorAttributes.at(attr);
493 } else {
494 handleAttributeError(attr, "position vector");
495 throw ProcessError();
496 }
497}
498
499
502 return myVClass;
503}
504
505
508 if (myDefinedVehicleTypeParameter) {
509 return myVehicleTypeParameter;
510 } else {
511 throw ProcessError(TL("Undefined vehicleType parameter"));
512 }
513}
514
515
518 if (myDefinedVehicleParameter) {
519 return myVehicleParameter;
520 } else {
521 throw ProcessError(TL("Undefined vehicle parameter"));
522 }
523}
524
525
528 if (myDefinedStopParameter) {
529 return myStopParameter;
530 } else {
531 throw ProcessError(TL("Undefined stop parameter"));
532 }
533
534}
535
536
537const std::map<std::string, std::string>&
539 return myParameters;
540}
541
542
545 return myPlanParameters;
546}
547
548
549const std::vector<CommonXMLStructure::SumoBaseObject*>&
551 return mySumoBaseObjectChildren;
552}
553
554
555bool
557 return myStringAttributes.count(attr) > 0;
558}
559
560
561bool
563 return myIntAttributes.count(attr) > 0;
564}
565
566
567bool
569 return myDoubleAttributes.count(attr) > 0;
570}
571
572
573bool
575 return myBoolAttributes.count(attr) > 0;
576}
577
578
579bool
581 return myPositionAttributes.count(attr) > 0;
582}
583
584
585bool
587 return myTimeAttributes.count(attr) > 0;
588}
589
590
591bool
593 return myColorAttributes.count(attr) > 0;
594}
595
596
597bool
599 return myStringListAttributes.count(attr) > 0;
600}
601
602
603bool
605 return myDoubleListAttributes.count(attr) > 0;
606}
607
608
609bool
611 return myPositionVectorAttributes.count(attr) > 0;
612}
613
614
615void
617 myStringAttributes[attr] = value;
618}
619
620
621void
623 myIntAttributes[attr] = value;
624}
625
626
627void
629 myDoubleAttributes[attr] = value;
630}
631
632
633void
635 myBoolAttributes[attr] = value;
636}
637
638
639void
641 myPositionAttributes[attr] = value;
642}
643
644
645void
647 myTimeAttributes[attr] = value;
648}
649
650
651void
653 myColorAttributes[attr] = value;
654}
655
656
657void
658CommonXMLStructure::SumoBaseObject::addStringListAttribute(const SumoXMLAttr attr, const std::vector<std::string>& value) {
659 myStringListAttributes[attr] = value;
660}
661
662
663void
664CommonXMLStructure::SumoBaseObject::addDoubleListAttribute(const SumoXMLAttr attr, const std::vector<double>& value) {
665 myDoubleListAttributes[attr] = value;
666}
667
668
669void
671 myPositionVectorAttributes[attr] = value;
672}
673
674
675void
676CommonXMLStructure::SumoBaseObject::addParameter(const std::string& key, const std::string& value) {
677 // check if we have to insert in vType, vehicle or stop parameters
678 if (myDefinedVehicleTypeParameter) {
679 myVehicleTypeParameter.setParameter(key, value);
680 } else if (myDefinedVehicleParameter) {
681 myVehicleParameter.setParameter(key, value);
682 } else if (myDefinedStopParameter) {
683 myStopParameter.setParameter(key, value);
684 } else {
685 myParameters[key] = value;
686 }
687}
688
689
690void
694
695
696void
698 myVehicleTypeParameter = *vehicleTypeParameter;
699 myDefinedVehicleTypeParameter = true;
700 // set attribute id
701 addStringAttribute(SUMO_ATTR_ID, myVehicleTypeParameter.id);
702}
703
704
705void
707 myVehicleParameter = *vehicleParameter;
708 myDefinedVehicleParameter = true;
709 // set attribute id
710 if (!myVehicleParameter.id.empty()) {
711 addStringAttribute(SUMO_ATTR_ID, myVehicleParameter.id);
712 }
713 // set attribute route
714 if (!vehicleParameter->routeid.empty()) {
715 addStringAttribute(SUMO_ATTR_ROUTE, myVehicleParameter.routeid);
716 }
717}
718
719
720void
722 myStopParameter = stopParameter;
723 myDefinedStopParameter = true;
724 // set attribute edge
725 if (!myStopParameter.edge.empty()) {
726 addStringAttribute(SUMO_ATTR_EDGE, myStopParameter.edge);
727 }
728 // set attribute lane
729 if (!myStopParameter.lane.empty()) {
730 addStringAttribute(SUMO_ATTR_LANE, myStopParameter.lane);
731 }
732 // set attribute busStop
733 if (!myStopParameter.busstop.empty()) {
734 addStringAttribute(SUMO_ATTR_BUS_STOP, myStopParameter.busstop);
735 }
736 // set attribute containerstop
737 if (!myStopParameter.containerstop.empty()) {
738 addStringAttribute(SUMO_ATTR_CONTAINER_STOP, myStopParameter.containerstop);
739 }
740 // set attribute parkingarea
741 if (!myStopParameter.parkingarea.empty()) {
742 addStringAttribute(SUMO_ATTR_PARKING_AREA, myStopParameter.parkingarea);
743 }
744 // set attribute chargingStation
745 if (!myStopParameter.chargingStation.empty()) {
746 addStringAttribute(SUMO_ATTR_CHARGING_STATION, myStopParameter.chargingStation);
747 }
748}
749
750
751void
753 myPlanParameters = planParameters;
754}
755
756void
758 // just add it into mySumoBaseObjectChildren
759 mySumoBaseObjectChildren.push_back(sumoBaseObject);
760}
761
762
763void
765 // find sumoBaseObject
766 auto it = std::find(mySumoBaseObjectChildren.begin(), mySumoBaseObjectChildren.end(), sumoBaseObject);
767 // check iterator
768 if (it != mySumoBaseObjectChildren.end()) {
769 mySumoBaseObjectChildren.erase(it);
770 }
771}
772
773
774void
776 WRITE_ERRORF(TL("Trying to get undefined % attribute '%' in SUMOBaseObject '%'"), type, toString(attr), toString(myTag));
777}
778
779// ---------------------------------------------------------------------------
780// CommonXMLStructure - methods
781// ---------------------------------------------------------------------------
782
788
789
791 // delete mySumoBaseObjectRoot (this will also delete all SumoBaseObjectChildrens)
794 }
795}
796
797
798void
800 // first check if root is empty
801 if (mySumoBaseObjectRoot == nullptr) {
802 // create root
804 // set tag
806 // update last inserted Root
808 } else {
809 // create new node
810 SumoBaseObject* newSumoBaseObject = new SumoBaseObject(myCurrentSumoBaseObject);
811 // update last inserted node
812 myCurrentSumoBaseObject = newSumoBaseObject;
813 }
814}
815
816
817void
819 // check that myCurrentSumoBaseObject is valid
821 // check if last inserted SumoBaseObject is the root
823 // reset both pointers
824 myCurrentSumoBaseObject = nullptr;
825 mySumoBaseObjectRoot = nullptr;
826 } else {
827 // update last inserted SumoBaseObject
829 }
830 }
831}
832
833
834void
836 // delete current sumo base object and use their parent as sumo base object
840 myCurrentSumoBaseObject = nullptr;
841 mySumoBaseObjectRoot = nullptr;
842 } else {
843 auto parentSumoBaseObject = myCurrentSumoBaseObject->getParentSumoBaseObject();
845 myCurrentSumoBaseObject = parentSumoBaseObject;
846 }
847 }
848}
849
850
855
856
861
862/****************************************************************************/
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 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 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.