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
MSRouteLoader.cpp
Go to the documentation of this file.
1
/****************************************************************************/
8
// A class that performs the loading of routes
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
// included modules
24
// ===========================================================================
25
#ifdef _MSC_VER
26
#include <
windows_config.h
>
27
#else
28
#include <
config.h
>
29
#endif
30
31
#include <string>
32
#include <
utils/common/MsgHandler.h
>
33
#include <
utils/common/UtilExceptions.h
>
34
#include <
utils/xml/XMLSubSys.h
>
35
#include "
MSNet.h
"
36
#include "
MSRouteHandler.h
"
37
#include "
MSRouteLoader.h
"
38
39
#ifdef CHECK_MEMORY_LEAKS
40
#include <
foreign/nvwa/debug_new.h
>
41
#endif // CHECK_MEMORY_LEAKS
42
43
44
// ===========================================================================
45
// method definitions
46
// ===========================================================================
47
MSRouteLoader::MSRouteLoader
(
MSNet
&,
48
MSRouteHandler
* handler)
49
: myParser(0), myMoreAvailable(true), myHandler(handler) {
50
myParser
=
XMLSubSys::getSAXReader
(*
myHandler
);
51
}
52
53
54
MSRouteLoader::~MSRouteLoader
() {
55
delete
myParser
;
56
delete
myHandler
;
57
}
58
59
60
void
61
MSRouteLoader::init
() {
62
myMoreAvailable
=
true
;
63
if
(!
myParser
->parseFirst(
myHandler
->
getFileName
().c_str(),
myToken
)) {
64
throw
ProcessError
(
"Can not read XML-file '"
+
myHandler
->
getFileName
() +
"'."
);
65
}
66
}
67
68
69
void
70
MSRouteLoader::loadUntil
(
SUMOTime
time) {
71
// read only when further data is available, no error occured
72
// and vehicles may be found in the between the departure time of
73
// the last read vehicle and the time to read until
74
if
(!
myMoreAvailable
|| time <= myHandler->getLastDepart()) {
75
return
;
76
}
77
78
// read vehicles until specified time or the period to read vehicles
79
// until is reached
80
while
(
myParser
->parseNext(
myToken
)) {
81
// return when the last read vehicle is beyond the period
82
if
(time <= myHandler->getLastDepart()) {
83
return
;
84
}
85
}
86
87
// no data are available anymore
88
myMoreAvailable
=
false
;
89
return
;
90
}
91
92
93
bool
94
MSRouteLoader::moreAvailable
()
const
{
95
return
myMoreAvailable
;
96
}
97
98
99
100
/****************************************************************************/
101
build
buildd
sumo-0.15.0~dfsg
src
microsim
MSRouteLoader.cpp
Generated on Wed Jul 18 2012 22:58:33 for SUMO - Simulation of Urban MObility by
1.8.1.1