Eclipse SUMO - Simulation of Urban MObility
GNEHierarchicalElement.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 
22 #include <netedit/GNEGeometry.h>
24 
26 
27 
28 // ===========================================================================
29 // class definitions
30 // ===========================================================================
31 
37 
38 public:
40  friend class GNEChange_Children;
41  friend class GNEDemandElement;
42 
56  const std::vector<GNEJunction*>& parentJunctions,
57  const std::vector<GNEEdge*>& parentEdges,
58  const std::vector<GNELane*>& parentLanes,
59  const std::vector<GNEAdditional*>& parentAdditionals,
60  const std::vector<GNEShape*>& parentShapes,
61  const std::vector<GNETAZElement*>& parentTAZElements,
62  const std::vector<GNEDemandElement*>& parentDemandElements,
63  const std::vector<GNEGenericData*>& parentGenericDatas);
64 
67 
71  virtual void updateGeometry() = 0;
72 
74  virtual Position getPositionInView() const = 0;
76 
79 
82 
85 
87  std::vector<GNEHierarchicalElement*> getAllHierarchicalElements() const;
88 
90  const std::vector<GNEJunction*>& getParentJunctions() const;
91 
93  const std::vector<GNEEdge*>& getParentEdges() const;
94 
96  const std::vector<GNELane*>& getParentLanes() const;
97 
99  const std::vector<GNEAdditional*>& getParentAdditionals() const;
100 
102  const std::vector<GNEShape*>& getParentShapes() const;
103 
105  const std::vector<GNETAZElement*>& getParentTAZElements() const;
106 
108  const std::vector<GNEDemandElement*>& getParentDemandElements() const;
109 
111  const std::vector<GNEGenericData*>& getParentGenericDatas() const;
112 
114  const std::vector<GNEJunction*>& getChildJunctions() const;
115 
117  const std::vector<GNEEdge*>& getChildEdges() const;
118 
120  const std::vector<GNELane*>& getChildLanes() const;
121 
123  const std::vector<GNEAdditional*>& getChildAdditionals() const;
124 
126  const std::vector<GNEShape*>& getChildShapes() const;
127 
129  const std::vector<GNETAZElement*>& getChildTAZElements() const;
130 
132  const std::vector<GNEDemandElement*>& getChildDemandElements() const;
133 
135  const std::vector<GNEGenericData*>& getChildGenericDatas() const;
137 
140 
142  template<typename T>
143  void addParentElement(T* element);
144 
146  template<typename T>
147  void removeParentElement(T* element);
148 
150  template<typename T>
151  void addChildElement(T* element);
152 
154  template<typename T>
155  void removeChildElement(T* element);
157 
160 
162  std::string getNewListOfParents(const GNENetworkElement* currentElement, const GNENetworkElement* newNextElement) const;
163 
165 
168 
170  void drawHierarchicalConnections(const GUIVisualizationSettings& s, const GNEAttributeCarrier* AC, const double exaggeration) const;
171 
174 
177 
179  virtual void updateParentAdditional();
180 
181 protected:
183  template<typename T, typename U>
184  void replaceParentElements(T* elementChild, const U& newParents) {
185  // remove elementChild from parents
186  for (const auto& parent : myHierarchicalContainer.getParents<U>()) {
187  parent->removeChildElement(elementChild);
188  }
189  // set new parents junctions
191  // add elementChild into new parents
192  for (const auto& parent : myHierarchicalContainer.getParents<U>()) {
193  parent->addChildElement(elementChild);
194  }
195  }
196 
198  template<typename T, typename U>
199  void replaceChildElements(T* elementChild, const U& newChildren) {
200  // remove elementChild from childs
201  for (const auto& child : myHierarchicalContainer.getChildren<U>()) {
202  child->removeChildElement(elementChild);
203  }
204  // set new childs junctions
206  // add elementChild into new childs
207  for (const auto& child : myHierarchicalContainer.getChildren<U>()) {
208  child->addChildElement(elementChild);
209  }
210  }
211 
214 
215 private:
218 
221 
224 };
225 
SumoXMLTag
Numbers representing SUMO-XML - element names.
An Element which don't belongs to GNENet but has influency in the simulation.
class to pack all variables and functions relative to connections between hierarchical element and th...
Definition: GNEGeometry.h:446
Hierarchical container (used for keep myParent and myChildren.
const T & getParents() const
get parents
const T & getChildren() const
get children
void setChildren(const T &newChildren)
set children
void setParents(const T &newParents)
set parents
const std::vector< GNEJunction * > & getParentJunctions() const
get parent junctions
void addChildElement(T *element)
add child element
void drawHierarchicalConnections(const GUIVisualizationSettings &s, const GNEAttributeCarrier *AC, const double exaggeration) const
Draw hierarchical connections between parent and children.
const std::vector< GNETAZElement * > & getChildTAZElements() const
get child TAZElements
const std::vector< GNEDemandElement * > & getChildDemandElements() const
return child demand elements
const std::vector< GNEGenericData * > & getParentGenericDatas() const
get parent demand elements
bool checkChildAdditionalsOverlapping() const
check if children are overlapped (Used by Rerouters)
const std::vector< GNELane * > & getChildLanes() const
get child lanes
void updateHierarchicalConnections()
update child connections
virtual void updateParentAdditional()
update parent after add or remove a child (can be reimplemented, for example used for statistics)
const GNEHierarchicalContainer & getHierarchicalContainer() const
get hierarchicalcontainer with parents and children
const std::vector< GNEDemandElement * > & getParentDemandElements() const
get parent demand elements
GNEHierarchicalContainer myHierarchicalContainer
hierarchical container with parents and children
bool checkChildDemandElementsOverlapping() const
check if childs demand elements are overlapped
GNEGeometry::HierarchicalConnections myHierarchicalConnections
hierarchical connections
const std::vector< GNEAdditional * > & getParentAdditionals() const
get parent additionals
void addParentElement(T *element)
add parent element
virtual Position getPositionInView() const =0
Returns position of hierarchical element in view.
const std::vector< GNEShape * > & getParentShapes() const
get parent shapes
const std::vector< GNEEdge * > & getChildEdges() const
get child edges
const std::vector< GNEEdge * > & getParentEdges() const
get parent edges
std::vector< GNEHierarchicalElement * > getAllHierarchicalElements() const
get all parents and children
void removeChildElement(T *element)
remove child element
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...
virtual void updateGeometry()=0
update pre-computed geometry information
GNEHierarchicalElement(const GNEHierarchicalElement &)=delete
Invalidated copy constructor.
const std::vector< GNEJunction * > & getChildJunctions() const
get child junctions
GNEHierarchicalElement(GNENet *net, SumoXMLTag tag, 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.
const std::vector< GNELane * > & getParentLanes() const
get parent lanes
const std::vector< GNEShape * > & getChildShapes() const
get child shapes
const std::vector< GNETAZElement * > & getParentTAZElements() const
get parent TAZElements
const std::vector< GNEAdditional * > & getChildAdditionals() const
return child additionals
void replaceParentElements(T *elementChild, const U &newParents)
replace parent elements
GNEHierarchicalElement & operator=(const GNEHierarchicalElement &)=delete
Invalidated assignment operator.
void replaceChildElements(T *elementChild, const U &newChildren)
replace child elements
const std::vector< GNEGenericData * > & getChildGenericDatas() const
return child generic data elements
void removeParentElement(T *element)
remove parent element
void restoreHierarchicalContainer(const GNEHierarchicalContainer &container)
restore hierarchical container
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:40
Stores the information about how to visualize structures.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36