SUMO - Simulation of Urban MObility
MSDevice_Transportable.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2018 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 /****************************************************************************/
19 // A device which is used to keep track of persons and containers riding with a vehicle
20 /****************************************************************************/
21 #ifndef MSDevice_Transportable_h
22 #define MSDevice_Transportable_h
23 
24 
25 // ===========================================================================
26 // included modules
27 // ===========================================================================
28 #include <config.h>
29 
30 #include <vector>
31 #include "MSVehicleDevice.h"
32 #include <utils/common/SUMOTime.h>
33 #include <microsim/MSVehicle.h>
35 
36 
37 // ===========================================================================
38 // class definitions
39 // ===========================================================================
45 public:
53  static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, const bool isContainer);
54 
55 
56 
57 public:
60 
61 
64 
74  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
75 
76 
85  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
86 
87 
97  bool notifyLeave(SUMOVehicle& veh, double lastPos,
98  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
100 
101 
103  const std::string deviceName() const {
104  return myAmContainer ? "container" : "person";
105  }
106 
108  std::string getParameter(const std::string& key) const;
109 
114  void addTransportable(MSTransportable* transportable);
115 
116 
121  void removeTransportable(MSTransportable* transportable);
122 
123 
127  int size() const {
128  return (int)myTransportables.size();
129  }
130 
131 
135  const std::vector<MSTransportable*>& getTransportables() const {
136  return myTransportables;
137  }
138 
139 protected:
143  void notifyMoveInternal(const SUMOVehicle& veh,
144  const double frontOnLane,
145  const double timeOnLane,
146  const double meanSpeedFrontOnLane,
147  const double meanSpeedVehicleOnLane,
148  const double travelledDistanceFrontOnLane,
149  const double travelledDistanceVehicleOnLane,
150  const double /* meanLengthOnLane */);
151 
152 private:
158  MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
159 
160 
161 
162 private:
165 
167  std::vector<MSTransportable*> myTransportables;
168 
170  bool myStopped;
171 
172 
173 private:
176 
179 
180 
181 };
182 
183 
184 #endif
185 
186 /****************************************************************************/
187 
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.
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:60
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.
void notifyMoveInternal(const SUMOVehicle &veh, const double frontOnLane, const double timeOnLane, const double meanSpeedFrontOnLane, const double meanSpeedVehicleOnLane, const double travelledDistanceFrontOnLane, const double travelledDistanceVehicleOnLane, const double)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal() ...
bool notifyEnter(SUMOVehicle &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds passengers on vehicle insertion.
Abstract in-vehicle device.
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:78
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice *> &into, const bool isContainer)
Build devices for the given vehicle, if needed.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...