Eclipse SUMO - Simulation of Urban MObility
SUMOSAXAttributesImpl_Cached.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 /****************************************************************************/
18 // Encapsulated xml-attributes that use a map from string-attr-names to string-attr-values as backend
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <string>
24 #include <map>
25 #include <iostream>
26 #include <xercesc/sax2/Attributes.hpp>
27 #include <utils/common/SUMOTime.h>
29 #include "SUMOSAXAttributes.h"
30 
31 
32 // ===========================================================================
33 // class definitions
34 // ===========================================================================
42 public:
49  SUMOSAXAttributesImpl_Cached(const std::map<std::string, std::string>& attrs,
50  const std::vector<std::string>& predefinedTagsMML,
51  const std::string& objectType);
52 
59  SUMOSAXAttributesImpl_Cached(const std::map<SumoXMLAttr, std::string>& attrs,
60  const std::vector<std::string>& predefinedTagsMML,
61  const std::string& objectType);
62 
65 
68 
74  bool hasAttribute(int id) const;
75 
91  bool getBool(int id) const;
92 
108  int getInt(int id) const;
109 
125  long long int getLong(int id) const;
126 
139  std::string getString(int id) const;
140 
153  std::string getStringSecure(int id, const std::string& def) const;
154 
170  double getFloat(int id) const;
171 
173  bool hasAttribute(const std::string& id) const;
174 
190  double getFloat(const std::string& id) const;
191 
201  std::string getStringSecure(const std::string& id,
202  const std::string& def) const;
204 
211  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
212 
219  SumoXMLNodeType getNodeType(bool& ok) const;
220 
222  RightOfWay getRightOfWay(bool& ok) const;
223 
225  FringeType getFringeType(bool& ok) const;
226 
233  RGBColor getColor() const;
234 
235 
241  PositionVector getShape(int attr) const;
242 
248  Boundary getBoundary(int attr) const;
249 
257  std::string getName(int attr) const;
258 
263  void serialize(std::ostream& os) const;
264 
267  std::vector<std::string> getAttributeNames() const;
268 
270  SUMOSAXAttributes* clone() const;
271 
272 private:
279  const std::string& getAttributeValueSecure(int id) const;
280 
281 private:
283  std::map<std::string, std::string> myAttrs;
284 
286  const std::vector<std::string>& myPredefinedTagsMML;
287 
288 private:
291 
294 };
FringeType
algorithms for computing right of way
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
RightOfWay
algorithms for computing right of way
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:39
A list of positions.
Encapsulated SAX-Attributes.
Encapsulated Xerces-SAX-attributes.
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
SUMOSAXAttributesImpl_Cached & operator=(const SUMOSAXAttributesImpl_Cached &src)=delete
Invalidated assignment operator.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
FringeType getFringeType(bool &ok) const
returns fringe type
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
std::map< std::string, std::string > myAttrs
The encapsulated attributes.
SUMOSAXAttributesImpl_Cached(const std::map< std::string, std::string > &attrs, const std::vector< std::string > &predefinedTagsMML, const std::string &objectType)
Constructor.
SUMOSAXAttributesImpl_Cached(const SUMOSAXAttributesImpl_Cached &src)=delete
Invalidated copy constructor.
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
const std::string & getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
RGBColor getColor() const
Returns the value of the named attribute.
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
const std::vector< std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list.