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