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

Generated by: LCOV version 2.0-1