LCOV - code coverage report
Current view: top level - src/router - ROVehicle.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 100.0 % 8 8
Test Date: 2026-03-26 16:31:35 Functions: - 0 0

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2002-2026 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    ROVehicle.h
      15              : /// @author  Daniel Krajzewicz
      16              : /// @author  Michael Behrisch
      17              : /// @author  Jakob Erdmann
      18              : /// @date    Sept 2002
      19              : ///
      20              : // A vehicle as used by router
      21              : /****************************************************************************/
      22              : #pragma once
      23              : #include <config.h>
      24              : 
      25              : #include <string>
      26              : #include <iostream>
      27              : #include <utils/common/StdDefs.h>
      28              : #include <utils/common/SUMOTime.h>
      29              : #include <utils/vehicle/SUMOVehicleParameter.h>
      30              : #include <utils/vehicle/SUMOVTypeParameter.h>
      31              : #include "RORoutable.h"
      32              : 
      33              : 
      34              : // ===========================================================================
      35              : // class declarations
      36              : // ===========================================================================
      37              : class OutputDevice;
      38              : class ROEdge;
      39              : class RORoute;
      40              : class RONet;
      41              : class RORouteDef;
      42              : 
      43              : 
      44              : // ===========================================================================
      45              : // class definitions
      46              : // ===========================================================================
      47              : /**
      48              :  * @class ROVehicle
      49              :  * @brief A vehicle as used by router
      50              :  */
      51              : class ROVehicle : public RORoutable {
      52              : public:
      53              :     /** @brief Constructor
      54              :      *
      55              :      * @param[in] pars Parameter of this vehicle
      56              :      * @param[in] route The definition of the route the vehicle shall use
      57              :      * @param[in] type The type of the vehicle
      58              :      */
      59              :     ROVehicle(const SUMOVehicleParameter& pars,
      60              :               RORouteDef* route, const SUMOVTypeParameter* type,
      61              :               const RONet* net, MsgHandler* errorHandler = 0);
      62              : 
      63              : 
      64              :     /// @brief Destructor
      65              :     virtual ~ROVehicle();
      66              : 
      67              : 
      68              :     /** @brief Returns the definition of the route the vehicle takes
      69              :      *
      70              :      * @return The vehicle's route definition
      71              :      *
      72              :      * @todo Why not return a reference?
      73              :      */
      74              :     inline RORouteDef* getRouteDefinition() const {
      75       614725 :         return myRoute;
      76              :     }
      77              : 
      78              : 
      79              :     /** @brief Returns the first edge the vehicle takes
      80              :      *
      81              :      * @return The vehicle's departure edge
      82              :      */
      83              :     const ROEdge* getDepartEdge() const;
      84              : 
      85              : 
      86              :     void computeRoute(const RORouterProvider& provider,
      87              :                       const bool removeLoops, MsgHandler* errorHandler);
      88              : 
      89              :     /** @brief Returns the time the vehicle starts at, 0 for triggered vehicles
      90              :      *
      91              :      * @return The vehicle's depart time
      92              :      */
      93              :     inline SUMOTime getDepartureTime() const {
      94      1167295 :         return MAX2(SUMOTime(0), getParameter().depart);
      95              :     }
      96              : 
      97              : 
      98              :     /// @brief information for mandatory edges
      99              :     struct Mandatory {
     100       613124 :         Mandatory(const ROEdge* e, double p, SUMOTime jump = -1):
     101       613124 :             edge(e),
     102       613124 :             pos(p),
     103       613116 :             isJump(jump >= 0) {}
     104              : 
     105              :         const ROEdge* edge;
     106              :         double pos;
     107              :         bool isJump;
     108              :     };
     109              : 
     110              :     std::vector<Mandatory> getMandatoryEdges(const ROEdge* requiredStart, const ROEdge* requiredEnd) const;
     111              : 
     112              :     /** @brief Returns the vehicle's type definition
     113              :      * @return The vehicle's type definition
     114              :      */
     115              :     inline const SUMOVTypeParameter& getVTypeParameter() const  {
     116              :         return *getType();
     117              :     }
     118              : 
     119              :     /// @brief Returns the vehicle's length
     120              :     inline double getLength() const {
     121         1950 :         return getType()->length;
     122              :     }
     123              : 
     124              :     inline bool hasJumps() const {
     125       464282 :         return myJumpTime >= 0;
     126              :     }
     127              : 
     128              :     inline SUMOTime getJumpTime() const {
     129              :         return myJumpTime;
     130              :     }
     131              : 
     132              :     /** @brief Saves the complete vehicle description.
     133              :      *
     134              :      * Saves the vehicle itself including the route and stops.
     135              :      *
     136              :      * @param[in] os The routes or alternatives output device to store the vehicle's description into
     137              :      * @param[in] typeos The types - output device to store types into
     138              :      * @param[in] asAlternatives Whether the route shall be saved as route alternatives
     139              :      * @param[in] options to find out about defaults and whether exit times for the edges shall be written
     140              :      * @exception IOError If something fails (not yet implemented)
     141              :      */
     142              :     void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const;
     143              : 
     144              : 
     145              : private:
     146              :     /** @brief Adds a stop to this vehicle
     147              :      *
     148              :      * @param[in] stopPar the stop paramters
     149              :      * @param[in] net     pointer to the network, used for edge retrieval
     150              :      */
     151              :     void addStop(const SUMOVehicleParameter::Stop& stopPar,
     152              :                  const RONet* net, MsgHandler* errorHandler);
     153              : 
     154              :     /// @brief update departEdge / arrivalEdge
     155              :     void updateIndex(const RORoute* replaced, const RORoute* current, int& attr);
     156              : 
     157              : private:
     158              :     /// @brief The route the vehicle takes
     159              :     RORouteDef* const myRoute;
     160              : 
     161              :     /// @brief Whether this vehicle has any jumps defined
     162              :     SUMOTime myJumpTime;
     163              : 
     164              :     /// @brief map of all routes that were already saved with a name
     165              :     static std::map<ConstROEdgeVector, std::string> mySavedRoutes;
     166              : 
     167              : private:
     168              :     /// @brief Invalidated copy constructor
     169              :     ROVehicle(const ROVehicle& src);
     170              : 
     171              :     /// @brief Invalidated assignment operator
     172              :     ROVehicle& operator=(const ROVehicle& src);
     173              : 
     174              : };
        

Generated by: LCOV version 2.0-1