SUMO - Simulation of Urban MObility
 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-2013 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>
40 #include <utils/xml/XMLSubSys.h>
42 #include "MSTriggeredReader.h"
43 #include "MSTriggeredXMLReader.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 // ===========================================================================
55  const std::string& filename)
56  : MSTriggeredReader(net),
57  SUMOSAXHandler(filename),
58  myParser(0), myHaveMore(true) {
61 }
62 
63 
65 
66 
67 bool
69  while (myHaveMore && myParser->parseNext()) {
70  if (nextRead()) {
71  return true;
72  }
73  }
74  myHaveMore = false;
75  return false;
76 }
77 
78 
79 void
81  try {
83  if (!myParser->parseFirst(getFileName())) {
84  throw ProcessError("Can not read XML-file '" + getFileName() + "'.");
85  }
86  } catch (XERCES_CPP_NAMESPACE::SAXException& e) {
87  throw ProcessError(TplConvert::_2str(e.getMessage()));
88  } catch (XERCES_CPP_NAMESPACE::XMLException& e) {
89  throw ProcessError(TplConvert::_2str(e.getMessage()));
90  }
91 
92  if (readNextTriggered()) {
93  if (myOffset < MSNet::getInstance()->getCurrentTimeStep()) {
95  // !!! Warning?
96  }
97  } else {
98  myHaveMore = false;
99  }
100 }
101 
102 
103 
104 /****************************************************************************/