Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
SAXWeightsHandler.h
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2007-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/****************************************************************************/
20// An XML-handler for network weights
21/****************************************************************************/
22#pragma once
23#include <config.h>
24
25#include <string>
28
29
30// ===========================================================================
31// class definitions
32// ===========================================================================
59public:
65
66 public:
69
72
80 virtual void addEdgeWeight(const std::string& id, double val, double beg, double end) const {
85 }
86
87 virtual void addEdgeRelWeight(const std::string& from, const std::string& to,
88 double val, double beg, double end) const {
89 UNUSED_PARAMETER(from);
94 }
95
97 virtual void addTazRelWeight(const std::string intervalID, const std::string& from, const std::string& to,
98 double val, double beg, double end) {
99 UNUSED_PARAMETER(intervalID);
100 UNUSED_PARAMETER(from);
102 UNUSED_PARAMETER(val);
103 UNUSED_PARAMETER(beg);
104 UNUSED_PARAMETER(end);
105 }
106
107 private:
110 };
111
117 public:
119 ToRetrieveDefinition(const std::string& attributeName, bool edgeBased,
120 EdgeFloatTimeLineRetriever& destination);
121
124
125 public:
127 std::string myAttributeName;
128
131
134
137
140
143
146
147 private:
150
153 };
154
161 SAXWeightsHandler(const std::vector<ToRetrieveDefinition*>& defs, const std::string& file);
162
168 SAXWeightsHandler(ToRetrieveDefinition* def, const std::string& file);
169
172
173protected:
175
176
184 void myStartElement(int element, const SUMOSAXAttributes& attrs);
185
192 void myEndElement(int elemente);
193
195
196private:
198 void tryParse(const SUMOSAXAttributes& attrs, bool isEdge);
199
201 void tryParseEdgeRel(const SUMOSAXAttributes& attrs);
202
204 void tryParseTazRel(const SUMOSAXAttributes& attrs);
205
207 std::vector<ToRetrieveDefinition*> myDefinitions;
208
210 std::string myCurrentID;
211
214
217
219 std::string myCurrentEdgeID;
220
223
226};
#define UNUSED_PARAMETER(x)
Definition StdDefs.h:30
Interface for a class which obtains read weights for named edges.
EdgeFloatTimeLineRetriever & operator=(const EdgeFloatTimeLineRetriever &)=delete
we made the assignment operator invalid
virtual void addTazRelWeight(const std::string intervalID, const std::string &from, const std::string &to, double val, double beg, double end)
virtual void addEdgeWeight(const std::string &id, double val, double beg, double end) const
Adds a weight for a given edge and time period.
virtual void addEdgeRelWeight(const std::string &from, const std::string &to, double val, double beg, double end) const
Complete definition about what shall be retrieved and where to store it.
std::string myAttributeName
The attribute name that shall be parsed.
EdgeFloatTimeLineRetriever & myDestination
The class that shall be called when new data is avaiable.
bool myHadNonNumeric
Information whether the attribute was found to contain non-numerical data (for any edge)
int myNoLanes
The number of lanes read for the current edge.
double myAggValue
Aggregated value over the lanes read within the current edge.
bool myAmEdgeBased
Information whether edge values shall be used (lane value if false)
ToRetrieveDefinition(const ToRetrieveDefinition &)=delete
Invalidated copy constructor.
bool myHadAttribute
Information whether the attribute has been found for the current edge.
ToRetrieveDefinition & operator=(const ToRetrieveDefinition &)=delete
Invalidated assignment operator.
An XML-handler for network weights.
SAXWeightsHandler(const SAXWeightsHandler &src)=delete
we made the copy constructor invalid
double myCurrentTimeEnd
the end of the time period that is currently processed
double myCurrentTimeBeg
the begin of the time period that is currently processed
void myEndElement(int elemente)
Called when a closing tag occurs.
SAXWeightsHandler & operator=(const SAXWeightsHandler &src)=delete
we made the assignment operator invalid
void tryParseTazRel(const SUMOSAXAttributes &attrs)
Parses the data of an tazRelation for the previously read times.
~SAXWeightsHandler()
Destructor.
void tryParseEdgeRel(const SUMOSAXAttributes &attrs)
Parses the data of an edgeRelation for the previously read times.
void myStartElement(int element, const SUMOSAXAttributes &attrs)
Called on the opening of a tag;.
void tryParse(const SUMOSAXAttributes &attrs, bool isEdge)
Parses the data of an edge or lane for the previously read times.
std::string myCurrentEdgeID
the edge which is currently being processed
std::string myCurrentID
the id of the interval being parsed
std::vector< ToRetrieveDefinition * > myDefinitions
List of definitions what shall be read and whereto stored while parsing the file.
Encapsulated SAX-Attributes.
SAX-handler base for SUMO-files.