Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/netedit/elements/GNEHierarchicalStructureParents.h
169678 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-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 GNEHierarchicalStructureParents.h
15
/// @author Pablo Alvarez Lopez
16
/// @date Feb 2025
17
///
18
// Structure for GNEHierarchicalElements centered in parents
19
/****************************************************************************/
20
#pragma once
21
#include <config.h>
22
23
#include <vector>
24
25
// ===========================================================================
26
// template declarations
27
// ===========================================================================
28
29
template <typename ParentType>
30
using GNEHierarchicalContainerParents = std::vector<ParentType>;
31
32
// ===========================================================================
33
// class declarations
34
// ===========================================================================
35
36
class GNENetworkElement;
37
class GNEJunction;
38
class GNEEdge;
39
class GNELane;
40
class GNEAdditional;
41
class GNETAZSourceSink;
42
class GNEDemandElement;
43
class GNEGenericData;
44
class GNEHierarchicalElement;
45
46
// ===========================================================================
47
// class definitions
48
// ===========================================================================
49
50
/// @brief Hierarchical structure used for keep parents
51
class GNEHierarchicalStructureParents {
52
53
public:
54
/// @brief default constructor
55
GNEHierarchicalStructureParents();
56
57
/// @brief clear container
58
void clear();
59
60
/// @brief get parents
61
template<typename ParentType>
62
const GNEHierarchicalContainerParents<ParentType>& get() const;
63
64
/// @brief get parent at the given position
65
template<typename ParentType>
66
ParentType at(const int index) const;
67
68
/**@brief add parent element
69
* @param parent new parent element to be inserted
70
* @param index position (-1 means push back)
71
*/
72
template<typename ParentType>
73
void add(ParentType parent, const int index = -1);
74
75
/// @brief remove parent element
76
template<typename ParentType>
77
void remove(ParentType parent);
78
79
/**@brief update single parent element
80
* @param index position
81
* @param parent new parent element to be updated
82
*/
83
template<typename ParentType>
84
void replaceSingle(const int index, ParentType newParent);
85
86
/// @brief update all parent element
87
template<typename ParentType>
88
void replaceAll(const GNEHierarchicalContainerParents<ParentType>& newParents);
89
90
private:
91
/// @brief parents junctions
92
GNEHierarchicalContainerParents<GNEJunction*> myParentJunctions;
93
94
/// @brief parents edges
95
GNEHierarchicalContainerParents<GNEEdge*> myParentEdges;
96
97
/// @brief parents lanes
98
GNEHierarchicalContainerParents<GNELane*> myParentLanes;
99
100
/// @brief parents additionals
101
GNEHierarchicalContainerParents<GNEAdditional*> myParentAdditionals;
102
103
/// @brief parents TAZSourceSinks (Unused, but needed for function addElementInParentsAndChildren)
104
GNEHierarchicalContainerParents<GNETAZSourceSink*> myParentTAZSourceSinks;
105
106
/// @brief parents demand elements
107
GNEHierarchicalContainerParents<GNEDemandElement*> myParentDemandElements;
108
109
/// @brief parents generic datas
110
GNEHierarchicalContainerParents<GNEGenericData*> myParentGenericDatas;
111
};
112
113