LCOV - code coverage report
Current view: top level - src/utils/router - RouterProvider.h (source / functions) Coverage Total Hit
Test: lcov.info Lines: 96.9 % 32 31
Test Date: 2024-11-22 15:46:21 Functions: 87.5 % 8 7

            Line data    Source code
       1              : /****************************************************************************/
       2              : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
       3              : // Copyright (C) 2001-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    RouterProvider.h
      15              : /// @author  Jakob Erdmann
      16              : /// @author  Michael Behrisch
      17              : /// @date    Mon, 03 March 2014
      18              : ///
      19              : // The RouterProvider provides car, pedestrian and intermodal routing in one object
      20              : /****************************************************************************/
      21              : #pragma once
      22              : #include <config.h>
      23              : 
      24              : #include "IntermodalRouter.h"
      25              : #include "RailwayRouter.h"
      26              : 
      27              : 
      28              : // ===========================================================================
      29              : // class definitions
      30              : // ===========================================================================
      31              : /**
      32              :  * @class RouterProvider
      33              :  * The encapsulation of the routers for vehicles and pedestrians
      34              :  */
      35              : template<class E, class L, class N, class V>
      36              : class RouterProvider {
      37              : public:
      38        14021 :     RouterProvider(SUMOAbstractRouter<E, V>* vehRouter,
      39              :                    PedestrianRouter<E, L, N, V>* pedRouter,
      40              :                    IntermodalRouter<E, L, N, V>* interRouter,
      41              :                    RailwayRouter<E, V>* railRouter) :
      42        14021 :         myVehRouter(vehRouter),
      43        14021 :         myPedRouter(pedRouter),
      44        14021 :         myInterRouter(interRouter),
      45        14021 :         myRailRouter(railRouter)
      46              :     {}
      47              : 
      48         2371 :     RouterProvider(const RouterProvider& original) :
      49         4742 :         myVehRouter(original.myVehRouter->clone()),
      50         2371 :         myPedRouter(static_cast<PedestrianRouter<E, L, N, V>*>(original.myPedRouter == nullptr ? nullptr : original.myPedRouter->clone())),
      51         2371 :         myInterRouter(static_cast<IntermodalRouter<E, L, N, V>*>(original.myInterRouter == nullptr ? nullptr : original.myInterRouter->clone())),
      52         4742 :         myRailRouter(static_cast<RailwayRouter<E, V>*>(original.myRailRouter == nullptr ? nullptr : original.myRailRouter->clone()))
      53         2371 :     {}
      54              : 
      55        26573 :     virtual ~RouterProvider() {
      56        16391 :         delete myVehRouter;
      57        16391 :         delete myPedRouter;
      58        16391 :         delete myInterRouter;
      59        16391 :         delete myRailRouter;
      60        26573 :     }
      61              : 
      62         2320 :     RouterProvider* clone() {
      63         2320 :         return new RouterProvider(*this);
      64              :     }
      65              : 
      66              :     SUMOAbstractRouter<E, V>& getVehicleRouter(SUMOVehicleClass svc) const {
      67      3425670 :         if (myRailRouter == nullptr || !isRailway(svc)) {
      68      3412391 :             return *myVehRouter;
      69              :         } else {
      70        13279 :             return *myRailRouter;
      71              :         }
      72              :     }
      73              : 
      74              :     PedestrianRouter<E, L, N, V>& getPedestrianRouter() const {
      75              :         return *myPedRouter;
      76              :     }
      77              : 
      78              :     IntermodalRouter<E, L, N, V>& getIntermodalRouter() const {
      79         7428 :         return *myInterRouter;
      80              :     }
      81              : 
      82              :     RailwayRouter<E, V>& getRailwayRouter() const {
      83              :         return *myRailRouter;
      84              :     }
      85              : 
      86          348 :     inline void setBulkMode(const bool mode) const {
      87          348 :         myVehRouter->setBulkMode(mode);
      88          348 :         if (myPedRouter != nullptr) {
      89          288 :             myPedRouter->setBulkMode(mode);
      90              :         }
      91          348 :         if (myInterRouter != nullptr) {
      92          288 :             myInterRouter->setBulkMode(mode);
      93              :         }
      94          348 :         if (myRailRouter != nullptr) {
      95            0 :             myRailRouter->setBulkMode(mode);
      96              :         }
      97          348 :     }
      98              : 
      99              : 
     100              : private:
     101              :     SUMOAbstractRouter<E, V>* const myVehRouter;
     102              :     PedestrianRouter<E, L, N, V>* const myPedRouter;
     103              :     IntermodalRouter<E, L, N, V>* const myInterRouter;
     104              :     RailwayRouter<E, V>* const myRailRouter;
     105              : 
     106              : 
     107              : private:
     108              :     /// @brief Invalidated assignment operator
     109              :     RouterProvider& operator=(const RouterProvider& src);
     110              : 
     111              : };
        

Generated by: LCOV version 2.0-1