/****************************************************************************/1// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo2// Copyright (C) 2001-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 NBDistrictCont.h14/// @author Daniel Krajzewicz15/// @author Michael Behrisch16/// @date Sept 200217///18// A container for districts19/****************************************************************************/20#pragma once21#include <config.h>2223#include <map>24#include <string>252627// ===========================================================================28// class declarations29// ===========================================================================30class NBDistrict;31class NBEdge;32class NBNodeCont;33class OutputDevice;343536// ===========================================================================37// class definitions38// ===========================================================================39/**40* @class NBDistrictCont41* @brief A container for districts42*43* A simple storage for district instances. Allows addition an retrieval of44* districts, filling them with sources/sinks, and some other methods which45* operate at all stored districts.46*47* @see NBDistrict48*/49class NBDistrictCont {50public:51/// @brief Constructor52NBDistrictCont();535455/// @brief Destructor56~NBDistrictCont();575859/** @brief Adds a district to the dictionary60*61* @param[in] district The district to add62* @return false if the districts already was in the dictionary63*/64bool insert(NBDistrict* const district);656667/** @brief Returns the districts with the given id68*69* @param[in] id The id of the district to retrieve70* @return The district with the given id if there was one having it, 0 otherwise71*/72NBDistrict* retrieve(const std::string& id) const;737475/** @brief Returns the pointer to the begin of the stored districts76* @return The iterator to the beginning of stored edges77*/78std::map<std::string, NBDistrict*>::const_iterator begin() const {79return myDistricts.begin();80}818283/** @brief Returns the pointer to the end of the stored districts84* @return The iterator to the end of stored edges85*/86std::map<std::string, NBDistrict*>::const_iterator end() const {87return myDistricts.end();88}899091/** @brief Returns the number of districts inside the container */92int size() const;939495/** @brief Adds a source to the named district96*97* At first, the district is tried to be retrieved. If this fails, false is98* returned. Otherwise the retrieved districts NBDistrict::addSource-method99* is called.100*101* @see NBDistrict::addSource102* @param[in] dist The id of the district to add the source to103* @param[in] source An edge that shall be used as source104* @param[in] weight An optional weight of the source105* @return Whether the source could be added (the district exists and the suorce was not added to it before)106*/107bool addSource(const std::string& dist, NBEdge* const source,108double weight);109110111/** @brief Adds a sink to the named district112*113* At first, the district is tried to be retrieved. If this fails, false is114* returned. Otherwise the retrieved districts NBDistrict::addSink-method115* is called.116*117* @see NBDistrict::addSink118* @param[in] dist The id of the district to add the sink to119* @param[in] source An edge that shall be used as sink120* @param[in] weight An optional weight of the source121* @return Whether the source could be added (the district exists and the suorce was not added to it before)122*/123bool addSink(const std::string& dist, NBEdge* const destination,124double weight);125126127/** @brief Removes the given edge from the lists of sources and sinks in all stored districts128*129* This method simply goes through all stored districts and calls their method130* NBDistrict::removeFromSinksAndSources.131*132* @see NBDistrict::removeFromSinksAndSources133* @param[in] e The edge to remove from sinks/sources134*/135void removeFromSinksAndSources(NBEdge* const e);136137138private:139/// @brief The type of the dictionary where a node may be found by her id140typedef std::map<std::string, NBDistrict*> DistrictCont;141142/// @brief The instance of the dictionary143DistrictCont myDistricts;144145146private:147/** invalid copy constructor */148NBDistrictCont(const NBDistrictCont& s);149150/** invalid assignment operator */151NBDistrictCont& operator=(const NBDistrictCont& s);152153154};155156157