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
ODDistrictCont.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// A container for districts
10
/****************************************************************************/
11
// SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12
// Copyright (C) 2002-2014 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 <string>
34
#include "
ODDistrict.h
"
35
#include "
ODDistrictCont.h
"
36
#include <
utils/common/MsgHandler.h
>
37
#include <
utils/common/UtilExceptions.h
>
38
#include <
utils/common/NamedObjectCont.h
>
39
#include <
od2trips/ODDistrictCont.h
>
40
#include <
od2trips/ODDistrictHandler.h
>
41
#include <
utils/xml/XMLSubSys.h
>
42
#include <
utils/common/RandHelper.h
>
43
#include <
utils/common/FileHelpers.h
>
44
#include <
utils/options/OptionsCont.h
>
45
#ifdef CHECK_MEMORY_LEAKS
46
#include <
foreign/nvwa/debug_new.h
>
47
#include <
utils/options/OptionsCont.h
>
48
#endif // CHECK_MEMORY_LEAKS
49
50
51
// ===========================================================================
52
// method definitions
53
// ===========================================================================
54
ODDistrictCont::ODDistrictCont
() {}
55
56
57
ODDistrictCont::~ODDistrictCont
() {}
58
59
60
std::string
61
ODDistrictCont::getRandomSourceFromDistrict
(
const
std::string& name)
const
{
62
ODDistrict
* district =
get
(name);
63
if
(district == 0) {
64
throw
InvalidArgument
(
"There is no district '"
+ name +
"'."
);
65
}
66
return
district->
getRandomSource
();
67
}
68
69
70
std::string
71
ODDistrictCont::getRandomSinkFromDistrict
(
const
std::string& name)
const
{
72
ODDistrict
* district =
get
(name);
73
if
(district == 0) {
74
throw
InvalidArgument
(
"There is no district '"
+ name +
"'."
);
75
}
76
return
district->
getRandomSink
();
77
}
78
79
void
80
ODDistrictCont::loadDistricts
(std::string districtfile) {
81
if
(!
FileHelpers::isReadable
(districtfile)) {
82
throw
ProcessError
(
"Could not access network file '"
+ districtfile +
"' to load."
);
83
}
84
PROGRESS_BEGIN_MESSAGE
(
"Loading districts from '"
+ districtfile +
"'"
);
85
// build the xml-parser and handler
86
ODDistrictHandler
handler(*
this
, districtfile);
87
if
(!
XMLSubSys::runParser
(handler, districtfile,
true
)) {
88
PROGRESS_FAILED_MESSAGE
();
89
}
else
{
90
PROGRESS_DONE_MESSAGE
();
91
}
92
}
93
94
/****************************************************************************/
95
tmp
buildd
sumo-0.21.0+dfsg
src
od2trips
ODDistrictCont.cpp
Generated on Thu Nov 20 2014 19:49:58 for SUMO - Simulation of Urban MObility by
1.8.1.2