/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2002-2025 German Aerospace Center (DLR) and others.3// This program and the accompanying materials are made available under the4// terms of the Eclipse Public License 2.0 which is available at5// https://www.eclipse.org/legal/epl-2.0/6// This Source Code may also be made available under the following Secondary7// Licenses when the conditions for such availability set forth in the Eclipse8// Public License 2.0 are satisfied: GNU General Public License, version 29// or later which is available at10// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html11// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later12/****************************************************************************/13/// @file ROLoader.h14/// @author Daniel Krajzewicz15/// @author Christian Roessel16/// @author Michael Behrisch17/// @author Jakob Erdmann18/// @date Sept 200219///20// Loader for networks and route imports21/****************************************************************************/22#pragma once23#include <config.h>2425#include <utils/common/SUMOTime.h>26#include <utils/common/ValueTimeLine.h>27#include <utils/vehicle/SUMORouteLoaderControl.h>28#include <utils/xml/SAXWeightsHandler.h>29#include "RORoutable.h"303132// ===========================================================================33// class declarations34// ===========================================================================35class OptionsCont;36class ROAbstractEdgeBuilder;37class RONet;38class ROVehicle;39class SUMORouteHandler;404142// ===========================================================================43// class definitions44// ===========================================================================45/**46* @class ROLoader47* @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*/53class ROLoader {54public:55/** @brief Constructor56*57* @param[in] oc The options to use58* @param[in] emptyDestinationsAllowed Whether trips may be given without destinations59* @todo Recheck usage of emptyDestinationsAllowed60*/61ROLoader(OptionsCont& oc, const bool emptyDestinationsAllowed, const bool logSteps);626364/// @brief Destructor65virtual ~ROLoader();6667/// Loads the network68virtual void loadNet(RONet& toFill, ROAbstractEdgeBuilder& eb);6970/// Loads the net weights71bool loadWeights(RONet& net, const std::string& optionName,72const std::string& measure, const bool useLanes, const bool boundariesOverride);7374/** @brief Builds and opens all route loaders */75void openRoutes(RONet& net);7677/** @brief Loads routes from all previously build route loaders */78void processRoutes(const SUMOTime start, const SUMOTime end, const SUMOTime increment,79RONet& net, const RORouterProvider& provider);8081SUMORouteHandler* getRouteHandler();8283protected:84/** @brief Opens route handler of the given type85*86* Checks whether the given option name is known, returns true if87* not (this means that everything's ok, though the according88* handler is not built).89*90* Checks then whether the given option name is set and his value is one91* or a set of valid (existing) files. This is done via a call to92* "OptionsCont::isUsableFileList" (which generates a proper error93* message).94*95* If the given files are valid, the proper instance(s) is built using96* "buildNamedHandler" and if this could be done, it is added to97* the list of route handlers to use ("myHandler")98*99* Returns whether the wished handler(s) could be built.100*101* @param[in] optionName The name of the option that refers to which handler and which files shall be used102* @param[in] net The net to assign to the built handlers103* @return Whether the wished handler(s) could be built104*/105bool openTypedRoutes(const std::string& optionName, RONet& net, const bool readAll = false);106107108/**109* @class EdgeFloatTimeLineRetriever_EdgeWeight110* @brief Obtains edge weights from a weights handler and stores them within the edges111* @see SAXWeightsHandler::EdgeFloatTimeLineRetriever112*/113class EdgeFloatTimeLineRetriever_EdgeWeight : public SAXWeightsHandler::EdgeFloatTimeLineRetriever {114public:115/// @brief Constructor116EdgeFloatTimeLineRetriever_EdgeWeight(RONet& net) : myNet(net) {}117118/// @brief Destructor119~EdgeFloatTimeLineRetriever_EdgeWeight() { }120121/** @brief Adds an effort for a given edge and time period122*123* @param[in] id The id of the object to add a weight for124* @param[in] val The weight125* @param[in] beg The begin of the interval the weight is valid for126* @param[in] end The end of the interval the weight is valid for127* @see SAXWeightsHandler::EdgeFloatTimeLineRetriever::addEdgeWeight128*/129void addEdgeWeight(const std::string& id,130double val, double beg, double end) const;131132private:133/// @brief The network edges shall be obtained from134RONet& myNet;135136};137138139/**140* @class EdgeFloatTimeLineRetriever_EdgeTravelTime141* @brief Obtains edge travel times from a weights handler and stores them within the edges142* @see SAXWeightsHandler::EdgeFloatTimeLineRetriever143*/144class EdgeFloatTimeLineRetriever_EdgeTravelTime : public SAXWeightsHandler::EdgeFloatTimeLineRetriever {145public:146/// @brief Constructor147EdgeFloatTimeLineRetriever_EdgeTravelTime(RONet& net) : myNet(net) {}148149/// @brief Destructor150~EdgeFloatTimeLineRetriever_EdgeTravelTime() {}151152/** @brief Adds a travel time for a given edge and time period153*154* @param[in] id The id of the object to add a weight for155* @param[in] val The travel time156* @param[in] beg The begin of the interval the weight is valid for157* @param[in] end The end of the interval the weight is valid for158* @see SAXWeightsHandler::EdgeFloatTimeLineRetriever::addEdgeWeight159*/160void addEdgeWeight(const std::string& id,161double val, double beg, double end) const;162163private:164/// @brief The network edges shall be obtained from165RONet& myNet;166167};168169170171protected:172void writeStats(const SUMOTime time, const SUMOTime start, const SUMOTime absNo, bool endGiven);173174175private:176/// @brief Options to use177OptionsCont& myOptions;178179/// @brief Information whether empty destinations are allowed180const bool myEmptyDestinationsAllowed;181182/// @brief Information whether the routing steps should be logged183const bool myLogSteps;184185/// @brief List of route loaders186SUMORouteLoaderControl myLoaders;187188189private:190/// @brief Invalidated copy constructor191ROLoader(const ROLoader& src);192193/// @brief Invalidated assignment operator194ROLoader& operator=(const ROLoader& src);195};196197198