SUMO - Simulation of Urban MObility
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.dlr.de/
11 // Copyright (C) 2002-2016 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 
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 // ===========================================================================
45  : myParser(0), myMoreAvailable(true), myHandler(handler) {
48  throw ProcessError("Can not read XML-file '" + myHandler->getFileName() + "'.");
49  }
50 }
51 
52 
54  delete myParser;
55  delete myHandler;
56 }
57 
58 
61  // read only when further data is available, no error occured
62  // and vehicles may be found in the between the departure time of
63  // the last read vehicle and the time to read until
64  if (!myMoreAvailable) {
65  return SUMOTime_MAX;
66  }
67  // read vehicles until specified time or the period to read vehicles
68  // until is reached
69  while (myHandler->getLastDepart() <= time) {
70  if (!myParser->parseNext()) {
71  // no data available anymore
72  myMoreAvailable = false;
73  return SUMOTime_MAX;
74  }
75  }
76  return myHandler->getLastDepart();
77 }
78 
79 
80 bool
82  return myMoreAvailable;
83 }
84 
85 
88  return myHandler->getFirstDepart();
89 }
90 
91 
92 /****************************************************************************/
long long int SUMOTime
Definition: SUMOTime.h:43
const std::string & getFileName() const
returns the current file name
bool myMoreAvailable
information whether more vehicles should be available
~SUMORouteLoader()
destructor
SUMOTime getLastDepart() const
Returns the last loaded depart time.
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
bool moreAvailable() const
returns the information whether new data is available
SUMOTime loadUntil(SUMOTime time)
SUMOTime getFirstDepart() const
returns the first departure time that was ever read
static SUMOSAXReader * getSAXReader(SUMOSAXHandler &handler)
Builds a reader and assigns the handler to it.
Definition: XMLSubSys.cpp:102
SUMORouteHandler * myHandler
the used Handler
Parser for routes during their loading.
bool parseFirst(std::string systemID)
#define SUMOTime_MAX
Definition: SUMOTime.h:44
SUMOSAXReader * myParser
the used SAXReader
SUMORouteLoader(SUMORouteHandler *handler)
constructor