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-2020 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"
29 #include <utils/common/SUMOTime.h>
30 #include <microsim/MSVehicle.h>
32 
33 
34 // ===========================================================================
35 // class definitions
36 // ===========================================================================
42 public:
50  static MSDevice_Transportable* buildVehicleDevices(SUMOVehicle& v, std::vector<MSVehicleDevice*>& into, const bool isContainer);
51 
52 
53 
54 public:
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 
123  void saveState(OutputDevice& out) const;
124 
129  void loadState(const SUMOSAXAttributes& attrs);
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 protected:
150  void notifyMoveInternal(const SUMOTrafficObject& veh,
151  const double frontOnLane,
152  const double timeOnLane,
153  const double meanSpeedFrontOnLane,
154  const double meanSpeedVehicleOnLane,
155  const double travelledDistanceFrontOnLane,
156  const double travelledDistanceVehicleOnLane,
157  const double /* meanLengthOnLane */);
158 
159 private:
165  MSDevice_Transportable(SUMOVehicle& holder, const std::string& id, const bool isContainer);
166 
167 
168 
169 private:
171  const bool myAmContainer;
172 
174  std::vector<MSTransportable*> myTransportables;
175 
177  bool myStopped;
178 
179 
180 private:
183 
186 
187 
188 };
MSDevice_Transportable(const MSDevice_Transportable &)
Invalidated copy constructor.
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.
const std::vector< MSTransportable * > & getTransportables() const
Returns the list of transportables using this vehicle.
std::string getParameter(const std::string &key) const
try to retrieve the given parameter from this device. Throw exception for unsupported key
bool notifyLeave(SUMOTrafficObject &veh, double lastPos, MSMoveReminder::Notification reason, const MSLane *enteredLane=0)
Passengers leaving on arrival.
static MSDevice_Transportable * buildVehicleDevices(SUMOVehicle &v, std::vector< MSVehicleDevice * > &into, const bool isContainer)
Build devices for the given vehicle, if needed.
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()
bool myStopped
Whether the vehicle is at a stop.
MSDevice_Transportable & operator=(const MSDevice_Transportable &)
Invalidated assignment operator.
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 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:82
Notification
Definition of a vehicle state.
Abstract in-vehicle device.
Static storage of an output device and its base (abstract) implementation.
Definition: OutputDevice.h:60
Encapsulated SAX-Attributes.
Representation of a vehicle, person, or container.
Representation of a vehicle.
Definition: SUMOVehicle.h:58