/****************************************************************************/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 ODDistrictCont.h14/// @author Daniel Krajzewicz15/// @author Yun-Pang Floetteroed16/// @author Michael Behrisch17/// @date Sept 200218///19// A container for districts20/****************************************************************************/21#pragma once22#include <config.h>2324#include "ODDistrict.h"25#include <utils/common/NamedObjectCont.h>262728// ===========================================================================29// class definitions30// ===========================================================================31/**32* @class ODDistrictCont33* @brief A container for districts34*35* Besides the inherited methods for adding/removing districts, this container36* allows to retrieve a random source or sink from a named district.37*/38class ODDistrictCont : public NamedObjectCont<ODDistrict*> {39public:40/// Constructor41ODDistrictCont();424344/// Destructor45~ODDistrictCont();464748/** @brief Returns the id of a random source from the named district49*50* At first, the named district is retrieved. If this fails, an51* InvalidArgument-exception is thrown. Otherwise, a source (edge)52* is chosen randomly from this district using this district's53* getRandomSource-method which throws an OutOfBoundsException-exception54* if this district does not contain a source.55*56* @param[in] name The id of the district to get a random source from57* @return The id of a randomly chosen source58* @exception InvalidArgument If the named district is not known59* @exception OutOfBoundsException If the named district has no sources60* @see ODDistrict::getRandomSource61*/62std::string getRandomSourceFromDistrict(const std::string& name) const;636465/** @brief Returns the id of a random sink from the named district66*67* At first, the named district is retrieved. If this fails, an68* InvalidArgument-exception is thrown. Otherwise, a sink (edge)69* is chosen randomly from this district using this district's70* getRandomSink-method which throws an OutOfBoundsException-exception71* if this district does not contain a sink.72*73* @param[in] name The id of the district to get a random sink from74* @return The id of a randomly chosen sink75* @exception InvalidArgument If the named district is not known76* @exception OutOfBoundsException If the named district has no sinks77* @see ODDistrict::getRandomSink78*/79std::string getRandomSinkFromDistrict(const std::string& name) const;8081/// @brief load districts from files82void loadDistricts(std::vector<std::string> files);8384/// @brief create districts from description85void makeDistricts(const std::map<std::string, std::pair<std::vector<std::string>, std::vector<std::string> > >& districts);8687private:88/// @brief invalidated copy constructor89ODDistrictCont(const ODDistrictCont& s);9091/// @brief invalidated assignment operator92ODDistrictCont& operator=(const ODDistrictCont& s);939495};969798