/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2002-2026 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}949596/// @brief information for mandatory edges97struct Mandatory {98Mandatory(const ROEdge* e, double p, SUMOTime jump = -1):99edge(e),100pos(p),101isJump(jump >= 0) {}102103const ROEdge* edge;104double pos;105bool isJump;106};107108std::vector<Mandatory> getMandatoryEdges(const ROEdge* requiredStart, const ROEdge* requiredEnd) const;109110/** @brief Returns the vehicle's type definition111* @return The vehicle's type definition112*/113inline const SUMOVTypeParameter& getVTypeParameter() const {114return *getType();115}116117/// @brief Returns the vehicle's length118inline double getLength() const {119return getType()->length;120}121122inline bool hasJumps() const {123return myJumpTime >= 0;124}125126inline SUMOTime getJumpTime() const {127return myJumpTime;128}129130/** @brief Saves the complete vehicle description.131*132* Saves the vehicle itself including the route and stops.133*134* @param[in] os The routes or alternatives output device to store the vehicle's description into135* @param[in] typeos The types - output device to store types into136* @param[in] asAlternatives Whether the route shall be saved as route alternatives137* @param[in] options to find out about defaults and whether exit times for the edges shall be written138* @exception IOError If something fails (not yet implemented)139*/140void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const;141142143private:144/** @brief Adds a stop to this vehicle145*146* @param[in] stopPar the stop paramters147* @param[in] net pointer to the network, used for edge retrieval148*/149void addStop(const SUMOVehicleParameter::Stop& stopPar,150const RONet* net, MsgHandler* errorHandler);151152private:153/// @brief The route the vehicle takes154RORouteDef* const myRoute;155156/// @brief Whether this vehicle has any jumps defined157SUMOTime myJumpTime;158159/// @brief map of all routes that were already saved with a name160static std::map<ConstROEdgeVector, std::string> mySavedRoutes;161162private:163/// @brief Invalidated copy constructor164ROVehicle(const ROVehicle& src);165166/// @brief Invalidated assignment operator167ROVehicle& operator=(const ROVehicle& src);168169};170171172