Line data Source code
1 : /****************************************************************************/
2 : // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 : // Copyright (C) 2002-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 NIVissimClosures.cpp
15 : /// @author Daniel Krajzewicz
16 : /// @author Michael Behrisch
17 : /// @date Sept 2002
18 : ///
19 : // -------------------
20 : /****************************************************************************/
21 : #include <config.h>
22 :
23 : #include <string>
24 : #include <utils/common/VectorHelper.h>
25 : #include "NIVissimClosures.h"
26 :
27 :
28 : NIVissimClosures::DictType NIVissimClosures::myDict;
29 :
30 0 : NIVissimClosures::NIVissimClosures(const std::string& id,
31 : int from_node, int to_node,
32 0 : std::vector<int>& overEdges)
33 0 : : myID(id), myFromNode(from_node), myToNode(to_node),
34 0 : myOverEdges(overEdges) {}
35 :
36 :
37 0 : NIVissimClosures::~NIVissimClosures() {}
38 :
39 :
40 : bool
41 0 : NIVissimClosures::dictionary(const std::string& id,
42 : int from_node, int to_node,
43 : std::vector<int>& overEdges) {
44 : NIVissimClosures* o = new NIVissimClosures(id, from_node, to_node,
45 0 : overEdges);
46 0 : if (!dictionary(id, o)) {
47 0 : delete o;
48 0 : return false;
49 : }
50 : return true;
51 : }
52 :
53 :
54 : bool
55 0 : NIVissimClosures::dictionary(const std::string& name, NIVissimClosures* o) {
56 : DictType::iterator i = myDict.find(name);
57 0 : if (i == myDict.end()) {
58 0 : myDict[name] = o;
59 0 : return true;
60 : }
61 : return false;
62 : }
63 :
64 :
65 : NIVissimClosures*
66 0 : NIVissimClosures::dictionary(const std::string& name) {
67 : DictType::iterator i = myDict.find(name);
68 0 : if (i == myDict.end()) {
69 : return nullptr;
70 : }
71 0 : return (*i).second;
72 : }
73 :
74 :
75 :
76 : void
77 9 : NIVissimClosures::clearDict() {
78 9 : for (DictType::iterator i = myDict.begin(); i != myDict.end(); i++) {
79 0 : delete (*i).second;
80 : }
81 : myDict.clear();
82 9 : }
83 :
84 :
85 : /****************************************************************************/
|