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-2017 German Aerospace Center (DLR) and others.
4 /****************************************************************************/
5 //
6 // This program and the accompanying materials
7 // are made available under the terms of the Eclipse Public License v2.0
8 // which accompanies this distribution, and is available at
9 // http://www.eclipse.org/legal/epl-v20.html
10 //
11 /****************************************************************************/
21 // A device which is used to keep track of persons and containers riding with a vehicle
22 /****************************************************************************/
23 #ifndef MSDevice_Transportable_h
24 #define MSDevice_Transportable_h
25 
26 
27 // ===========================================================================
28 // included modules
29 // ===========================================================================
30 #ifdef _MSC_VER
31 #include <windows_config.h>
32 #else
33 #include <config.h>
34 #endif
35 
36 #include <vector>
37 #include "MSDevice.h"
38 #include <utils/common/SUMOTime.h>
39 #include <microsim/MSVehicle.h>
41 
42 
43 // ===========================================================================
44 // class definitions
45 // ===========================================================================
51 public:
59  static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSDevice*>& into, const bool isContainer);
60 
61 
62 
63 public:
66 
67 
70 
80  bool notifyMove(SUMOVehicle& veh, double oldPos, double newPos, double newSpeed);
81 
82 
91  bool notifyEnter(SUMOVehicle& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
92 
93 
103  bool notifyLeave(SUMOVehicle& veh, double lastPos,
104  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
106 
107 
109  const std::string deviceName() const {
110  return myAmContainer ? "container" : "person";
111  }
112 
114  std::string getParameter(const std::string& key) const;
115 
120  void addTransportable(MSTransportable* transportable);
121 
122 
127  void removeTransportable(MSTransportable* transportable);
128 
129 
133  int size() const {
134  return (int)myTransportables.size();
135  }
136 
137 
141  const std::vector<MSTransportable*>& getTransportables() const {
142  return myTransportables;
143  }
144 
145 
146 
147 private:
153  MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
154 
155 
156 
157 private:
160 
162  std::vector<MSTransportable*> myTransportables;
163 
165  bool myStopped;
166 
167 
168 private:
171 
174 
175 
176 };
177 
178 
179 #endif
180 
181 /****************************************************************************/
182 
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:66
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:70
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:77
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key ...