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
SUMORouteLoader.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-2013 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 <
utils/xml/SUMORouteHandler.h
>
32
#include <
utils/xml/SUMOSAXReader.h
>
33
#include <
utils/xml/XMLSubSys.h
>
34
#include "
SUMORouteLoader.h
"
35
36
#ifdef CHECK_MEMORY_LEAKS
37
#include <
foreign/nvwa/debug_new.h
>
38
#endif // CHECK_MEMORY_LEAKS
39
40
41
// ===========================================================================
42
// method definitions
43
// ===========================================================================
44
SUMORouteLoader::SUMORouteLoader
(
SUMORouteHandler
* handler)
45
: myParser(0), myMoreAvailable(true), myHandler(handler) {
46
myParser
=
XMLSubSys::getSAXReader
(*
myHandler
);
47
if
(!
myParser
->
parseFirst
(
myHandler
->
getFileName
())) {
48
throw
ProcessError
(
"Can not read XML-file '"
+
myHandler
->
getFileName
() +
"'."
);
49
}
50
}
51
52
53
SUMORouteLoader::~SUMORouteLoader
() {
54
delete
myParser
;
55
delete
myHandler
;
56
}
57
58
59
SUMOTime
60
SUMORouteLoader::loadUntil
(
SUMOTime
time) {
61
SUMOTime
firstDepart =
SUMOTime_MAX
;
62
// read only when further data is available, no error occured
63
// and vehicles may be found in the between the departure time of
64
// the last read vehicle and the time to read until
65
if
(!
myMoreAvailable
|| time <= myHandler->getLastDepart()) {
66
return
firstDepart;
67
}
68
69
// read vehicles until specified time or the period to read vehicles
70
// until is reached
71
while
(
myParser
->
parseNext
()) {
72
if
(firstDepart ==
SUMOTime_MAX
&&
myHandler
->
getLastDepart
() >= 0) {
73
firstDepart =
myHandler
->
getLastDepart
();
74
}
75
// return when the last read vehicle is beyond the period
76
if
(time <= myHandler->getLastDepart()) {
77
return
firstDepart;
78
}
79
}
80
81
// no data available anymore
82
myMoreAvailable
=
false
;
83
return
firstDepart;
84
}
85
86
87
bool
88
SUMORouteLoader::moreAvailable
()
const
{
89
return
myMoreAvailable
;
90
}
91
92
93
/****************************************************************************/
build
buildd
sumo-0.17.1~dfsg
src
utils
xml
SUMORouteLoader.cpp
Generated on Sun Jun 16 2013 17:30:19 for SUMO - Simulation of Urban MObility by
1.8.3.1