SUMO - Simulation of Urban MObility
SUMOSAXAttributesImpl_Cached.h
Go to the documentation of this file.
1 /****************************************************************************/
7 // Encapsulated xml-attributes that use a map from string-attr-names to string-attr-values as backend
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2007-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 #ifndef SUMOSAXAttributesImpl_Cached_h
21 #define SUMOSAXAttributesImpl_Cached_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <string>
34 #include <map>
35 #include <iostream>
36 #include <xercesc/sax2/Attributes.hpp>
37 #include <utils/common/SUMOTime.h>
39 #include "SUMOSAXAttributes.h"
40 
41 
42 // ===========================================================================
43 // class definitions
44 // ===========================================================================
52 public:
59  SUMOSAXAttributesImpl_Cached(const std::map<std::string, std::string>& attrs,
60  const std::map<int, std::string>& predefinedTagsMML,
61  const std::string& objectType);
62 
63 
66 
67 
68 
69 
72 
78  bool hasAttribute(int id) const;
79 
80 
96  bool getBool(int id) const;
97 
98 
114  int getInt(int id) const;
115 
116 
132  long long int getLong(int id) const;
133 
134 
147  std::string getString(int id) const;
148 
161  std::string getStringSecure(int id,
162  const std::string& def) const;
163 
164 
180  double getFloat(int id) const;
181 
182 
186  bool hasAttribute(const std::string& id) const;
187 
188 
204  double getFloat(const std::string& id) const;
205 
206 
216  std::string getStringSecure(const std::string& id,
217  const std::string& def) const;
218  //}
219 
220 
227  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
228 
229 
236  SumoXMLNodeType getNodeType(bool& ok) const;
237 
238 
245  RGBColor getColor() const;
246 
247 
253  PositionVector getShape(int attr) const;
254 
255 
261  Boundary getBoundary(int attr) const;
262 
268  std::vector<std::string> getStringVector(int attr) const;
269 
277  std::string getName(int attr) const;
278 
279 
284  void serialize(std::ostream& os) const;
285 
287  SUMOSAXAttributes* clone() const;
288 
289 private:
296  const char* getAttributeValueSecure(int id) const;
297 
298 
299 private:
301  std::map<std::string, std::string> myAttrs;
302 
304  const std::map<int, std::string>& myPredefinedTagsMML;
305 
306 
307 private:
310 
313 
314 
315 };
316 
317 
318 #endif
319 
320 /****************************************************************************/
321 
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.
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:48
RGBColor getColor() const
Returns the 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.
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...
const char * getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
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...