Eclipse SUMO - Simulation of Urban MObility
GNEHierarchicalParentElements.h
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3 // Copyright (C) 2001-2020 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 /****************************************************************************/
18 // A abstract class for representation of Hierarchical Elements
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #include <netedit/GNEGeometry.h>
25 #include <utils/geom/Position.h>
26 
27 #include "GNEAttributeCarrier.h"
28 
29 // ===========================================================================
30 // class declarations
31 // ===========================================================================
32 
33 class GNENetworkElement;
34 class GNEAdditional;
35 class GNETAZElement;
36 class GNEShape;
37 class GNEDemandElement;
38 class GNEGenericData;
39 
40 // ===========================================================================
41 // class definitions
42 // ===========================================================================
43 
49 
50 public:
51 
53  friend class GNEChange_Children;
54 
67  const std::vector<GNEJunction*>& parentJunctions,
68  const std::vector<GNEEdge*>& parentEdges,
69  const std::vector<GNELane*>& parentLanes,
70  const std::vector<GNEAdditional*>& parentAdditionals,
71  const std::vector<GNEShape*>& parentShapes,
72  const std::vector<GNETAZElement*>& parentTAZElements,
73  const std::vector<GNEDemandElement*>& parentDemandElements,
74  const std::vector<GNEGenericData*>& parentGenericDatas);
75 
78 
82  virtual void updateGeometry() = 0;
83 
85  virtual Position getPositionInView() const = 0;
87 
89  template<typename T>
90  void addParentElement(T* element);
91 
93  template<typename T>
94  void removeParentElement(T* element);
95 
97  const std::vector<GNEEdge*>& getParentEdges() const;
98 
100  const std::vector<GNELane*>& getParentLanes() const;
101 
103  const std::vector<GNEAdditional*>& getParentAdditionals() const;
104 
106  const std::vector<GNEShape*>& getParentShapes() const;
107 
109  const std::vector<GNETAZElement*>& getParentTAZElements() const;
110 
112  const std::vector<GNEDemandElement*>& getParentDemandElements() const;
113 
115  const std::vector<GNEGenericData*>& getParentGenericDatas() const;
116 
119 
122 
124  void updateFirstParentJunction(GNEJunction* junction);
125 
127  void updateSecondParentJunction(GNEJunction* junction);
128 
130  std::vector<GNEEdge*> getMiddleParentEdges() const;
131 
133  std::string getNewListOfParents(const GNENetworkElement* currentElement, const GNENetworkElement* newNextElement) const;
134 
135 protected:
138 
140  void replaceParentEdges(GNEShape* elementChild, const std::string& newEdgeIDs);
141 
143  void replaceParentEdges(GNEAdditional* elementChild, const std::string& newEdgeIDs);
144 
146  void replaceParentEdges(GNEDemandElement* elementChild, const std::string& newEdgeIDs);
147 
149  void replaceParentEdges(GNEDemandElement* elementChild, const std::vector<GNEEdge*>& newEdges);
150 
152  void replaceParentEdges(GNEGenericData* elementChild, const std::vector<GNEEdge*>& newEdges);
153 
155  void replaceFirstParentEdge(GNEDemandElement* elementChild, GNEEdge* newFirstEdge);
156 
158  void replaceFirstParentEdge(GNEGenericData* elementChild, GNEEdge* newFirstEdge);
159 
161  void replaceMiddleParentEdges(GNEDemandElement* elementChild, const std::vector<GNEEdge*>& newMiddleEdges, const bool updateChildReferences);
162 
164  void replaceLastParentEdge(GNEDemandElement* elementChild, GNEEdge* newLastEdge);
165 
167  void replaceLastParentEdge(GNEGenericData* elementChild, GNEEdge* newLastEdge);
168 
170  void replaceParentLanes(GNEShape* elementChild, const std::string& newLaneIDs);
171 
173  void replaceParentLanes(GNEAdditional* elementChild, const std::string& newLaneIDs);
174 
176  void replaceParentLanes(GNEDemandElement* elementChild, const std::string& newLaneIDs);
177 
182  void replaceParentAdditional(GNEShape* shapeTobeChanged, const std::string& newParentAdditionalID, int additionalParentIndex);
183 
188  void replaceParentAdditional(GNEAdditional* additionalTobeChanged, const std::string& newParentAdditionalID, int additionalParentIndex);
189 
194  void replaceParentAdditional(GNEDemandElement* demandElementTobeChanged, const std::string& newParentAdditionalID, int additionalParentIndex);
195 
197  void replaceFirstParentTAZElement(GNEGenericData* elementChild, GNETAZElement* newFirstTAZElement);
198 
200  void replaceLastParentTAZElement(GNEGenericData* elementChild, GNETAZElement* newLastTAZElement);
201 
206  void replaceParentDemandElement(GNEShape* shapeTobeChanged, const std::string& newParentDemandElementID, int demandElementParentIndex);
207 
212  void replaceParentDemandElement(GNEAdditional* additionalTobeChanged, const std::string& newParentDemandElementID, int demandElementParentIndex);
213 
218  void replaceParentDemandElement(GNEDemandElement* demandElementTobeChanged, const std::string& newParentDemandElementID, int demandElementParentIndex);
219 
221 
224 
225 private:
227  std::vector<GNEJunction*> myParentJunctions;
228 
230  std::vector<GNEEdge*> myParentEdges;
231 
233  std::vector<GNELane*> myParentLanes;
234 
236  std::vector<GNEAdditional*> myParentAdditionals;
237 
239  std::vector<GNEShape*> myParentShapes;
240 
242  std::vector<GNETAZElement*> myParentTAZElements;
243 
245  std::vector<GNEDemandElement*> myParentDemandElements;
246 
248  std::vector<GNEGenericData*> myParentGenericDatas;
249 
252 
255 
258 };
259 
GNEGeometry::ParentConnections myParentConnections
variable ParentConnections
std::vector< GNEJunction * > myParentJunctions
vector of junction parents
void replaceFirstParentTAZElement(GNEGenericData *elementChild, GNETAZElement *newFirstTAZElement)
replace the first parent TAZElement (used by generic data elements)
std::vector< GNEAdditional * > myParentAdditionals
vector of additional parents
void replaceLastParentTAZElement(GNEGenericData *elementChild, GNETAZElement *newLastTAZElement)
replace the last parent TAZElement (used by demand elements)
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
std::string getNewListOfParents(const GNENetworkElement *currentElement, const GNENetworkElement *newNextElement) const
if use edge/parent lanes as a list of consecutive elements, obtain a list of IDs of elements after in...
An special type of Attribute carrier that owns hierarchical elements.
std::vector< GNEEdge * > myParentEdges
vector of edge parents
void updateSecondParentJunction(GNEJunction *junction)
update last parent junction
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
std::vector< GNEGenericData * > myParentGenericDatas
vector of generic datas parents
GNEJunction * getSecondParentJunction() const
remove parent junction
void updateFirstParentJunction(GNEJunction *junction)
update front parent junction
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNETAZElement.h:46
std::vector< GNELane * > myParentLanes
vector of lane parents
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
GNEJunction * getFirstParentJunction() const
get front parent junction
struct for pack all variables and functions relative to connections between hierarchical element and ...
Definition: GNEGeometry.h:448
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
std::vector< GNEDemandElement * > myParentDemandElements
vector of demand elements parents
std::vector< GNEEdge * > getMiddleParentEdges() const
get middle (via) parent edges
const GNEAttributeCarrier * myAC
pointer to AC (needed to avoid diamond problem)
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
void replaceMiddleParentEdges(GNEDemandElement *elementChild, const std::vector< GNEEdge *> &newMiddleEdges, const bool updateChildReferences)
replace middle (via) parent edges
void replaceParentAdditional(GNEShape *shapeTobeChanged, const std::string &newParentAdditionalID, int additionalParentIndex)
replace the parent additional of a shape
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
std::vector< GNEShape * > myParentShapes
vector of shape parents
GNEHierarchicalParentElements(const GNEAttributeCarrier *AC, const std::vector< GNEJunction *> &parentJunctions, const std::vector< GNEEdge *> &parentEdges, const std::vector< GNELane *> &parentLanes, const std::vector< GNEAdditional *> &parentAdditionals, const std::vector< GNEShape *> &parentShapes, const std::vector< GNETAZElement *> &parentTAZElements, const std::vector< GNEDemandElement *> &parentDemandElements, const std::vector< GNEGenericData *> &parentGenericDatas)
Constructor used by elements that have another additionals as parent.
void addParentElement(T *element)
add child
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:47
void replaceParentLanes(GNEShape *elementChild, const std::string &newLaneIDs)
replace the parent edges of a shape
const std::vector< GNEShape * > & getParentShapes() const
get parent shapes
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
Definition: GNEAdditional.h:47
GNEHierarchicalParentElements & operator=(const GNEHierarchicalParentElements &)=delete
Invalidated assignment operator.
std::vector< GNETAZElement * > myParentTAZElements
vector of TAZElement parents
void removeParentElement(T *element)
remove child
void replaceFirstParentEdge(GNEDemandElement *elementChild, GNEEdge *newFirstEdge)
replace the first parent edge (used by demand elements)
void replaceLastParentEdge(GNEDemandElement *elementChild, GNEEdge *newLastEdge)
replace the last parent edge (used by demand elements)
virtual Position getPositionInView() const =0
Returns position of hierarchical element in view.
virtual void updateGeometry()=0
const std::vector< GNEGenericData * > & getParentGenericDatas() const
get parent demand elements
void replaceParentDemandElement(GNEShape *shapeTobeChanged, const std::string &newParentDemandElementID, int demandElementParentIndex)
replace the parent demand element of a shape
An Element which don&#39;t belongs to GNENet but has influency in the simulation.
void replaceParentEdges(GNEShape *elementChild, const std::string &newEdgeIDs)
replace the parent edges of a shape
const std::vector< GNETAZElement * > & getParentTAZElements() const
get parent TAZElements