/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file ROVehicle.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @author Jakob Erdmann17/// @date Sept 200218///19// A vehicle as used by router20/****************************************************************************/21#pragma once22#include <config.h>2324#include <string>25#include <iostream>26#include <utils/common/StdDefs.h>27#include <utils/common/SUMOTime.h>28#include <utils/vehicle/SUMOVehicleParameter.h>29#include <utils/vehicle/SUMOVTypeParameter.h>30#include "RORoutable.h"313233// ===========================================================================34// class declarations35// ===========================================================================36class OutputDevice;37class ROEdge;38class RONet;39class RORouteDef;404142// ===========================================================================43// class definitions44// ===========================================================================45/**46* @class ROVehicle47* @brief A vehicle as used by router48*/49class ROVehicle : public RORoutable {50public:51/** @brief Constructor52*53* @param[in] pars Parameter of this vehicle54* @param[in] route The definition of the route the vehicle shall use55* @param[in] type The type of the vehicle56*/57ROVehicle(const SUMOVehicleParameter& pars,58RORouteDef* route, const SUMOVTypeParameter* type,59const RONet* net, MsgHandler* errorHandler = 0);606162/// @brief Destructor63virtual ~ROVehicle();646566/** @brief Returns the definition of the route the vehicle takes67*68* @return The vehicle's route definition69*70* @todo Why not return a reference?71*/72inline RORouteDef* getRouteDefinition() const {73return myRoute;74}757677/** @brief Returns the first edge the vehicle takes78*79* @return The vehicle's departure edge80*/81const ROEdge* getDepartEdge() const;828384void computeRoute(const RORouterProvider& provider,85const bool removeLoops, MsgHandler* errorHandler);8687/** @brief Returns the time the vehicle starts at, 0 for triggered vehicles88*89* @return The vehicle's depart time90*/91inline SUMOTime getDepartureTime() const {92return MAX2(SUMOTime(0), getParameter().depart);93}949596inline const ConstROEdgeVector& getStopEdges() const {97return myStopEdges;98}99100101/// @brief compute mandatory edges102ConstROEdgeVector getMandatoryEdges(const ROEdge* requiredStart, const ROEdge* requiredEnd) const;103104/** @brief Returns an upper bound for the speed factor of this vehicle105*106* @return the maximum speed factor107*/108inline double getChosenSpeedFactor() const {109return getType()->speedFactor.getMax();110}111112/** @brief Returns the vehicle's type definition113* @return The vehicle's type definition114*/115inline const SUMOVTypeParameter& getVehicleType() const {116return *getType();117}118119/// @brief Returns the vehicle's length120inline double getLength() const {121return getType()->length;122}123124inline bool hasJumps() const {125return myJumpTime >= 0;126}127128inline SUMOTime getJumpTime() const {129return myJumpTime;130}131132/// @brief collect mandatory-edge iterators that define jumps in the route133void collectJumps(const ConstROEdgeVector& mandatory, std::set<ConstROEdgeVector::const_iterator>& jumpStarts) const;134135/** @brief Saves the complete vehicle description.136*137* Saves the vehicle itself including the route and stops.138*139* @param[in] os The routes or alternatives output device to store the vehicle's description into140* @param[in] typeos The types - output device to store types into141* @param[in] asAlternatives Whether the route shall be saved as route alternatives142* @param[in] options to find out about defaults and whether exit times for the edges shall be written143* @exception IOError If something fails (not yet implemented)144*/145void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const;146147148private:149/** @brief Adds a stop to this vehicle150*151* @param[in] stopPar the stop paramters152* @param[in] net pointer to the network, used for edge retrieval153*/154void addStop(const SUMOVehicleParameter::Stop& stopPar,155const RONet* net, MsgHandler* errorHandler);156157private:158/// @brief The route the vehicle takes159RORouteDef* const myRoute;160161/// @brief The edges where the vehicle stops162ConstROEdgeVector myStopEdges;163164/// @brief Whether this vehicle has any jumps defined165SUMOTime myJumpTime;166167/// @brief map of all routes that were already saved with a name168static std::map<ConstROEdgeVector, std::string> mySavedRoutes;169170private:171/// @brief Invalidated copy constructor172ROVehicle(const ROVehicle& src);173174/// @brief Invalidated assignment operator175ROVehicle& operator=(const ROVehicle& src);176177};178179180