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 /****************************************************************************/
14 // Encapsulated xml-attributes that use a map from string-attr-names to string-attr-values as backend
15 /****************************************************************************/
16 #ifndef SUMOSAXAttributesImpl_Cached_h
17 #define SUMOSAXAttributesImpl_Cached_h
18 
19 
20 // ===========================================================================
21 // included modules
22 // ===========================================================================
23 #include <config.h>
24 
25 #include <string>
26 #include <map>
27 #include <iostream>
28 #include <xercesc/sax2/Attributes.hpp>
29 #include <utils/common/SUMOTime.h>
31 #include "SUMOSAXAttributes.h"
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
44 public:
51  SUMOSAXAttributesImpl_Cached(const std::map<std::string, std::string>& attrs,
52  const std::map<int, std::string>& predefinedTagsMML,
53  const std::string& objectType);
54 
61  SUMOSAXAttributesImpl_Cached(const std::map<SumoXMLAttr, std::string>& attrs,
62  const std::map<int, std::string>& predefinedTagsMML,
63  const std::string& objectType);
64 
67 
70 
76  bool hasAttribute(int id) const;
77 
93  bool getBool(int id) const;
94 
110  int getInt(int id) const;
111 
127  long long int getLong(int id) const;
128 
141  std::string getString(int id) const;
142 
155  std::string getStringSecure(int id, const std::string& def) const;
156 
172  double getFloat(int id) const;
173 
175  bool hasAttribute(const std::string& id) const;
176 
192  double getFloat(const std::string& id) const;
193 
203  std::string getStringSecure(const std::string& id,
204  const std::string& def) const;
206 
213  SumoXMLEdgeFunc getEdgeFunc(bool& ok) const;
214 
221  SumoXMLNodeType getNodeType(bool& ok) const;
222 
224  RightOfWay getRightOfWay(bool& ok) const;
225 
227  FringeType getFringeType(bool& ok) const;
228 
235  RGBColor getColor() const;
236 
237 
243  PositionVector getShape(int attr) const;
244 
250  Boundary getBoundary(int attr) const;
251 
259  std::string getName(int attr) const;
260 
265  void serialize(std::ostream& os) const;
266 
269  std::vector<std::string> getAttributeNames() const;
270 
272  SUMOSAXAttributes* clone() const;
273 
274 private:
281  const std::string& getAttributeValueSecure(int id) const;
282 
283 private:
285  std::map<std::string, std::string> myAttrs;
286 
288  const std::map<int, std::string>& myPredefinedTagsMML;
289 
290 private:
293 
296 };
297 
298 
299 #endif
300 
301 /****************************************************************************/
302 
FringeType
FringeType
algorithms for computing right of way
Definition: SUMOXMLDefinitions.h:1110
SUMOSAXAttributesImpl_Cached::getFringeType
FringeType getFringeType(bool &ok) const
returns fringe type
Definition: SUMOSAXAttributesImpl_Cached.cpp:185
SUMOSAXAttributesImpl_Cached::getBoundary
Boundary getBoundary(int attr) const
Tries to read given attribute assuming it is a Boundary.
Definition: SUMOSAXAttributesImpl_Cached.cpp:225
SUMOTime.h
SUMOSAXAttributesImpl_Cached::getFloat
double getFloat(int id) const
Returns the double-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:109
SUMOSAXAttributesImpl_Cached::getNodeType
SumoXMLNodeType getNodeType(bool &ok) const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:160
SUMOSAXAttributesImpl_Cached::getStringSecure
std::string getStringSecure(int id, const std::string &def) const
Returns the string-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:102
SUMOSAXAttributesImpl_Cached::getString
std::string getString(int id) const
Returns the string-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:96
SUMOSAXAttributesImpl_Cached::getBool
bool getBool(int id) const
Returns the bool-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:78
SUMOSAXAttributesImpl_Cached::myAttrs
std::map< std::string, std::string > myAttrs
The encapsulated attributes.
Definition: SUMOSAXAttributesImpl_Cached.h:285
SumoXMLEdgeFunc
SumoXMLEdgeFunc
Numbers representing special SUMO-XML-attribute values for representing edge functions used in netbui...
Definition: SUMOXMLDefinitions.h:1079
SUMOSAXAttributesImpl_Cached::SUMOSAXAttributesImpl_Cached
SUMOSAXAttributesImpl_Cached(const SUMOSAXAttributesImpl_Cached &src)=delete
Invalidated copy constructor.
PositionVector
A list of positions.
Definition: PositionVector.h:45
SUMOSAXAttributesImpl_Cached::hasAttribute
bool hasAttribute(int id) const
Returns the information whether the named (by its enum-value) attribute is within the current list.
Definition: SUMOSAXAttributesImpl_Cached.cpp:68
RGBColor
Definition: RGBColor.h:39
SUMOSAXAttributesImpl_Cached::SUMOSAXAttributesImpl_Cached
SUMOSAXAttributesImpl_Cached(const std::map< std::string, std::string > &attrs, const std::map< int, std::string > &predefinedTagsMML, const std::string &objectType)
Constructor.
Definition: SUMOSAXAttributesImpl_Cached.cpp:42
SUMOSAXAttributesImpl_Cached::getEdgeFunc
SumoXMLEdgeFunc getEdgeFunc(bool &ok) const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:147
SUMOSAXAttributesImpl_Cached::operator=
SUMOSAXAttributesImpl_Cached & operator=(const SUMOSAXAttributesImpl_Cached &src)=delete
Invalidated assignment operator.
SUMOSAXAttributesImpl_Cached
Encapsulated Xerces-SAX-attributes.
Definition: SUMOSAXAttributesImpl_Cached.h:43
SUMOSAXAttributesImpl_Cached::clone
SUMOSAXAttributes * clone() const
return a new deep-copy attributes object
Definition: SUMOSAXAttributesImpl_Cached.cpp:266
SumoXMLNodeType
SumoXMLNodeType
Numbers representing special SUMO-XML-attribute values for representing node- (junction-) types used ...
Definition: SUMOXMLDefinitions.h:1054
SUMOSAXAttributesImpl_Cached::getRightOfWay
RightOfWay getRightOfWay(bool &ok) const
returns rightOfWay method
Definition: SUMOSAXAttributesImpl_Cached.cpp:173
Boundary
A class that stores a 2D geometrical boundary.
Definition: Boundary.h:41
SUMOSAXAttributesImpl_Cached::getInt
int getInt(int id) const
Returns the int-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:84
SUMOSAXAttributesImpl_Cached::getLong
long long int getLong(int id) const
Returns the long-value of the named (by its enum-value) attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:90
SUMOSAXAttributesImpl_Cached::getName
std::string getName(int attr) const
Converts the given attribute id into a man readable string.
Definition: SUMOSAXAttributesImpl_Cached.cpp:240
StringUtils.h
SUMOSAXAttributesImpl_Cached::getAttributeValueSecure
const std::string & getAttributeValueSecure(int id) const
Returns Xerces-value of the named attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:115
RightOfWay
RightOfWay
algorithms for computing right of way
Definition: SUMOXMLDefinitions.h:1104
SUMOSAXAttributes.h
SUMOSAXAttributesImpl_Cached::serialize
void serialize(std::ostream &os) const
Prints all attribute names and values into the given stream.
Definition: SUMOSAXAttributesImpl_Cached.cpp:249
config.h
SUMOSAXAttributesImpl_Cached::getAttributeNames
std::vector< std::string > getAttributeNames() const
Retrieves all attribute names.
Definition: SUMOSAXAttributesImpl_Cached.cpp:257
SUMOSAXAttributesImpl_Cached::~SUMOSAXAttributesImpl_Cached
~SUMOSAXAttributesImpl_Cached()
Destructor.
Definition: SUMOSAXAttributesImpl_Cached.cpp:64
SUMOSAXAttributesImpl_Cached::getShape
PositionVector getShape(int attr) const
Tries to read given attribute assuming it is a PositionVector.
Definition: SUMOSAXAttributesImpl_Cached.cpp:203
SUMOSAXAttributesImpl_Cached::getColor
RGBColor getColor() const
Returns the value of the named attribute.
Definition: SUMOSAXAttributesImpl_Cached.cpp:197
SUMOSAXAttributesImpl_Cached::myPredefinedTagsMML
const std::map< int, std::string > & myPredefinedTagsMML
Map of attribute ids to their (readable) string-representation.
Definition: SUMOSAXAttributesImpl_Cached.h:288
SUMOSAXAttributes
Encapsulated SAX-Attributes.
Definition: SUMOSAXAttributes.h:56