Eclipse 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-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 /****************************************************************************/
18 // A device which is used to keep track of persons and containers riding with a vehicle
19 /****************************************************************************/
20 #ifndef MSDevice_Transportable_h
21 #define MSDevice_Transportable_h
22 
23 
24 // ===========================================================================
25 // included modules
26 // ===========================================================================
27 #include <config.h>
28 
29 #include <vector>
30 #include "MSVehicleDevice.h"
31 #include <utils/common/SUMOTime.h>
32 #include <microsim/MSVehicle.h>
34 
35 
36 // ===========================================================================
37 // class definitions
38 // ===========================================================================
44 public:
52  static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, const bool isContainer);
53 
54 
55 
56 public:
59 
60 
63 
73  bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
74 
75 
84  bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
85 
86 
96  bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
97  MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
99 
100 
102  const std::string deviceName() const {
103  return myAmContainer ? "container" : "person";
104  }
105 
107  std::string getParameter(const std::string& key) const;
108 
113  void addTransportable(MSTransportable* transportable);
114 
115 
120  void removeTransportable(MSTransportable* transportable);
121 
122 
126  int size() const {
127  return (int)myTransportables.size();
128  }
129 
130 
134  const std::vector<MSTransportable*>& getTransportables() const {
135  return myTransportables;
136  }
137 
138 protected:
142  void notifyMoveInternal(const SUMOTrafficObject& veh,
143  const double frontOnLane,
144  const double timeOnLane,
145  const double meanSpeedFrontOnLane,
146  const double meanSpeedVehicleOnLane,
147  const double travelledDistanceFrontOnLane,
148  const double travelledDistanceVehicleOnLane,
149  const double /* meanLengthOnLane */);
150 
151 private:
157  MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
158 
159 
160 
161 private:
164 
166  std::vector<MSTransportable*> myTransportables;
167 
169  bool myStopped;
170 
171 
172 private:
175 
178 
179 
180 };
181 
182 
183 #endif
184 
185 /****************************************************************************/
186 
SUMOTrafficObject
Representation of a vehicle or person.
Definition: SUMOTrafficObject.h:47
MSDevice_Transportable::getTransportables
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
Definition: MSDevice_Transportable.h:134
MSDevice_Transportable::myTransportables
std::vector< MSTransportable * > myTransportables
The passengers of the vehicle.
Definition: MSDevice_Transportable.h:166
SUMOTime.h
MSLane
Representation of a lane in the micro simulation.
Definition: MSLane.h:82
MSVehicleDevice.h
MSDevice_Transportable
Definition: MSDevice_Transportable.h:43
WrappingCommand.h
SUMOVehicle
Representation of a vehicle.
Definition: SUMOVehicle.h:60
MSTransportable
Definition: MSTransportable.h:58
MSVehicle.h
MSDevice_Transportable::myAmContainer
bool myAmContainer
Whether it is a container device.
Definition: MSDevice_Transportable.h:163
MSDevice_Transportable::myStopped
bool myStopped
Whether the vehicle is at a stop.
Definition: MSDevice_Transportable.h:169
MSDevice_Transportable::MSDevice_Transportable
MSDevice_Transportable(SUMOVehicle &holder, const std::string &id, const bool isContainer)
Constructor.
Definition: MSDevice_Transportable.cpp:53
MSDevice_Transportable::deviceName
const std::string deviceName() const
return the name for this type of device
Definition: MSDevice_Transportable.h:102
MSDevice_Transportable::MSDevice_Transportable
MSDevice_Transportable(const MSDevice_Transportable &)
Invalidated copy constructor.
MSDevice_Transportable::getParameter
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
Definition: MSDevice_Transportable.cpp:192
MSDevice_Transportable::buildVehicleDevices
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
Definition: MSDevice_Transportable.cpp:43
MSDevice_Transportable::operator=
MSDevice_Transportable & operator=(const MSDevice_Transportable &)
Invalidated assignment operator.
MSDevice_Transportable::notifyMove
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle is at a stop and transportable action is needed.
Definition: MSDevice_Transportable.cpp:86
MSDevice_Transportable::removeTransportable
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Definition: MSDevice_Transportable.cpp:176
MSDevice_Transportable::~MSDevice_Transportable
~MSDevice_Transportable()
Destructor.
Definition: MSDevice_Transportable.cpp:58
MSDevice_Transportable::addTransportable
void addTransportable(MSTransportable *transportable)
Add a passenger.
Definition: MSDevice_Transportable.cpp:163
MSDevice_Transportable::notifyLeave
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Passengers leaving on arrival.
Definition: MSDevice_Transportable.cpp:138
MSDevice_Transportable::size
int size() const
Return the number of passengers / containers.
Definition: MSDevice_Transportable.h:126
MSDevice_Transportable::notifyMoveInternal
void notifyMoveInternal(const SUMOTrafficObject &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()
Definition: MSDevice_Transportable.cpp:73
config.h
MSDevice_Transportable::notifyEnter
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds passengers on vehicle insertion.
Definition: MSDevice_Transportable.cpp:127
MSMoveReminder::Notification
Notification
Definition of a vehicle state.
Definition: MSMoveReminder.h:91
MSVehicleDevice
Abstract in-vehicle device.
Definition: MSVehicleDevice.h:54