Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/od/ODDistrictCont.h
169668 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2002-2025 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 ODDistrictCont.h
15
/// @author Daniel Krajzewicz
16
/// @author Yun-Pang Floetteroed
17
/// @author Michael Behrisch
18
/// @date Sept 2002
19
///
20
// A container for districts
21
/****************************************************************************/
22
#pragma once
23
#include <config.h>
24
25
#include "ODDistrict.h"
26
#include <utils/common/NamedObjectCont.h>
27
28
29
// ===========================================================================
30
// class definitions
31
// ===========================================================================
32
/**
33
* @class ODDistrictCont
34
* @brief A container for districts
35
*
36
* Besides the inherited methods for adding/removing districts, this container
37
* allows to retrieve a random source or sink from a named district.
38
*/
39
class ODDistrictCont : public NamedObjectCont<ODDistrict*> {
40
public:
41
/// Constructor
42
ODDistrictCont();
43
44
45
/// Destructor
46
~ODDistrictCont();
47
48
49
/** @brief Returns the id of a random source from the named district
50
*
51
* At first, the named district is retrieved. If this fails, an
52
* InvalidArgument-exception is thrown. Otherwise, a source (edge)
53
* is chosen randomly from this district using this district's
54
* getRandomSource-method which throws an OutOfBoundsException-exception
55
* if this district does not contain a source.
56
*
57
* @param[in] name The id of the district to get a random source from
58
* @return The id of a randomly chosen source
59
* @exception InvalidArgument If the named district is not known
60
* @exception OutOfBoundsException If the named district has no sources
61
* @see ODDistrict::getRandomSource
62
*/
63
std::string getRandomSourceFromDistrict(const std::string& name) const;
64
65
66
/** @brief Returns the id of a random sink from the named district
67
*
68
* At first, the named district is retrieved. If this fails, an
69
* InvalidArgument-exception is thrown. Otherwise, a sink (edge)
70
* is chosen randomly from this district using this district's
71
* getRandomSink-method which throws an OutOfBoundsException-exception
72
* if this district does not contain a sink.
73
*
74
* @param[in] name The id of the district to get a random sink from
75
* @return The id of a randomly chosen sink
76
* @exception InvalidArgument If the named district is not known
77
* @exception OutOfBoundsException If the named district has no sinks
78
* @see ODDistrict::getRandomSink
79
*/
80
std::string getRandomSinkFromDistrict(const std::string& name) const;
81
82
/// @brief load districts from files
83
void loadDistricts(std::vector<std::string> files);
84
85
/// @brief create districts from description
86
void makeDistricts(const std::map<std::string, std::pair<std::vector<std::string>, std::vector<std::string> > >& districts);
87
88
private:
89
/// @brief invalidated copy constructor
90
ODDistrictCont(const ODDistrictCont& s);
91
92
/// @brief invalidated assignment operator
93
ODDistrictCont& operator=(const ODDistrictCont& s);
94
95
96
};
97
98