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-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
22// A device which is used to keep track of persons and containers riding with a vehicle
23/****************************************************************************/
24#pragma once
25#include <config.h>
26
27#include <vector>
28#include "MSVehicleDevice.h"
30#include <microsim/MSVehicle.h>
32
33
34// ===========================================================================
35// class definitions
36// ===========================================================================
42public:
50 static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, const bool isContainer);
51
52
53
54public:
57
58
61
71 bool notifyMove(SUMOTrafficObject& veh, double oldPos, double newPos, double newSpeed);
72
73
82 bool notifyEnter(SUMOTrafficObject& veh, MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
83
84
94 bool notifyLeave(SUMOTrafficObject& veh, double lastPos,
95 MSMoveReminder::Notification reason, const MSLane* enteredLane = 0);
97
98
100 const std::string deviceName() const {
101 return myAmContainer ? "container" : "person";
102 }
103
105 std::string getParameter(const std::string& key) const;
106
111 void addTransportable(MSTransportable* transportable);
112
117 void removeTransportable(MSTransportable* transportable);
118
119
120 bool anyLeavingAtStop(const MSStop& stop) const;
121
126 void saveState(OutputDevice& out) const;
127
132 void loadState(const SUMOSAXAttributes& attrs);
133
137 int size() const {
138 return (int)myTransportables.size();
139 }
140
141
145 const std::vector<MSTransportable*>& getTransportables() const {
146 return myTransportables;
147 }
148
149protected:
154 const double frontOnLane,
155 const double timeOnLane,
156 const double meanSpeedFrontOnLane,
157 const double meanSpeedVehicleOnLane,
158 const double travelledDistanceFrontOnLane,
159 const double travelledDistanceVehicleOnLane,
160 const double meanLengthOnLane);
161
162private:
168 MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
169
170
171
172private:
174 const bool myAmContainer;
175
177 std::vector<MSTransportable*> myTransportables;
178
179 /* @brief Whether the vehicle is at a stop and the stop is finished
180 * true means, all passengers that wish to debord at the current stop have left
181 */
183
184
185private:
188
191
192
193};
MSDevice_Transportable(const MSDevice_Transportable &)
Invalidated copy constructor.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
void saveState(OutputDevice &out) const
Saves the state of the device.
bool notifyMove(SUMOTrafficObject &veh, double oldPos, double newPos, double newSpeed)
Checks whether the vehicle is at a stop and transportable action is needed.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
MSDevice_Transportable & operator=(const MSDevice_Transportable &)
Invalidated assignment operator.
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Passengers leaving on arrival.
bool anyLeavingAtStop(const MSStop &stop) const
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
bool notifyEnter(SUMOTrafficObject &veh, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Adds passengers on vehicle insertion.
int size() const
Return the number of passengers / containers.
MSDevice_Transportable(SUMOVehicle &holder, const std::string &id, const bool isContainer)
Constructor.
std::vector< MSTransportable * > myTransportables
The passengers of the vehicle.
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 meanLengthOnLane)
Internal notification about the vehicle moves, see MSMoveReminder::notifyMoveInternal()
void addTransportable(MSTransportable *transportable)
Add a passenger.
const bool myAmContainer
Whether it is a container device.
const std::string deviceName() const
return the name for this type of device
void loadState(const SUMOSAXAttributes &attrs)
Loads the state of the device from the given description.
void removeTransportable(MSTransportable *transportable)
Remove a passenger (TraCI)
Representation of a lane in the micro simulation.
Definition: MSLane.h:84
Notification
Definition of a vehicle state.
Definition: MSStop.h:44
Abstract in-vehicle device.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:61
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:60