SUMO - Simulation of Urban MObility
MSDevice_Transportable.h
Go to the documentation of this file.
1 /****************************************************************************/
11 // A device which is used to keep track of persons and containers riding with a vehicle
12 /****************************************************************************/
13 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
14 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
15 /****************************************************************************/
16 //
17 // This file is part of SUMO.
18 // SUMO is free software: you can redistribute it and/or modify
19 // it under the terms of the GNU General Public License as published by
20 // the Free Software Foundation, either version 3 of the License, or
21 // (at your option) any later version.
22 //
23 /****************************************************************************/
24 #ifndef MSDevice_Transportable_h
25 #define MSDevice_Transportable_h
26 
27 
28 // ===========================================================================
29 // included modules
30 // ===========================================================================
31 #ifdef _MSC_VER
32 #include <windows_config.h>
33 #else
34 #include <config.h>
35 #endif
36 
37 #include <vector>
38 #include "MSDevice.h"
39 #include <utils/common/SUMOTime.h>
40 #include <microsim/MSVehicle.h>
42 
43 
44 // ===========================================================================
45 // class definitions
46 // ===========================================================================
52 public:
60  static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into, const bool isContainer);
61 
62 
63 
64 public:
67 
68 
71 
81  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
82 
83 
92  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
93 
94 
104  bool notifyLeave(SUMOVehicle& veh, double lastPos,
105  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
107 
108 
110  const std::string deviceName() const {
111  return myAmContainer ? "container" : "person";
112  }
113 
115  std::string getParameter(const std::string& key) const;
116 
121  void addTransportable(MSTransportable* transportable);
122 
123 
128  void removeTransportable(MSTransportable* transportable);
129 
130 
134  int size() const {
135  return (int)myTransportables.size();
136  }
137 
138 
142  const std::vector<MSTransportable*>& getTransportables() const {
143  return myTransportables;
144  }
145 
146 
147 
148 private:
154  MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
155 
156 
157 
158 private:
161 
163  std::vector<MSTransportable*> myTransportables;
164 
166  bool myStopped;
167 
168 
169 private:
172 
175 
176 
177 };
178 
179 
180 #endif
181 
182 /****************************************************************************/
183 
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
int size() const
Return the number of passengers / containers.
Notification
Definition of a vehicle state.
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSDevice *> &into, const bool isContainer)
Build devices for the given vehicle, if needed.
bool notifyMove(SUMOVehicle &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle is at a stop and transportable action is needed.
MSDevice_Transportable & operator=(const MSDevice_Transportable &)
Invalidated assignment operator.
Representation of a vehicle.
Definition: SUMOVehicle.h:67
const std::string deviceName() const
return the name for this type of device
void addTransportable(MSTransportable *transportable)
Add a passenger.
bool notifyLeave(SUMOVehicle &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Passengers leaving on arrival.
bool myAmContainer
Whether it is a container device.
Abstract in-vehicle device.
Definition: MSDevice.h:71
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds passengers on vehicle insertion.
MSDevice_Transportable(SUMOVehicle &holder, const std::string &id, const bool isContainer)
Constructor.
bool myStopped
Whether the vehicle is at a stop.
std::vector< MSTransportable * > myTransportables
The passengers of the vehicle.
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Representation of a lane in the micro simulation.
Definition: MSLane.h:79
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...