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
NBDistrictCont.cpp
Go to the documentation of this file.
1
/****************************************************************************/
8
// A container for districts
9
/****************************************************************************/
10
// SUMO, Simulation of Urban MObility; see http://sumo.sourceforge.net/
11
// Copyright (C) 2001-2012 DLR (http://www.dlr.de/) and contributors
12
/****************************************************************************/
13
//
14
// This file is part of SUMO.
15
// SUMO is free software: you can redistribute it and/or modify
16
// it under the terms of the GNU General Public License as published by
17
// the Free Software Foundation, either version 3 of the License, or
18
// (at your option) any later version.
19
//
20
/****************************************************************************/
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 <iostream>
34
#include <
utils/common/MsgHandler.h
>
35
#include <
utils/common/ToString.h
>
36
#include <
utils/iodevices/OutputDevice.h
>
37
#include "
NBDistrict.h
"
38
#include "
NBDistrictCont.h
"
39
40
#ifdef CHECK_MEMORY_LEAKS
41
#include <
foreign/nvwa/debug_new.h
>
42
#endif // CHECK_MEMORY_LEAKS
43
44
45
// ===========================================================================
46
// method definitions
47
// ===========================================================================
48
NBDistrictCont::NBDistrictCont
() {}
49
50
51
NBDistrictCont::~NBDistrictCont
() {
52
for
(DistrictCont::iterator i =
myDistricts
.begin(); i !=
myDistricts
.end(); i++) {
53
delete
((*i).second);
54
}
55
myDistricts
.clear();
56
}
57
58
59
bool
60
NBDistrictCont::insert
(
NBDistrict
*
const
district) {
61
DistrictCont::const_iterator i =
myDistricts
.find(district->
getID
());
62
if
(i !=
myDistricts
.end()) {
63
return
false
;
64
}
65
myDistricts
.insert(DistrictCont::value_type(district->
getID
(), district));
66
return
true
;
67
}
68
69
70
NBDistrict
*
71
NBDistrictCont::retrieve
(
const
std::string&
id
)
const
{
72
DistrictCont::const_iterator i =
myDistricts
.find(
id
);
73
if
(i ==
myDistricts
.end()) {
74
return
0;
75
}
76
return
(*i).second;
77
}
78
79
80
size_t
81
NBDistrictCont::size
()
const
{
82
return
myDistricts
.size();
83
}
84
85
86
bool
87
NBDistrictCont::addSource
(
const
std::string& dist,
NBEdge
*
const
source,
88
SUMOReal
weight) {
89
NBDistrict
* o =
retrieve
(dist);
90
if
(o == 0) {
91
return
false
;
92
}
93
return
o->
addSource
(source, weight);
94
}
95
96
97
bool
98
NBDistrictCont::addSink
(
const
std::string& dist,
NBEdge
*
const
destination,
99
SUMOReal
weight) {
100
NBDistrict
* o =
retrieve
(dist);
101
if
(o == 0) {
102
return
false
;
103
}
104
return
o->
addSink
(destination, weight);
105
}
106
107
108
void
109
NBDistrictCont::removeFromSinksAndSources
(
NBEdge
*
const
e) {
110
for
(DistrictCont::iterator i =
myDistricts
.begin(); i !=
myDistricts
.end(); i++) {
111
(*i).second->removeFromSinksAndSources(e);
112
}
113
}
114
115
116
117
/****************************************************************************/
118
build
buildd
sumo-0.15.0~dfsg
src
netbuild
NBDistrictCont.cpp
Generated on Wed Jul 18 2012 22:58:34 for SUMO - Simulation of Urban MObility by
1.8.1.1