1 /****************************************************************************/ 2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo 3 // Copyright (C) 2001-2019 German Aerospace Center (DLR) and others. 4 // This program and the accompanying materials 5 // are made available under the terms of the Eclipse Public License v2.0 6 // which accompanies this distribution, and is available at 7 // http://www.eclipse.org/legal/epl-v20.html 8 // SPDX-License-Identifier: EPL-2.0 9 /****************************************************************************/ 10 /// @file MSStopOut.h 11 /// @author Jakob Erdmann 12 /// @date Wed, 21.12.2016 13 /// @version $Id$ 14 /// 15 // Ouput information about planned vehicle stop 16 /****************************************************************************/ 17 #ifndef MSStopOut_h 18 #define MSStopOut_h 19 20 21 // =========================================================================== 22 // included modules 23 // =========================================================================== 24 #include <config.h> 25 26 #include <map> 27 #include <utils/common/SUMOTime.h> 28 #include <microsim/MSVehicle.h> 29 30 31 // =========================================================================== 32 // class declarations 33 // =========================================================================== 34 class OutputDevice; 35 class SUMOVehicle; 36 37 38 // =========================================================================== 39 // class definitions 40 // =========================================================================== 41 /** 42 * @class MSStopOut 43 * @brief Realises dumping the complete network state 44 * 45 * The class offers a static method, which writes the complete dump of 46 * the given network into the given OutputDevice. 47 * 48 * @todo consider error-handling on write (using IOError) 49 */ 50 class MSStopOut { 51 public: 52 53 /** @brief Static intialization 54 */ 55 static void init(); 56 active()57 static bool active() { 58 return myInstance != 0; 59 } 60 61 static void cleanup(); 62 getInstance()63 static MSStopOut* getInstance() { 64 return myInstance; 65 } 66 67 /// @brief constructor. 68 MSStopOut(OutputDevice& dev); 69 70 /// @brief Destructor. 71 virtual ~MSStopOut(); 72 73 void stopStarted(const SUMOVehicle* veh, int numPersons, int numContainers, SUMOTime time); 74 75 void loadedPersons(const SUMOVehicle* veh, int n); 76 void unloadedPersons(const SUMOVehicle* veh, int n); 77 78 void loadedContainers(const SUMOVehicle* veh, int n); 79 void unloadedContainers(const SUMOVehicle* veh, int n); 80 81 void stopEnded(const SUMOVehicle* veh, const SUMOVehicleParameter::Stop& stop, const std::string& laneOrEdgeID); 82 83 84 private: 85 struct StopInfo { 86 StopInfoStopInfo87 StopInfo(SUMOTime t, int numPersons, int numContainers) : 88 started(t), 89 initialNumPersons(numPersons), 90 loadedPersons(0), 91 unloadedPersons(0), 92 initialNumContainers(numContainers), 93 loadedContainers(0), 94 unloadedContainers(0) { 95 } 96 97 // @note: need default constructor or std::map doesn't work StopInfoStopInfo98 StopInfo() : 99 started(-1), 100 initialNumPersons(0), 101 loadedPersons(0), 102 unloadedPersons(0), 103 initialNumContainers(0), 104 loadedContainers(0), 105 unloadedContainers(0) { 106 } 107 108 SUMOTime started; 109 int initialNumPersons; 110 int loadedPersons; 111 int unloadedPersons; 112 int initialNumContainers; 113 int loadedContainers; 114 int unloadedContainers; 115 }; 116 117 typedef std::map<const SUMOVehicle*, StopInfo> Stopped; 118 Stopped myStopped; 119 120 OutputDevice& myDevice; 121 122 static MSStopOut* myInstance; 123 124 /// @brief Invalidated copy constructor. 125 MSStopOut(const MSStopOut&); 126 127 /// @brief Invalidated assignment operator. 128 MSStopOut& operator=(const MSStopOut&); 129 130 131 }; 132 133 134 #endif 135 136 /****************************************************************************/ 137 138