LCOV - code coverage report
Current view: top level - src/router - RORoute.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 11 11
Test Date: 2024-12-21 15:45:41 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2002-2024 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              : /****************************************************************************/
      14              : /// @file    RORoute.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Jakob Erdmann
      18              : /// @author  Yun-Pang Floetteroed
      19              : /// @date    Sept 2002
      20              : ///
      21              : // A complete router's route
      22              : /****************************************************************************/
      23              : #pragma once
      24              : #include <config.h>
      25              : 
      26              : #include <string>
      27              : #include <utils/common/Named.h>
      28              : #include <utils/common/RGBColor.h>
      29              : #include <utils/router/SUMOAbstractRouter.h>
      30              : #include <utils/vehicle/SUMOVehicleParameter.h>
      31              : 
      32              : 
      33              : // ===========================================================================
      34              : // class declarations
      35              : // ===========================================================================
      36              : class ROEdge;
      37              : class ROVehicle;
      38              : class OutputDevice;
      39              : 
      40              : typedef std::vector<const ROEdge*> ConstROEdgeVector;
      41              : 
      42              : // ===========================================================================
      43              : // class definitions
      44              : // ===========================================================================
      45              : /**
      46              :  * @class RORoute
      47              :  * @brief A complete router's route
      48              :  *
      49              :  * This class represents a single and complete vehicle route after being
      50              :  *  computed/imported.
      51              :  */
      52              : class RORoute : public Named {
      53              : public:
      54              :     /** @brief Constructor
      55              :      *
      56              :      * @param[in] id The route's id
      57              :      * @param[in] costs The route's costs
      58              :      * @param[in] prob The route's probability
      59              :      * @param[in] route The list of edges the route is made of
      60              :      * @param[in] color The (optional) color of this route
      61              :      *
      62              :      * @todo Are costs/prob really mandatory?
      63              :      */
      64              :     RORoute(const std::string& id, double costs, double prob,
      65              :             const ConstROEdgeVector& route, const RGBColor* const color,
      66              :             const std::vector<SUMOVehicleParameter::Stop>& stops);
      67              : 
      68              : 
      69              :     /** @brief Constructor
      70              :      *
      71              :      * @param[in] id The route's id
      72              :      * @param[in] route The list of edges the route is made of
      73              :      */
      74              :     RORoute(const std::string& id, const ConstROEdgeVector& route);
      75              : 
      76              :     /** @brief Copy constructor
      77              :      *
      78              :      * @param[in] src The route to copy
      79              :      */
      80              :     RORoute(const RORoute& src);
      81              : 
      82              : 
      83              :     /// @brief Destructor
      84              :     ~RORoute();
      85              : 
      86              : 
      87              :     /** @brief Returns the first edge in the route
      88              :      *
      89              :      * @return The route's first edge
      90              :      */
      91              :     const ROEdge* getFirst() const {
      92       248240 :         return myRoute[0];
      93              :     }
      94              : 
      95              : 
      96              :     /** @brief Returns the last edge in the route
      97              :      *
      98              :      * @return The route's last edge
      99              :      */
     100              :     const ROEdge* getLast() const {
     101       247853 :         return myRoute.back();
     102              :     }
     103              : 
     104              : 
     105              :     /** @brief Returns the costs of the route
     106              :      *
     107              :      * @return The route's costs (normally the time needed to pass it)
     108              :      * @todo Recheck why the costs are stored in a route
     109              :      */
     110              :     double getCosts() const {
     111       475253 :         return myCosts;
     112              :     }
     113              : 
     114              : 
     115              :     /** @brief Returns the probability the driver will take this route with
     116              :      *
     117              :      * @return The probability to choose the route
     118              :      * @todo Recheck why the probability is stored in a route
     119              :      */
     120              :     double getProbability() const {
     121      1367076 :         return myProbability;
     122              :     }
     123              : 
     124              : 
     125              :     /** @brief Sets the costs of the route
     126              :      *
     127              :      * @todo Recheck why the costs are stored in a route
     128              :      */
     129              :     void setCosts(double costs);
     130              : 
     131              : 
     132              :     /** @brief Sets the probability of the route
     133              :      *
     134              :      * @todo Recheck why the probability is stored in a route
     135              :      */
     136              :     void setProbability(double prob);
     137              : 
     138              : 
     139              :     /** @brief Returns the number of edges in this route
     140              :      *
     141              :      * @return The number of edges the route is made of
     142              :      */
     143              :     int size() const {
     144       155796 :         return (int) myRoute.size();
     145              :     }
     146              : 
     147              : 
     148              :     /** @brief Returns the list of edges this route consists of
     149              :      *
     150              :      * @return The edges this route consists of
     151              :      */
     152              :     const ConstROEdgeVector& getEdgeVector() const {
     153       599555 :         return myRoute;
     154              :     }
     155              : 
     156              :     /** @brief Returns this route's color
     157              :      *
     158              :      * @return This route's color
     159              :      */
     160              :     const RGBColor* getColor() const {
     161        91676 :         return myColor;
     162              :     }
     163              : 
     164              : 
     165              :     /** @brief Checks whether this route contains loops and removes such
     166              :      */
     167              :     void recheckForLoops(const ConstROEdgeVector& mandatory);
     168              : 
     169              : 
     170              :     /// @brief check whether the route is valid for the given vehicle
     171              :     bool isValid(const ROVehicle& veh, bool ignoreErrors) const;
     172              : 
     173              :     OutputDevice&
     174              :     writeXMLDefinition(OutputDevice& dev, const ROVehicle* const veh,
     175              :                        const bool withCosts, const bool withProb,
     176              :                        const bool withExitTimes, const bool withLength,
     177              :                        const std::string& id = "") const;
     178              : 
     179              :     /** @brief add additional vehicles/probability
     180              :      */
     181              :     void addProbability(double prob);
     182              : 
     183              :     /** @brief Returns the list of stops this route contains
     184              :      *
     185              :      * @return list of stops
     186              :      */
     187              :     const std::vector<SUMOVehicleParameter::Stop>& getStops() const {
     188        92117 :         return myStops;
     189              :     }
     190              : 
     191              :     /** @brief Adapts the until time of all stops by the given offset
     192              :      */
     193              :     void addStopOffset(const SUMOTime offset) {
     194        25812 :         for (std::vector<SUMOVehicleParameter::Stop>::iterator stop = myStops.begin(); stop != myStops.end(); ++stop) {
     195          324 :             if (stop->until >= 0) {
     196          164 :                 stop->until += offset;
     197              :             }
     198              :         }
     199              :     }
     200              : 
     201              :     /// @brief return edges that shall be written in the route definition
     202              :     ConstROEdgeVector getNormalEdges() const;
     203              : 
     204              : private:
     205              :     /// @brief The costs of the route
     206              :     double myCosts;
     207              : 
     208              :     /// @brief The probability the driver will take this route with
     209              :     double myProbability;
     210              : 
     211              :     /// @brief The edges the route consists of
     212              :     ConstROEdgeVector myRoute;
     213              : 
     214              :     /// @brief The color of the route
     215              :     const RGBColor* myColor;
     216              : 
     217              :     /// @brief List of the stops on the parsed route
     218              :     std::vector<SUMOVehicleParameter::Stop> myStops;
     219              : 
     220              : 
     221              : private:
     222              :     /// @brief Invalidated assignment operator
     223              :     RORoute& operator=(const RORoute& src);
     224              : 
     225              : };
        

Generated by: LCOV version 2.0-1