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-02 16:00:03 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 RONet;
      40              : class RORouteDef;
      41              : 
      42              : 
      43              : // ===========================================================================
      44              : // class definitions
      45              : // ===========================================================================
      46              : /**
      47              :  * @class ROVehicle
      48              :  * @brief A vehicle as used by router
      49              :  */
      50              : class ROVehicle : public RORoutable {
      51              : public:
      52              :     /** @brief Constructor
      53              :      *
      54              :      * @param[in] pars Parameter of this vehicle
      55              :      * @param[in] route The definition of the route the vehicle shall use
      56              :      * @param[in] type The type of the vehicle
      57              :      */
      58              :     ROVehicle(const SUMOVehicleParameter& pars,
      59              :               RORouteDef* route, const SUMOVTypeParameter* type,
      60              :               const RONet* net, MsgHandler* errorHandler = 0);
      61              : 
      62              : 
      63              :     /// @brief Destructor
      64              :     virtual ~ROVehicle();
      65              : 
      66              : 
      67              :     /** @brief Returns the definition of the route the vehicle takes
      68              :      *
      69              :      * @return The vehicle's route definition
      70              :      *
      71              :      * @todo Why not return a reference?
      72              :      */
      73              :     inline RORouteDef* getRouteDefinition() const {
      74       614663 :         return myRoute;
      75              :     }
      76              : 
      77              : 
      78              :     /** @brief Returns the first edge the vehicle takes
      79              :      *
      80              :      * @return The vehicle's departure edge
      81              :      */
      82              :     const ROEdge* getDepartEdge() const;
      83              : 
      84              : 
      85              :     void computeRoute(const RORouterProvider& provider,
      86              :                       const bool removeLoops, MsgHandler* errorHandler);
      87              : 
      88              :     /** @brief Returns the time the vehicle starts at, 0 for triggered vehicles
      89              :      *
      90              :      * @return The vehicle's depart time
      91              :      */
      92              :     inline SUMOTime getDepartureTime() const {
      93      1167227 :         return MAX2(SUMOTime(0), getParameter().depart);
      94              :     }
      95              : 
      96              : 
      97              :     /// @brief information for mandatory edges
      98              :     struct Mandatory {
      99       613066 :         Mandatory(const ROEdge* e, double p, SUMOTime jump = -1):
     100       613066 :             edge(e),
     101       613066 :             pos(p),
     102       613058 :             isJump(jump >= 0) {}
     103              : 
     104              :         const ROEdge* edge;
     105              :         double pos;
     106              :         bool isJump;
     107              :     };
     108              : 
     109              :     std::vector<Mandatory> getMandatoryEdges(const ROEdge* requiredStart, const ROEdge* requiredEnd) const;
     110              : 
     111              :     /** @brief Returns the vehicle's type definition
     112              :      * @return The vehicle's type definition
     113              :      */
     114              :     inline const SUMOVTypeParameter& getVTypeParameter() const  {
     115              :         return *getType();
     116              :     }
     117              : 
     118              :     /// @brief Returns the vehicle's length
     119              :     inline double getLength() const {
     120         1950 :         return getType()->length;
     121              :     }
     122              : 
     123              :     inline bool hasJumps() const {
     124       464262 :         return myJumpTime >= 0;
     125              :     }
     126              : 
     127              :     inline SUMOTime getJumpTime() const {
     128              :         return myJumpTime;
     129              :     }
     130              : 
     131              :     /** @brief Saves the complete vehicle description.
     132              :      *
     133              :      * Saves the vehicle itself including the route and stops.
     134              :      *
     135              :      * @param[in] os The routes or alternatives output device to store the vehicle's description into
     136              :      * @param[in] typeos The types - output device to store types into
     137              :      * @param[in] asAlternatives Whether the route shall be saved as route alternatives
     138              :      * @param[in] options to find out about defaults and whether exit times for the edges shall be written
     139              :      * @exception IOError If something fails (not yet implemented)
     140              :      */
     141              :     void saveAsXML(OutputDevice& os, OutputDevice* const typeos, bool asAlternatives, OptionsCont& options, int cloneIndex = 0) const;
     142              : 
     143              : 
     144              : private:
     145              :     /** @brief Adds a stop to this vehicle
     146              :      *
     147              :      * @param[in] stopPar the stop paramters
     148              :      * @param[in] net     pointer to the network, used for edge retrieval
     149              :      */
     150              :     void addStop(const SUMOVehicleParameter::Stop& stopPar,
     151              :                  const RONet* net, MsgHandler* errorHandler);
     152              : 
     153              : private:
     154              :     /// @brief The route the vehicle takes
     155              :     RORouteDef* const myRoute;
     156              : 
     157              :     /// @brief Whether this vehicle has any jumps defined
     158              :     SUMOTime myJumpTime;
     159              : 
     160              :     /// @brief map of all routes that were already saved with a name
     161              :     static std::map<ConstROEdgeVector, std::string> mySavedRoutes;
     162              : 
     163              : private:
     164              :     /// @brief Invalidated copy constructor
     165              :     ROVehicle(const ROVehicle& src);
     166              : 
     167              :     /// @brief Invalidated assignment operator
     168              :     ROVehicle& operator=(const ROVehicle& src);
     169              : 
     170              : };
        

Generated by: LCOV version 2.0-1