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-2018 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 
56 
59 
60 
61 
62 
65 
71  bool hasAttribute(int id) const;
72 
73 
89  bool getBool(int id) const;
90 
91 
107  int getInt(int id) const;
108 
109 
125  long long int getLong(int id) const;
126 
127 
140  std::string getString(int id) const;
141 
154  std::string getStringSecure(int id,
155  const std::string& def) const;
156 
157 
173  double getFloat(int id) const;
174 
175 
179  bool hasAttribute(const std::string& id) const;
180 
181 
197  double getFloat(const std::string& id) const;
198 
199 
209  std::string getStringSecure(const std::string& id,
210  const std::string& def) const;
211  //}
212 
213 
220  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
221 
222 
229  SumoXMLNodeType getNodeType(bool& ok) const;
230 
232  RightOfWay getRightOfWay(bool& ok) const;
233 
240  RGBColor getColor() const;
241 
242 
248  PositionVector getShape(int attr) const;
249 
250 
256  Boundary getBoundary(int attr) const;
257 
263  std::vector<std::string> getStringVector(int attr) const;
264 
272  std::string getName(int attr) const;
273 
274 
279  void serialize(std::ostream& os) const;
280 
282  SUMOSAXAttributes* clone() const;
283 
284 private:
291  const std::string& getAttributeValueSecure(int id) const;
292 
293 
294 private:
296  std::map<std::string, std::string> myAttrs;
297 
299  const std::map<int, std::string>& myPredefinedTagsMML;
300 
301 
302 private:
305 
308 
309 
310 };
311 
312 
313 #endif
314 
315 /****************************************************************************/
316 
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
std::vector< std::string > getStringVector(int attr) const
Tries to read given attribute assuming it is a string vector.
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.
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
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.
virtual ~SUMOSAXAttributesImpl_Cached()
Destructor.
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...
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.
std::map< std::string, std::string > myAttrs
The encapsulated attributes.
SUMOSAXAttributesImpl_Cached & operator=(const SUMOSAXAttributesImpl_Cached &src)
Invalidated assignment operator.
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list...