/****************************************************************************/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 RORoutable.h14/// @author Michael Behrisch15/// @date Oct 201516///17// A routable thing such as a vehicle or person18/****************************************************************************/19#pragma once20#include <config.h>2122#include <string>23#include <iostream>24#include <utils/common/StdDefs.h>25#include <utils/common/SUMOTime.h>26#include <utils/router/RouterProvider.h>27#include <utils/vehicle/SUMOVehicleParameter.h>28#include <utils/vehicle/SUMOVTypeParameter.h>2930// ===========================================================================31// class declarations32// ===========================================================================33class OutputDevice;34class ROEdge;35class ROLane;36class RONode;37class ROVehicle;3839typedef std::vector<const ROEdge*> ConstROEdgeVector;40typedef IntermodalRouter<ROEdge, ROLane, RONode, ROVehicle> ROIntermodalRouter;41typedef RouterProvider<ROEdge, ROLane, RONode, ROVehicle> RORouterProvider;424344// ===========================================================================45// class definitions46// ===========================================================================47/**48* @class RORoutable49* @brief A routable thing such as a vehicle or person50*/51class RORoutable {52public:53/** @brief Constructor54*55* @param[in] pars Parameter of this routable56* @param[in] type The type of the routable57*/58RORoutable(const SUMOVehicleParameter& pars, const SUMOVTypeParameter* type)59: myParameter(pars), myType(type), myRoutingSuccess(false) {}606162/// @brief Destructor63virtual ~RORoutable() {}646566/** @brief Returns the definition of the vehicle / person parameter67*68* @return The vehicle / person's parameter69*/70inline const SUMOVehicleParameter& getParameter() const {71return myParameter;72}737475/** @brief Returns the type of the routable76*77* @return The routable's type78*79* @todo Why not return a reference?80*/81inline const SUMOVTypeParameter* getType() const {82return myType;83}848586/** @brief Returns the id of the routable87*88* @return The id of the routable89*/90inline const std::string& getID() const {91return myParameter.id;92}939495/** @brief Returns the time the vehicle starts at, -1 for triggered vehicles96*97* @return The vehicle's depart time98*/99inline SUMOTime getDepart() const {100return myParameter.depart;101}102103/// @brief update depart time (for triggered persons)104inline void setDepart(SUMOTime t) {105myParameter.depart = t;106}107108inline SUMOVehicleClass getVClass() const {109return getType() != 0 ? getType()->vehicleClass : SVC_IGNORING;110}111112/** @brief Returns whether this object is ignoring transient permission113* changes (during routing)114*/115bool ignoreTransientPermissions() const {116return false;117};118119/// @brief Returns the vehicle's maximum speed120inline double getMaxSpeed() const {121return MIN2(getType()->maxSpeed,122getType()->desiredMaxSpeed * getType()->speedFactor.getParameter(0));123}124125virtual const ROEdge* getDepartEdge() const = 0;126127128inline bool isPublicTransport() const {129return myParameter.line != "";130}131132inline bool isPartOfFlow() const {133return myParameter.repetitionNumber >= 0;134}135136virtual void computeRoute(const RORouterProvider& provider,137const bool removeLoops, MsgHandler* errorHandler) = 0;138139140/** @brief Saves the routable including the vehicle type (if it was not saved before).141*142* @param[in] os The routes - output device to store the vehicle's description into143* @param[in] altos The route alternatives - output device to store the vehicle's description into144* @param[in] typeos The types - output device to store the vehicle types into145* @exception IOError If something fails (not yet implemented)146*/147void write(OutputDevice* os, OutputDevice* const altos,148OutputDevice* const typeos, OptionsCont& options, int quota) const {149for (int i = 0; i < quota; i++) {150if (os != nullptr) {151if (altos == nullptr && typeos == nullptr) {152saveAsXML(*os, os, false, options, i);153} else {154saveAsXML(*os, typeos, false, options, i);155}156}157if (altos != nullptr) {158saveAsXML(*altos, typeos, true, options, i);159}160}161}162163164inline bool getRoutingSuccess() const {165return myRoutingSuccess;166}167168169protected:170/** @brief Saves the complete routable description.171*172* Saves the routable itself including the route and stops.173*174* @param[in] os The routes or alternatives output device to store the routable's description into175* @param[in] typeos The types - output device to store additional types into176* @param[in] asAlternatives Whether the route shall be saved as route alternatives177* @param[in] options to find out about defaults and whether exit times for the edges shall be written178* @exception IOError If something fails (not yet implemented)179*/180virtual void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const = 0;181182183private:184/// @brief The vehicle's parameter185SUMOVehicleParameter myParameter;186187/// @brief The type of the vehicle188const SUMOVTypeParameter* const myType;189190protected:191/// @brief Whether the last routing was successful192bool myRoutingSuccess;193194195private:196/// @brief Invalidated copy constructor197RORoutable(const RORoutable& src);198199/// @brief Invalidated assignment operator200RORoutable& operator=(const RORoutable& src);201202};203204205