Eclipse SUMO - Simulation of Urban MObility
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>
27 #include <utils/common/SUMOTime.h>
28 
29 
30 // ===========================================================================
31 // class definitions
32 // ===========================================================================
59 public:
65 
66  public:
69 
72 
80  virtual void addEdgeWeight(const std::string& id, double val, double beg, double end) const {
81  UNUSED_PARAMETER(id);
82  UNUSED_PARAMETER(val);
83  UNUSED_PARAMETER(beg);
84  UNUSED_PARAMETER(end);
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);
90  UNUSED_PARAMETER(to);
91  UNUSED_PARAMETER(val);
92  UNUSED_PARAMETER(beg);
93  UNUSED_PARAMETER(end);
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);
101  UNUSED_PARAMETER(to);
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 
136  double myAggValue;
137 
140 
143 
144  private:
147 
150  };
151 
158  SAXWeightsHandler(const std::vector<ToRetrieveDefinition*>& defs, const std::string& file);
159 
165  SAXWeightsHandler(ToRetrieveDefinition* def, const std::string& file);
166 
169 
170 protected:
172 
173 
181  void myStartElement(int element, const SUMOSAXAttributes& attrs);
182 
189  void myEndElement(int elemente);
190 
192 
193 private:
195  void tryParse(const SUMOSAXAttributes& attrs, bool isEdge);
196 
198  void tryParseEdgeRel(const SUMOSAXAttributes& attrs);
199 
201  void tryParseTazRel(const SUMOSAXAttributes& attrs);
202 
204  std::vector<ToRetrieveDefinition*> myDefinitions;
205 
207  std::string myCurrentID;
208 
211 
214 
216  std::string myCurrentEdgeID;
217 
219  SAXWeightsHandler(const SAXWeightsHandler& src) = delete;
220 
223 };
#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.
ToRetrieveDefinition(const std::string &attributeName, bool edgeBased, EdgeFloatTimeLineRetriever &destination)
Constructor.
ToRetrieveDefinition & operator=(const ToRetrieveDefinition &)=delete
Invalidated assignment operator.
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.
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.
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;.
SAXWeightsHandler & operator=(const SAXWeightsHandler &src)=delete
we made the assignment operator invalid
void tryParse(const SUMOSAXAttributes &attrs, bool isEdge)
Parses the data of an edge or lane for the previously read times.
SAXWeightsHandler(const std::vector< ToRetrieveDefinition * > &defs, const std::string &file)
Constructor.
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.