LCOV - code coverage report
Current view: top level - src/router - ROLoader.h (source / functions) Hit Total Coverage
Test: lcov.info Lines: 4 4 100.0 %
Date: 2024-05-07 15:28:01 Functions: 0 4 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    ROLoader.h
      15             : /// @author  Daniel Krajzewicz
      16             : /// @author  Christian Roessel
      17             : /// @author  Michael Behrisch
      18             : /// @author  Jakob Erdmann
      19             : /// @date    Sept 2002
      20             : ///
      21             : // Loader for networks and route imports
      22             : /****************************************************************************/
      23             : #pragma once
      24             : #include <config.h>
      25             : 
      26             : #include <utils/common/SUMOTime.h>
      27             : #include <utils/common/ValueTimeLine.h>
      28             : #include <utils/vehicle/SUMORouteLoaderControl.h>
      29             : #include <utils/xml/SAXWeightsHandler.h>
      30             : #include "RORoutable.h"
      31             : 
      32             : 
      33             : // ===========================================================================
      34             : // class declarations
      35             : // ===========================================================================
      36             : class OptionsCont;
      37             : class ROAbstractEdgeBuilder;
      38             : class RONet;
      39             : class ROVehicle;
      40             : 
      41             : 
      42             : // ===========================================================================
      43             : // class definitions
      44             : // ===========================================================================
      45             : /**
      46             :  * @class ROLoader
      47             :  * @brief The data loader.
      48             :  *
      49             :  * Loads the network and route descriptions using further classes.
      50             :  *
      51             :  * Is capable to either load all routes in one step or go through them step wise.
      52             :  */
      53             : class ROLoader {
      54             : public:
      55             :     /** @brief Constructor
      56             :      *
      57             :      * @param[in] oc The options to use
      58             :      * @param[in] emptyDestinationsAllowed Whether trips may be given without destinations
      59             :      * @todo Recheck usage of emptyDestinationsAllowed
      60             :      */
      61             :     ROLoader(OptionsCont& oc, const bool emptyDestinationsAllowed, const bool logSteps);
      62             : 
      63             : 
      64             :     /// @brief Destructor
      65             :     virtual ~ROLoader();
      66             : 
      67             :     /// Loads the network
      68             :     virtual void loadNet(RONet& toFill, ROAbstractEdgeBuilder& eb);
      69             : 
      70             :     /// Loads the net weights
      71             :     bool loadWeights(RONet& net, const std::string& optionName,
      72             :                      const std::string& measure, const bool useLanes, const bool boundariesOverride);
      73             : 
      74             :     /** @brief Builds and opens all route loaders */
      75             :     void openRoutes(RONet& net);
      76             : 
      77             :     /** @brief Loads routes from all previously build route loaders */
      78             :     void processRoutes(const SUMOTime start, const SUMOTime end, const SUMOTime increment,
      79             :                        RONet& net, const RORouterProvider& provider);
      80             : 
      81             : protected:
      82             :     /** @brief Opens route handler of the given type
      83             :      *
      84             :      * Checks whether the given option name is known, returns true if
      85             :      *  not (this means that everything's ok, though the according
      86             :      *  handler is not built).
      87             :      *
      88             :      * Checks then whether the given option name is set and his value is one
      89             :      *  or a set of valid (existing) files. This is done via a call to
      90             :      *  "OptionsCont::isUsableFileList" (which generates a proper error
      91             :      *  message).
      92             :      *
      93             :      * If the given files are valid, the proper instance(s) is built using
      94             :      *  "buildNamedHandler" and if this could be done, it is added to
      95             :      *  the list of route handlers to use ("myHandler")
      96             :      *
      97             :      * Returns whether the wished handler(s) could be built.
      98             :      *
      99             :      * @param[in] optionName The name of the option that refers to which handler and which files shall be used
     100             :      * @param[in] net The net to assign to the built handlers
     101             :      * @return Whether the wished handler(s) could be built
     102             :      */
     103             :     bool openTypedRoutes(const std::string& optionName, RONet& net, const bool readAll = false);
     104             : 
     105             : 
     106             :     /**
     107             :      * @class EdgeFloatTimeLineRetriever_EdgeWeight
     108             :      * @brief Obtains edge weights from a weights handler and stores them within the edges
     109             :      * @see SAXWeightsHandler::EdgeFloatTimeLineRetriever
     110             :      */
     111             :     class EdgeFloatTimeLineRetriever_EdgeWeight : public SAXWeightsHandler::EdgeFloatTimeLineRetriever {
     112             :     public:
     113             :         /// @brief Constructor
     114         726 :         EdgeFloatTimeLineRetriever_EdgeWeight(RONet& net) : myNet(net) {}
     115             : 
     116             :         /// @brief Destructor
     117         726 :         ~EdgeFloatTimeLineRetriever_EdgeWeight() { }
     118             : 
     119             :         /** @brief Adds an effort for a given edge and time period
     120             :          *
     121             :          * @param[in] id The id of the object to add a weight for
     122             :          * @param[in] val The weight
     123             :          * @param[in] beg The begin of the interval the weight is valid for
     124             :          * @param[in] end The end of the interval the weight is valid for
     125             :          * @see SAXWeightsHandler::EdgeFloatTimeLineRetriever::addEdgeWeight
     126             :          */
     127             :         void addEdgeWeight(const std::string& id,
     128             :                            double val, double beg, double end) const;
     129             : 
     130             :     private:
     131             :         /// @brief The network edges shall be obtained from
     132             :         RONet& myNet;
     133             : 
     134             :     };
     135             : 
     136             : 
     137             :     /**
     138             :      * @class EdgeFloatTimeLineRetriever_EdgeTravelTime
     139             :      * @brief Obtains edge travel times from a weights handler and stores them within the edges
     140             :      * @see SAXWeightsHandler::EdgeFloatTimeLineRetriever
     141             :      */
     142             :     class EdgeFloatTimeLineRetriever_EdgeTravelTime : public SAXWeightsHandler::EdgeFloatTimeLineRetriever {
     143             :     public:
     144             :         /// @brief Constructor
     145         726 :         EdgeFloatTimeLineRetriever_EdgeTravelTime(RONet& net) : myNet(net) {}
     146             : 
     147             :         /// @brief Destructor
     148         726 :         ~EdgeFloatTimeLineRetriever_EdgeTravelTime() {}
     149             : 
     150             :         /** @brief Adds a travel time for a given edge and time period
     151             :          *
     152             :          * @param[in] id The id of the object to add a weight for
     153             :          * @param[in] val The travel time
     154             :          * @param[in] beg The begin of the interval the weight is valid for
     155             :          * @param[in] end The end of the interval the weight is valid for
     156             :          * @see SAXWeightsHandler::EdgeFloatTimeLineRetriever::addEdgeWeight
     157             :          */
     158             :         void addEdgeWeight(const std::string& id,
     159             :                            double val, double beg, double end) const;
     160             : 
     161             :     private:
     162             :         /// @brief The network edges shall be obtained from
     163             :         RONet& myNet;
     164             : 
     165             :     };
     166             : 
     167             : 
     168             : 
     169             : protected:
     170             :     void writeStats(const SUMOTime time, const SUMOTime start, const SUMOTime absNo, bool endGiven);
     171             : 
     172             : 
     173             : private:
     174             :     /// @brief Options to use
     175             :     OptionsCont& myOptions;
     176             : 
     177             :     /// @brief Information whether empty destinations are allowed
     178             :     const bool myEmptyDestinationsAllowed;
     179             : 
     180             :     /// @brief Information whether the routing steps should be logged
     181             :     const bool myLogSteps;
     182             : 
     183             :     /// @brief List of route loaders
     184             :     SUMORouteLoaderControl myLoaders;
     185             : 
     186             : 
     187             : private:
     188             :     /// @brief Invalidated copy constructor
     189             :     ROLoader(const ROLoader& src);
     190             : 
     191             :     /// @brief Invalidated assignment operator
     192             :     ROLoader& operator=(const ROLoader& src);
     193             : };

Generated by: LCOV version 1.14