SUMO - Simulation of Urban MObility
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
NIXMLTypesHandler.cpp
Go to the documentation of this file.
1
/****************************************************************************/
10
// Importer for edge type information stored in XML
11
/****************************************************************************/
12
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
13
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
14
/****************************************************************************/
15
//
16
// This file is part of SUMO.
17
// SUMO is free software: you can redistribute it and/or modify
18
// it under the terms of the GNU General Public License as published by
19
// the Free Software Foundation, either version 3 of the License, or
20
// (at your option) any later version.
21
//
22
/****************************************************************************/
23
24
25
// ===========================================================================
26
// included modules
27
// ===========================================================================
28
#ifdef _MSC_VER
29
#include <
windows_config.h
>
30
#else
31
#include <
config.h
>
32
#endif
33
34
#include <string>
35
#include <iostream>
36
#include <xercesc/sax/HandlerBase.hpp>
37
#include <xercesc/sax/AttributeList.hpp>
38
#include <xercesc/sax/SAXParseException.hpp>
39
#include <xercesc/sax/SAXException.hpp>
40
#include "
NIXMLTypesHandler.h
"
41
#include <
netbuild/NBTypeCont.h
>
42
#include <
utils/xml/SUMOSAXHandler.h
>
43
#include <
utils/xml/SUMOXMLDefinitions.h
>
44
#include <
utils/common/TplConvert.h
>
45
#include <
utils/common/MsgHandler.h
>
46
#include <
utils/common/ToString.h
>
47
#include <
utils/common/SUMOVehicleClass.h
>
48
49
#ifdef CHECK_MEMORY_LEAKS
50
#include <
foreign/nvwa/debug_new.h
>
51
#endif // CHECK_MEMORY_LEAKS
52
53
54
// ===========================================================================
55
// method definitions
56
// ===========================================================================
57
NIXMLTypesHandler::NIXMLTypesHandler
(
NBTypeCont
& tc)
58
:
SUMOSAXHandler
(
"xml-types - file"
),
59
myTypeCont(tc) {}
60
61
62
NIXMLTypesHandler::~NIXMLTypesHandler
() {}
63
64
65
void
66
NIXMLTypesHandler::myStartElement
(
int
element,
67
const
SUMOSAXAttributes
& attrs) {
68
if
(element !=
SUMO_TAG_TYPE
) {
69
return
;
70
}
71
bool
ok =
true
;
72
// get the id, report a warning if not given or empty...
73
std::string
id
= attrs.
getStringReporting
(
SUMO_ATTR_ID
, 0, ok);
74
int
priority = attrs.
getOptIntReporting
(
SUMO_ATTR_PRIORITY
,
id
.c_str(), ok,
myTypeCont
.
getPriority
(
""
));
75
int
noLanes =
myTypeCont
.
getNumLanes
(
""
);
76
noLanes = attrs.
getOptIntReporting
(
SUMO_ATTR_NUMLANES
,
id
.c_str(), ok, noLanes);
77
SUMOReal
speed = attrs.
getOptSUMORealReporting
(
SUMO_ATTR_SPEED
,
id
.c_str(), ok, (
SUMOReal
)
myTypeCont
.
getSpeed
(
""
));
78
std::string allowS = attrs.
getOptStringReporting
(
SUMO_ATTR_ALLOW
,
id
.c_str(), ok,
""
);
79
std::string disallowS = attrs.
getOptStringReporting
(
SUMO_ATTR_DISALLOW
,
id
.c_str(), ok,
""
);
80
bool
oneway = attrs.
getOptBoolReporting
(
SUMO_ATTR_ONEWAY
,
id
.c_str(), ok,
false
);
81
bool
discard = attrs.
getOptBoolReporting
(
SUMO_ATTR_DISCARD
,
id
.c_str(), ok,
false
);
82
SUMOReal
width = attrs.
getOptSUMORealReporting
(
SUMO_ATTR_WIDTH
,
id
.c_str(), ok,
NBEdge::UNSPECIFIED_WIDTH
);
83
if
(!ok) {
84
return
;
85
}
86
// build the type
87
SVCPermissions
permissions =
parseVehicleClasses
(allowS, disallowS);
88
if
(!
myTypeCont
.
insert
(
id
, noLanes, speed, priority, permissions, width, oneway)) {
89
WRITE_ERROR
(
"Duplicate type occured. ID='"
+
id
+
"'"
);
90
}
else
{
91
if
(discard) {
92
myTypeCont
.
markAsToDiscard
(
id
);
93
}
94
}
95
}
96
97
98
99
/****************************************************************************/
100
build
buildd
sumo-0.16.0~dfsg
src
netimport
NIXMLTypesHandler.cpp
Generated on Tue Apr 16 2013 01:32:19 for SUMO - Simulation of Urban MObility by
1.8.3.1