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
MSTriggeredXMLReader.cpp
Go to the documentation of this file.
1
/****************************************************************************/
9
// The basic class for classes that read XML-triggers
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
// 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 <xercesc/sax2/SAX2XMLReader.hpp>
34
#include <xercesc/sax/SAXException.hpp>
35
#include <xercesc/sax/SAXParseException.hpp>
36
#include <
utils/common/TplConvert.h
>
37
#include <
utils/common/MsgHandler.h
>
38
#include <
utils/common/UtilExceptions.h
>
39
#include <
utils/xml/SUMOSAXHandler.h
>
40
#include <
utils/xml/XMLSubSys.h
>
41
#include <
microsim/MSEventControl.h
>
42
#include "
MSTriggeredReader.h
"
43
#include "
MSTriggeredXMLReader.h
"
44
#include <
utils/common/WrappingCommand.h
>
45
46
#ifdef CHECK_MEMORY_LEAKS
47
#include <
foreign/nvwa/debug_new.h
>
48
#endif // CHECK_MEMORY_LEAKS
49
50
51
// ===========================================================================
52
// method definitions
53
// ===========================================================================
54
MSTriggeredXMLReader::MSTriggeredXMLReader
(
MSNet
& net,
55
const
std::string& filename)
56
:
MSTriggeredReader
(net),
57
SUMOSAXHandler
(filename),
58
myParser(0), myHaveMore(true) {
59
Command
* c =
new
WrappingCommand< MSTriggeredReader >
(
this
, &
MSTriggeredReader::wrappedExecute
);
60
MSNet::getInstance
()->
getInsertionEvents
().
addEvent
(c, net.
getCurrentTimeStep
(),
MSEventControl::NO_CHANGE
);
61
}
62
63
64
MSTriggeredXMLReader::~MSTriggeredXMLReader
() {}
65
66
67
bool
68
MSTriggeredXMLReader::readNextTriggered
() {
69
while
(
myHaveMore
&&
myParser
->parseNext(
myToken
)) {
70
if
(
nextRead
()) {
71
return
true
;
72
}
73
}
74
myHaveMore
=
false
;
75
return
false
;
76
}
77
78
79
void
80
MSTriggeredXMLReader::myInit
() {
81
try
{
82
myParser
=
XMLSubSys::getSAXReader
(*
this
);
83
if
(!
myParser
->parseFirst(
getFileName
().c_str(),
myToken
)) {
84
throw
ProcessError
(
"Can not read XML-file '"
+
getFileName
() +
"'."
);
85
86
}
87
}
catch
(SAXException& e) {
88
throw
ProcessError
(
TplConvert<XMLCh>::_2str
(e.getMessage()));
89
90
}
catch
(XMLException& e) {
91
throw
ProcessError
(
TplConvert<XMLCh>::_2str
(e.getMessage()));
92
93
}
94
95
if
(
readNextTriggered
()) {
96
if
(
myOffset
<
MSNet::getInstance
()->getCurrentTimeStep()) {
97
myOffset
=
MSNet::getInstance
()->
getCurrentTimeStep
() + 1;
98
// !!! Warning?
99
}
100
}
else
{
101
myHaveMore
=
false
;
102
}
103
}
104
105
106
107
/****************************************************************************/
108
var
build
temp
tmp.znCyBrHNjL
4.0-0-0
sumo
sumo-0.15.0~dfsg
src
microsim
trigger
MSTriggeredXMLReader.cpp
Generated on Mon Mar 24 2014 09:53:11 for SUMO - Simulation of Urban MObility by
1.8.1.2