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.org/sumo
3 // Copyright (C) 2007-2020 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 = 0;
81 
82  virtual void addEdgeRelWeight(const std::string& from, const std::string& to,
83  double val, double beg, double end) const {
84  UNUSED_PARAMETER(from);
85  UNUSED_PARAMETER(to);
86  UNUSED_PARAMETER(val);
87  UNUSED_PARAMETER(beg);
88  UNUSED_PARAMETER(end);
89  }
90 
91  private:
94  };
95 
101  public:
103  ToRetrieveDefinition(const std::string& attributeName, bool edgeBased,
104  EdgeFloatTimeLineRetriever& destination);
105 
108 
109  public:
111  std::string myAttributeName;
112 
115 
118 
120  double myAggValue;
121 
124 
127 
128  private:
131 
134  };
135 
142  SAXWeightsHandler(const std::vector<ToRetrieveDefinition*>& defs, const std::string& file);
143 
149  SAXWeightsHandler(ToRetrieveDefinition* def, const std::string& file);
150 
153 
154 protected:
156 
157 
165  void myStartElement(int element, const SUMOSAXAttributes& attrs);
166 
173  void myEndElement(int elemente);
174 
176 
177 private:
179  void tryParse(const SUMOSAXAttributes& attrs, bool isEdge);
180 
182  void tryParseEdgeRel(const SUMOSAXAttributes& attrs);
183 
185  std::vector<ToRetrieveDefinition*> myDefinitions;
186 
189 
192 
194  std::string myCurrentEdgeID;
195 
197  SAXWeightsHandler(const SAXWeightsHandler& src) = delete;
198 
201 };
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
Interface for a class which obtains read weights for named edges.
EdgeFloatTimeLineRetriever & operator=(const EdgeFloatTimeLineRetriever &)=delete
we made the assignment operator invalid
virtual void addEdgeWeight(const std::string &id, double val, double beg, double end) const =0
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.
~SAXWeightsHandler()
Destructor.
void tryParseEdgeRel(const SUMOSAXAttributes &attrs)
Parses the data of an edgeRel 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::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.