SUMO - Simulation of Urban MObility
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SUMORouteLoaderControl.cpp
Go to the documentation of this file.
1 /****************************************************************************/
9 // Class responsible for loading of routes from some files
10 /****************************************************************************/
11 // SUMO, Simulation of Urban MObility; see http://sumo-sim.org/
12 // Copyright (C) 2002-2014 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 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #ifdef _MSC_VER
28 #include <windows_config.h>
29 #else
30 #include <config.h>
31 #endif
32 
33 #include <vector>
34 #include <utils/common/StdDefs.h>
35 #include "SUMORouteLoader.h"
36 #include "SUMORouteLoaderControl.h"
37 
38 #ifdef CHECK_MEMORY_LEAKS
39 #include <foreign/nvwa/debug_new.h>
40 #endif // CHECK_MEMORY_LEAKS
41 
42 
43 // ===========================================================================
44 // method definitions
45 // ===========================================================================
47  myFirstLoadTime(SUMOTime_MAX),
48  myInAdvanceStepNo(inAdvanceStepNo),
49  myRouteLoaders(),
50  myLoadAll(inAdvanceStepNo <= 0),
51  myAllLoaded(false) {
52 }
53 
54 
56  for (std::vector<SUMORouteLoader*>::iterator i = myRouteLoaders.begin();
57  i != myRouteLoaders.end(); ++i) {
58  delete(*i);
59  }
60 }
61 
62 
63 void
65  myRouteLoaders.push_back(loader);
66 }
67 
68 
69 void
71  // check whether new vehicles shall be loaded
72  // return if not
73  if (myAllLoaded) {
74  return;
75  }
76  SUMOTime loadMaxTime = myLoadAll ? SUMOTime_MAX : step + myInAdvanceStepNo;
77 
78  // load all routes for the specified time period
79  bool furtherAvailable = false;
80  for (std::vector<SUMORouteLoader*>::iterator i = myRouteLoaders.begin(); i != myRouteLoaders.end(); ++i) {
81  myFirstLoadTime = MIN2(myFirstLoadTime, (*i)->loadUntil(loadMaxTime));
82  furtherAvailable |= (*i)->moreAvailable();
83  }
84  myAllLoaded = !furtherAvailable;
85 }
86 
87 
88 /****************************************************************************/