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
SUMOVTypeParameter.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// Structure representing possible vehicle parameter
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
12
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
13
/****************************************************************************/
14
//
15
// This file is part of SUMO.
16
// SUMO is free software: you can redistribute it and/or modify
17
// it under the terms of the GNU General Public License as published by
18
// the Free Software Foundation, either version 3 of the License, or
19
// (at your option) any later version.
20
//
21
/****************************************************************************/
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 <algorithm>
34
#include <
utils/common/SUMOVTypeParameter.h
>
35
#include <
utils/common/ToString.h
>
36
#include <
utils/common/TplConvert.h
>
37
#include <
utils/common/MsgHandler.h
>
38
#include <
utils/iodevices/OutputDevice.h
>
39
#include <
utils/options/OptionsCont.h
>
40
#include <
utils/xml/SUMOXMLDefinitions.h
>
41
42
#ifdef CHECK_MEMORY_LEAKS
43
#include <
foreign/nvwa/debug_new.h
>
44
#endif // CHECK_MEMORY_LEAKS
45
46
47
// ===========================================================================
48
// member method definitions
49
// ===========================================================================
50
SUMOVTypeParameter::SUMOVTypeParameter
()
51
: id(
DEFAULT_VTYPE_ID
), length(
DEFAULT_VEH_LENGTH
),
52
minGap(
DEFAULT_VEH_MINGAP
), maxSpeed(
DEFAULT_VEH_MAXSPEED
),
53
defaultProbability(
DEFAULT_VEH_PROB
),
54
speedFactor(
DEFAULT_VEH_SPEEDFACTOR
), speedDev(
DEFAULT_VEH_SPEEDDEV
),
55
emissionClass(
SVE_UNKNOWN
), color(
RGBColor
::DEFAULT_COLOR),
56
vehicleClass(
SVC_UNKNOWN
), width(
DEFAULT_VEH_WIDTH
),
57
height(
DEFAULT_VEH_HEIGHT
), shape(
DEFAULT_VEH_SHAPE
),
58
cfModel(
DEFAULT_VEH_FOLLOW_MODEL
), lcModel(
DEFAULT_VEH_LANE_CHANGE_MODEL
),
59
setParameter(0), saved(false), onlyReferenced(false) {
60
}
61
62
63
void
64
SUMOVTypeParameter::write
(
OutputDevice
& dev)
const
{
65
if
(
onlyReferenced
) {
66
return
;
67
}
68
dev.
openTag
(
SUMO_TAG_VTYPE
);
69
dev.
writeAttr
(
SUMO_ATTR_ID
,
id
);
70
if
(
wasSet
(
VTYPEPARS_LENGTH_SET
)) {
71
dev.
writeAttr
(
SUMO_ATTR_LENGTH
,
length
);
72
}
73
if
(
wasSet
(
VTYPEPARS_MINGAP_SET
)) {
74
dev.
writeAttr
(
SUMO_ATTR_MINGAP
,
minGap
);
75
}
76
if
(
wasSet
(
VTYPEPARS_MAXSPEED_SET
)) {
77
dev.
writeAttr
(
SUMO_ATTR_MAXSPEED
,
maxSpeed
);
78
}
79
if
(
wasSet
(
VTYPEPARS_PROBABILITY_SET
)) {
80
dev.
writeAttr
(
SUMO_ATTR_PROB
,
defaultProbability
);
81
}
82
if
(
wasSet
(
VTYPEPARS_SPEEDFACTOR_SET
)) {
83
dev.
writeAttr
(
SUMO_ATTR_SPEEDFACTOR
,
speedFactor
);
84
}
85
if
(
wasSet
(
VTYPEPARS_SPEEDDEVIATION_SET
)) {
86
dev.
writeAttr
(
SUMO_ATTR_SPEEDDEV
,
speedDev
);
87
}
88
if
(
wasSet
(
VTYPEPARS_VEHICLECLASS_SET
)) {
89
dev.
writeAttr
(
SUMO_ATTR_VCLASS
,
toString
(
vehicleClass
));
90
}
91
if
(
wasSet
(
VTYPEPARS_EMISSIONCLASS_SET
)) {
92
dev.
writeAttr
(
SUMO_ATTR_EMISSIONCLASS
,
getVehicleEmissionTypeName
(
emissionClass
));
93
}
94
if
(
wasSet
(
VTYPEPARS_SHAPE_SET
)) {
95
dev.
writeAttr
(
SUMO_ATTR_GUISHAPE
,
getVehicleShapeName
(
shape
));
96
}
97
if
(
wasSet
(
VTYPEPARS_WIDTH_SET
)) {
98
dev.
writeAttr
(
SUMO_ATTR_WIDTH
,
width
);
99
}
100
if
(
wasSet
(
VTYPEPARS_HEIGHT_SET
)) {
101
dev.
writeAttr
(
SUMO_ATTR_HEIGHT
,
height
);
102
}
103
if
(
wasSet
(
VTYPEPARS_COLOR_SET
)) {
104
dev.
writeAttr
(
SUMO_ATTR_COLOR
,
color
);
105
}
106
if
(
wasSet
(
VTYPEPARS_OSGFILE_SET
)) {
107
dev.
writeAttr
(
SUMO_ATTR_OSGFILE
,
osgFile
);
108
}
109
if
(
wasSet
(
VTYPEPARS_IMGFILE_SET
)) {
110
dev.
writeAttr
(
SUMO_ATTR_IMGFILE
,
imgFile
);
111
}
112
113
if
(
cfParameter
.size() != 0) {
114
dev.
closeOpener
();
115
dev.
openTag
(
cfModel
);
116
std::vector<SumoXMLAttr> attrs;
117
for
(CFParams::const_iterator i =
cfParameter
.begin(); i !=
cfParameter
.end(); ++i) {
118
attrs.push_back(i->first);
119
}
120
std::sort(attrs.begin(), attrs.end());
121
for
(std::vector<SumoXMLAttr>::const_iterator i = attrs.begin(); i != attrs.end(); ++i) {
122
dev.
writeAttr
(*i,
cfParameter
.find(*i)->second);
123
}
124
dev.
closeTag
(
true
);
125
dev.
closeTag
();
126
}
else
{
127
dev.
closeTag
(
true
);
128
}
129
}
130
131
132
SUMOReal
133
SUMOVTypeParameter::get
(
const
SumoXMLAttr
attr,
const
SUMOReal
defaultValue)
const
{
134
if
(
cfParameter
.count(attr)) {
135
return
cfParameter
.find(attr)->second;
136
}
else
{
137
return
defaultValue;
138
}
139
}
140
141
142
/****************************************************************************/
143
build
buildd
sumo-0.16.0~dfsg
src
utils
common
SUMOVTypeParameter.cpp
Generated on Tue Apr 16 2013 01:32:21 for SUMO - Simulation of Urban MObility by
1.8.3.1