Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
RouteHandler.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// The XML-Handler for route elements loading
19/****************************************************************************/
20#pragma once
21#include <config.h>
22
24
25
26// ===========================================================================
27// class definitions
28// ===========================================================================
29
31
32public:
37 RouteHandler(const std::string& filename, const bool hardFail);
38
40 virtual ~RouteHandler();
41
44
46 void endParseAttributes();
47
50
53
55 virtual void buildVType(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVTypeParameter& vTypeParameter) = 0;
56
58 virtual void buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, const int deterministic,
59 const std::vector<std::string>& vTypeIDs, const std::vector<double>& probabilities) = 0;
60
62 virtual void buildRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id, SUMOVehicleClass vClass,
63 const std::vector<std::string>& edgeIDs, const RGBColor& color, const int repeat, const SUMOTime cycleTime,
64 const double probability, const Parameterised::Map& routeParameters) = 0;
65
67 virtual void buildEmbeddedRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::vector<std::string>& edgeIDs,
68 const RGBColor& color, const int repeat, const SUMOTime cycleTime,
69 const Parameterised::Map& routeParameters) = 0;
70
72 virtual void buildRouteDistribution(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const std::string& id,
73 const std::vector<std::string>& vTypeIDs, const std::vector<double>& probabilities) = 0;
74
76 virtual void buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters) = 0;
77
79 virtual void buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters) = 0;
80
82 virtual void buildTrip(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
83 const std::string& fromEdgeID, const std::string& toEdgeID) = 0;
84
86 virtual void buildTripJunctions(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
87 const std::string& fromJunctionID, const std::string& toJunctionID) = 0;
88
90 virtual void buildTripTAZs(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
91 const std::string& fromTazID, const std::string& toTazID) = 0;
92
94 virtual void buildFlow(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
95 const std::string& fromEdgeID, const std::string& toEdgeID) = 0;
96
98 virtual void buildFlowJunctions(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
99 const std::string& fromJunctionID, const std::string& toJunctionID) = 0;
100
102 virtual void buildFlowTAZs(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& vehicleParameters,
103 const std::string& fromTAZID, const std::string& toTAZID) = 0;
104
106 virtual void buildPerson(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& personParameters) = 0;
107
109 virtual void buildPersonFlow(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& personFlowParameters) = 0;
110
112 virtual void buildPersonTrip(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const CommonXMLStructure::PlanParameters& planParameters,
113 const double arrivalPos, const std::vector<std::string>& types, const std::vector<std::string>& modes,
114 const std::vector<std::string>& lines, const double walkFactor, const std::string& group) = 0;
115
117 virtual void buildWalk(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const CommonXMLStructure::PlanParameters& planParameters,
118 const double arrivalPos, const double speed, const SUMOTime duration) = 0;
119
121 virtual void buildRide(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const CommonXMLStructure::PlanParameters& planParameters,
122 const double arrivalPos, const std::vector<std::string>& lines, const std::string& group) = 0;
123
125 virtual void buildContainer(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& containerParameters) = 0;
126
128 virtual void buildContainerFlow(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const SUMOVehicleParameter& containerFlowParameters) = 0;
129
131 virtual void buildTransport(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const CommonXMLStructure::PlanParameters& planParameters,
132 const double arrivalPos, const std::vector<std::string>& lines, const std::string& group) = 0;
133
135 virtual void buildTranship(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const CommonXMLStructure::PlanParameters& planParameters,
136 const double arrivalPosition, const double departPosition, const double speed, const SUMOTime duration) = 0;
137
139 virtual void buildStop(const CommonXMLStructure::SumoBaseObject* sumoBaseObject, const CommonXMLStructure::PlanParameters& planParameters,
140 const SUMOVehicleParameter::Stop& stopParameters) = 0;
141
143
145 bool isErrorCreatingElement() const;
146
147protected:
149 void writeError(const std::string& error);
150
151private:
153 const std::string myFilename;
154
156 const bool myHardFail;
157
160
163
166
169
171 void writeErrorInvalidID(const SumoXMLTag tag, const std::string& id);
172
174 void writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string& id);
175
179 void parseVType(const SUMOSAXAttributes& attrs);
180
182 void parseVTypeDistribution(const SUMOSAXAttributes& attrs);
183
185 void parseRoute(const SUMOSAXAttributes& attrs);
186
188 void parseRouteDistribution(const SUMOSAXAttributes& attrs);
189
191 void parseTrip(const SUMOSAXAttributes& attrs);
192
194 void parseVehicle(const SUMOSAXAttributes& attrs);
195
197 void parseFlow(const SUMOSAXAttributes& attrs);
198
200 void parseStop(const SUMOSAXAttributes& attrs);
201
203 void parsePerson(const SUMOSAXAttributes& attrs);
204
206 void parsePersonFlow(const SUMOSAXAttributes& attrs);
207
209 void parsePersonTrip(const SUMOSAXAttributes& attrs);
210
212 void parseWalk(const SUMOSAXAttributes& attrs);
213
215 void parseRide(const SUMOSAXAttributes& attrs);
216
218 void parseContainer(const SUMOSAXAttributes& attrs);
219
221 void parseContainerFlow(const SUMOSAXAttributes& attrs);
222
224 void parseTransport(const SUMOSAXAttributes& attrs);
225
227 void parseTranship(const SUMOSAXAttributes& attrs);
228
230 void parseInterval(const SUMOSAXAttributes& attrs);
231
233 void parseParameters(const SUMOSAXAttributes& attrs);
234
236 bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes& attrs);
237
239
242
244 bool isEmbeddedRoute(const SUMOSAXAttributes& attrs) const;
245
247 void checkParent(const SumoXMLTag currentTag, const std::vector<SumoXMLTag>& parentTags, bool& ok);
248
250 RouteHandler(const RouteHandler& s) = delete;
251
254};
long long int SUMOTime
Definition GUI.h:36
SUMOVehicleClass
Definition of vehicle classes to differ between different lane usage and authority types.
SumoXMLTag
Numbers representing SUMO-XML - element names.
plan parameters (used for group all from-to parameters related with plans)
std::map< std::string, std::string > Map
parameters map
void parseWalk(const SUMOSAXAttributes &attrs)
parse walk
virtual void buildContainer(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerParameters)=0
build container
void parseContainerFlow(const SUMOSAXAttributes &attrs)
parse container flow
void parseFlow(const SUMOSAXAttributes &attrs)
parse flow (including flows, flows over routes and flows with embedded routes)
bool beginParseAttributes(SumoXMLTag tag, const SUMOSAXAttributes &attrs)
begin parse attributes
CommonXMLStructure myCommonXMLStructure
common XML Structure
virtual void buildFlowTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTAZID, const std::string &toTAZID)=0
build flow (from-to TAZs)
virtual void buildRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, SUMOVehicleClass vClass, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const double probability, const Parameterised::Map &routeParameters)=0
build route
virtual void buildFlowOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a flow over an existent route
bool isErrorCreatingElement() const
get flag for check if a element wasn't created
bool isEmbeddedRoute(const SUMOSAXAttributes &attrs) const
check embedded route
void parsePerson(const SUMOSAXAttributes &attrs)
parse person
virtual void buildEmbeddedRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::vector< std::string > &edgeIDs, const RGBColor &color, const int repeat, const SUMOTime cycleTime, const Parameterised::Map &routeParameters)=0
build embedded route
void parseTransport(const SUMOSAXAttributes &attrs)
parse transport
virtual void buildTransport(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group)=0
build transport
void endParseAttributes()
end parse attributes
virtual void buildFlowJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build flow (from-to junctions)
virtual void buildTranship(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPosition, const double departPosition, const double speed, const SUMOTime duration)=0
build tranship
void parseVTypeDistribution(const SUMOSAXAttributes &attrs)
parse vType distribution
virtual void buildTripJunctions(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromJunctionID, const std::string &toJunctionID)=0
build trip (from-to junctions)
void writeErrorInvalidID(const SumoXMLTag tag, const std::string &id)
write error "invalid id"
const std::string myFilename
filename (needed for parsing vTypes)
virtual void buildWalk(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const double speed, const SUMOTime duration)=0
build walk
void parseStop(const SUMOSAXAttributes &attrs)
parse stop
void parseContainer(const SUMOSAXAttributes &attrs)
parse container
void parsePersonTrip(const SUMOSAXAttributes &attrs)
parse person trip
virtual void buildTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build trip (from-to edges)
virtual void buildVType(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVTypeParameter &vTypeParameter)=0
build vType
void parseRoute(const SUMOSAXAttributes &attrs)
parse route
virtual void buildVTypeDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const int deterministic, const std::vector< std::string > &vTypeIDs, const std::vector< double > &probabilities)=0
build vType distribution
virtual void buildTripTAZs(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromTazID, const std::string &toTazID)=0
build trip (from-to TAZs)
void parseTrip(const SUMOSAXAttributes &attrs)
parse trip
SUMOTime myFlowEndDefault
The default value for flow ends.
virtual ~RouteHandler()
Destructor.
void parseParameters(const SUMOSAXAttributes &attrs)
parse generic parameters
virtual void buildStop(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const SUMOVehicleParameter::Stop &stopParameters)=0
build stop
void parseSumoBaseObject(CommonXMLStructure::SumoBaseObject *obj)
parse SumoBaseObject (it's called recursivelly)
virtual void buildRide(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &lines, const std::string &group)=0
build ride
virtual void buildPersonFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personFlowParameters)=0
build person flow
void parsePersonFlow(const SUMOSAXAttributes &attrs)
parse person flow
void parseInterval(const SUMOSAXAttributes &attrs)
parse interval
bool myErrorCreatingElement
flag for check if a element wasn't created
void parseVType(const SUMOSAXAttributes &attrs)
void writeError(const std::string &error)
write error and enable error creating element
void parseRide(const SUMOSAXAttributes &attrs)
parse ride
bool parseNestedCFM(const SumoXMLTag tag, const SUMOSAXAttributes &attrs)
parse nested CarFollowingModel
virtual void buildPersonTrip(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const CommonXMLStructure::PlanParameters &planParameters, const double arrivalPos, const std::vector< std::string > &types, const std::vector< std::string > &modes, const std::vector< std::string > &lines, const double walkFactor, const std::string &group)=0
build person trip
SUMOTime myFlowBeginDefault
The default value for flow begins.
virtual void buildVehicleOverRoute(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters)=0
build a vehicle over an existent route
void parseVehicle(const SUMOSAXAttributes &attrs)
parse vehicle (including vehicles over routes and vehicles with embedded routes)
void checkParent(const SumoXMLTag currentTag, const std::vector< SumoXMLTag > &parentTags, bool &ok)
check parents
virtual void buildRouteDistribution(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const std::string &id, const std::vector< std::string > &vTypeIDs, const std::vector< double > &probabilities)=0
build route distribution
virtual void buildContainerFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &containerFlowParameters)=0
build container flow
virtual void buildPerson(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &personParameters)=0
build person
bool parseStopParameters(SUMOVehicleParameter::Stop &stop, const SUMOSAXAttributes &attrs)
parse stop parameters
void writeErrorInvalidDistribution(const SumoXMLTag tag, const std::string &id)
write error "invalid distribution"
const bool myHardFail
enable or disable hardFail (stop parsing if parameter aren't correct)
void parseRouteDistribution(const SUMOSAXAttributes &attrs)
parse route distribution
RouteHandler & operator=(const RouteHandler &s)=delete
invalidate assignment operator
RouteHandler(const RouteHandler &s)=delete
invalidate copy constructor
void parseTranship(const SUMOSAXAttributes &attrs)
parse tranship
virtual void buildFlow(const CommonXMLStructure::SumoBaseObject *sumoBaseObject, const SUMOVehicleParameter &vehicleParameters, const std::string &fromEdgeID, const std::string &toEdgeID)=0
build flow (from-to edges)
Encapsulated SAX-Attributes.
Structure representing possible vehicle parameter.
Definition of vehicle stop (position and duration)
Structure representing possible vehicle parameter.