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-2019 German Aerospace Center (DLR) and others.
4 // This program and the accompanying materials
5 // are made available under the terms of the Eclipse Public License v2.0
6 // which accompanies this distribution, and is available at
7 // http://www.eclipse.org/legal/epl-v20.html
8 // SPDX-License-Identifier: EPL-2.0
9 /****************************************************************************/
15 // Encapsulated xml-attributes that use a map from string-attr-names to string-attr-values as backend
16 /****************************************************************************/
17 #ifndef SUMOSAXAttributesImpl_Cached_h
18 #define SUMOSAXAttributesImpl_Cached_h
19 
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <string>
27 #include <map>
28 #include <iostream>
29 #include <xercesc/sax2/Attributes.hpp>
30 #include <utils/common/SUMOTime.h>
32 #include "SUMOSAXAttributes.h"
33 
34 
35 // ===========================================================================
36 // class definitions
37 // ===========================================================================
45 public:
52  SUMOSAXAttributesImpl_Cached(const std::map<std::string, std::string>& attrs,
53  const std::map<int, std::string>& predefinedTagsMML,
54  const std::string& objectType);
55 
62  SUMOSAXAttributesImpl_Cached(const std::map<SumoXMLAttr, std::string>& attrs,
63  const std::map<int, std::string>& predefinedTagsMML,
64  const std::string& objectType);
65 
68 
71 
77  bool hasAttribute(int id) const;
78 
94  bool getBool(int id) const;
95 
111  int getInt(int id) const;
112 
128  long long int getLong(int id) const;
129 
142  std::string getString(int id) const;
143 
156  std::string getStringSecure(int id, const std::string& def) const;
157 
173  double getFloat(int id) const;
174 
176  bool hasAttribute(const std::string& id) const;
177 
193  double getFloat(const std::string& id) const;
194 
204  std::string getStringSecure(const std::string& id,
205  const std::string& def) const;
207 
214  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
215 
222  SumoXMLNodeType getNodeType(bool& ok) const;
223 
225  RightOfWay getRightOfWay(bool& ok) const;
226 
228  FringeType getFringeType(bool& ok) const;
229 
236  RGBColor getColor() const;
237 
238 
244  PositionVector getShape(int attr) const;
245 
251  Boundary getBoundary(int attr) const;
252 
260  std::string getName(int attr) const;
261 
266  void serialize(std::ostream& os) const;
267 
270  std::vector<std::string> getAttributeNames() const;
271 
273  SUMOSAXAttributes* clone() const;
274 
275 private:
282  const std::string& getAttributeValueSecure(int id) const;
283 
284 private:
286  std::map<std::string, std::string> myAttrs;
287 
289  const std::map<int, std::string>& myPredefinedTagsMML;
290 
291 private:
294 
297 };
298 
299 
300 #endif
301 
302 /****************************************************************************/
303 
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
Encapsulated Xerces-SAX-attributes.
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
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
RightOfWay
algorithms for computing right of way
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:42
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
RGBColor getColor() const
Returns the value of the named attribute.
const std::string & getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
const std::map< int, std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
Encapsulated SAX-Attributes.
A list of positions.
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
FringeType
algorithms for computing right of way
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
SUMOSAXAttributesImpl_Cached(const std::map< std::string, std::string > &attrs, const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType)
Constructor.
SUMOSAXAttributesImpl_Cached & operator=(const SUMOSAXAttributesImpl_Cached &src)=delete
Invalidated assignment operator.
std::map< std::string, std::string > myAttrs
The encapsulated attributes.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...