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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
17 // Encapsulated xml-attributes that use a map from string-attr-names to string-attr-values as backend
18 /****************************************************************************/
19 #ifndef SUMOSAXAttributesImpl_Cached_h
20 #define SUMOSAXAttributesImpl_Cached_h
21 
22 
23 // ===========================================================================
24 // included modules
25 // ===========================================================================
26 #ifdef _MSC_VER
27 #include <windows_config.h>
28 #else
29 #include <config.h>
30 #endif
31 
32 #include <string>
33 #include <map>
34 #include <iostream>
35 #include <xercesc/sax2/Attributes.hpp>
36 #include <utils/common/SUMOTime.h>
38 #include "SUMOSAXAttributes.h"
39 
40 
41 // ===========================================================================
42 // class definitions
43 // ===========================================================================
51 public:
58  SUMOSAXAttributesImpl_Cached(const std::map<std::string, std::string>& attrs,
59  const std::map<int, std::string>& predefinedTagsMML,
60  const std::string& objectType);
61 
62 
65 
66 
67 
68 
71 
77  bool hasAttribute(int id) const;
78 
79 
95  bool getBool(int id) const;
96 
97 
113  int getInt(int id) const;
114 
115 
131  long long int getLong(int id) const;
132 
133 
146  std::string getString(int id) const;
147 
160  std::string getStringSecure(int id,
161  const std::string& def) const;
162 
163 
179  double getFloat(int id) const;
180 
181 
185  bool hasAttribute(const std::string& id) const;
186 
187 
203  double getFloat(const std::string& id) const;
204 
205 
215  std::string getStringSecure(const std::string& id,
216  const std::string& def) const;
217  //}
218 
219 
226  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
227 
228 
235  SumoXMLNodeType getNodeType(bool& ok) const;
236 
237 
244  RGBColor getColor() const;
245 
246 
252  PositionVector getShape(int attr) const;
253 
254 
260  Boundary getBoundary(int attr) const;
261 
267  std::vector<std::string> getStringVector(int attr) const;
268 
276  std::string getName(int attr) const;
277 
278 
283  void serialize(std::ostream& os) const;
284 
286  SUMOSAXAttributes* clone() const;
287 
288 private:
295  const char* getAttributeValueSecure(int id) const;
296 
297 
298 private:
300  std::map<std::string, std::string> myAttrs;
301 
303  const std::map<int, std::string>& myPredefinedTagsMML;
304 
305 
306 private:
309 
312 
313 
314 };
315 
316 
317 #endif
318 
319 /****************************************************************************/
320 
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:47
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...