/****************************************************************************/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 RORoute.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @author Jakob Erdmann17/// @author Yun-Pang Floetteroed18/// @date Sept 200219///20// A complete router's route21/****************************************************************************/22#pragma once23#include <config.h>2425#include <string>26#include <utils/common/Named.h>27#include <utils/common/RGBColor.h>28#include <utils/router/SUMOAbstractRouter.h>29#include <utils/vehicle/SUMOVehicleParameter.h>303132// ===========================================================================33// class declarations34// ===========================================================================35class ROEdge;36class ROVehicle;37class OutputDevice;3839typedef std::vector<const ROEdge*> ConstROEdgeVector;4041// ===========================================================================42// class definitions43// ===========================================================================44/**45* @class RORoute46* @brief A complete router's route47*48* This class represents a single and complete vehicle route after being49* computed/imported.50*/51class RORoute : public Named {52public:53/** @brief Constructor54*55* @param[in] id The route's id56* @param[in] costs The route's costs57* @param[in] prob The route's probability58* @param[in] route The list of edges the route is made of59* @param[in] color The (optional) color of this route60*61* @todo Are costs/prob really mandatory?62*/63RORoute(const std::string& id, double costs, double prob,64const ConstROEdgeVector& route, const RGBColor* const color,65const StopParVector& stops);666768/** @brief Constructor69*70* @param[in] id The route's id71* @param[in] route The list of edges the route is made of72*/73RORoute(const std::string& id, const ConstROEdgeVector& route);7475/** @brief Copy constructor76*77* @param[in] src The route to copy78*/79RORoute(const RORoute& src);808182/// @brief Destructor83~RORoute();848586/** @brief Returns the first edge in the route87*88* @return The route's first edge89*/90const ROEdge* getFirst() const {91return myRoute[0];92}939495/** @brief Returns the last edge in the route96*97* @return The route's last edge98*/99const ROEdge* getLast() const {100return myRoute.back();101}102103104/** @brief Returns the costs of the route105*106* @return The route's costs (normally the time needed to pass it)107* @todo Recheck why the costs are stored in a route108*/109double getCosts() const {110return myCosts;111}112113114/** @brief Returns the probability the driver will take this route with115*116* @return The probability to choose the route117* @todo Recheck why the probability is stored in a route118*/119double getProbability() const {120return myProbability;121}122123124/** @brief Sets the costs of the route125*126* @todo Recheck why the costs are stored in a route127*/128void setCosts(double costs);129130131/** @brief Sets the probability of the route132*133* @todo Recheck why the probability is stored in a route134*/135void setProbability(double prob);136137138/** @brief Returns the number of edges in this route139*140* @return The number of edges the route is made of141*/142int size() const {143return (int) myRoute.size();144}145146147/** @brief Returns the list of edges this route consists of148*149* @return The edges this route consists of150*/151const ConstROEdgeVector& getEdgeVector() const {152return myRoute;153}154155/** @brief Returns this route's color156*157* @return This route's color158*/159const RGBColor* getColor() const {160return myColor;161}162163164/** @brief Checks whether this route contains loops and removes such165*/166void recheckForLoops(const ConstROEdgeVector& mandatory);167168169/// @brief check whether the route is valid for the given vehicle170bool isValid(const ROVehicle& veh, bool ignoreErrors) const;171172OutputDevice&173writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,174const bool withCosts, const bool asAlternatives,175const bool withExitTimes, const bool withLength,176const std::string& id = "") const;177178/** @brief add additional vehicles/probability179*/180void addProbability(double prob);181182/** @brief Returns the list of stops this route contains183*184* @return list of stops185*/186const StopParVector& getStops() const {187return myStops;188}189190/** @brief Adapts the until time of all stops by the given offset191*/192void addStopOffset(const SUMOTime offset) {193for (StopParVector::iterator stop = myStops.begin(); stop != myStops.end(); ++stop) {194if (stop->until >= 0) {195stop->until += offset;196}197}198}199200/// @brief return edges that shall be written in the route definition201ConstROEdgeVector getNormalEdges() const;202203private:204/// @brief The costs of the route205double myCosts;206207/// @brief The probability the driver will take this route with208double myProbability;209210/// @brief The edges the route consists of211ConstROEdgeVector myRoute;212213/// @brief The color of the route214const RGBColor* myColor;215216/// @brief List of the stops on the parsed route217StopParVector myStops;218219220private:221/// @brief Invalidated assignment operator222RORoute& operator=(const RORoute& src);223224};225226227