Eclipse SUMO - Simulation of Urban MObility
GNEChange_Additional.cpp
Go to the documentation of this file.
1 /****************************************************************************/
2 // Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3 // Copyright (C) 2001-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 /****************************************************************************/
18 // A network change in which a busStop is created or deleted
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 
24 #include "GNEChange_Additional.h"
25 
26 // ===========================================================================
27 // FOX-declarations
28 // ===========================================================================
29 FXIMPLEMENT_ABSTRACT(GNEChange_Additional, GNEChange, nullptr, 0)
30 
31 // ===========================================================================
32 // member method definitions
33 // ===========================================================================
34 
36  GNEChange(Supermode::NETWORK, additional, forward, additional->isAttributeCarrierSelected()),
37  myAdditional(additional) {
38  myAdditional->incRef("GNEChange_Additional");
39 }
40 
41 
43  myAdditional->decRef("GNEChange_Additional");
44  if (myAdditional->unreferenced()) {
45  // show extra information for tests
46  WRITE_DEBUG("Deleting unreferenced " + myAdditional->getTagStr());
47  // make sure that additional isn't in net before removing
49  // delete additional from net
51  }
52  delete myAdditional;
53  }
54 }
55 
56 
57 void
59  if (myForward) {
60  // show extra information for tests
61  WRITE_DEBUG("Removing " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
62  // unselect if mySelectedElement is enabled
63  if (mySelectedElement) {
65  }
66  // delete additional from net
68  // restore container
70  } else {
71  // show extra information for tests
72  WRITE_DEBUG("Adding " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
73  // select if mySelectedElement is enabled
74  if (mySelectedElement) {
76  }
77  // insert additional into net
79  // restore container
81  }
82  // require always save additionals
84 }
85 
86 
87 void
89  if (myForward) {
90  // show extra information for tests
91  WRITE_DEBUG("Adding " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
92  // select if mySelectedElement is enabled
93  if (mySelectedElement) {
95  }
96  // insert additional into net
98  // add additional in parent elements
100  } else {
101  // show extra information for tests
102  WRITE_DEBUG("Removing " + myAdditional->getTagStr() + " '" + myAdditional->getID() + "' in GNEChange_Additional");
103  // unselect if mySelectedElement is enabled
104  if (mySelectedElement) {
106  }
107  // delete additional from net
109  // remove additional from parents and children
111  }
112  // require always save additionals
114 }
115 
116 
117 std::string
119  if (myForward) {
120  return (TL("Undo create ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
121  } else {
122  return (TL("Undo delete ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
123  }
124 }
125 
126 
127 std::string
129  if (myForward) {
130  return (TL("Redo create ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
131  } else {
132  return (TL("Redo delete ") + myAdditional->getTagStr() + " '" + myAdditional->getID() + "'");
133  }
134 }
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:306
#define TL(string)
Definition: MsgHandler.h:315
An Element which don't belong to GNENet but has influence in the simulation.
Definition: GNEAdditional.h:49
const std::string getID() const
get ID (all Attribute Carriers have one)
const std::string & getTagStr() const
get tag assigned to this object in string format
void unselectAttributeCarrier(const bool changeFlag=true)
unselect attribute carrier using GUIGlobalSelection
GNENet * getNet() const
get pointer to net
void selectAttributeCarrier(const bool changeFlag=true)
select attribute carrier using GUIGlobalSelection
std::string redoName() const
get Redo name
GNEAdditional * myAdditional
full information regarding the additional element that is to be created/deleted
std::string undoName() const
return undoName
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:56
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:212
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:215
void addElementInParentsAndChildren(T *element)
add given element into parents and children (only use in redo() function)
Definition: GNEChange.h:124
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children (only use in redo() function)
Definition: GNEChange.h:167
void restoreHierarchicalContainers()
restore container (only use in undo() function)
Definition: GNEChange.cpp:94
GNEAdditional * retrieveAdditional(SumoXMLTag type, const std::string &id, bool hardFail=true) const
Returns the named additional.
void deleteAdditional(GNEAdditional *additional)
delete additional element of container
void insertAdditional(GNEAdditional *additional)
Insert a additional element in container.
void requireSaveAdditionals()
inform that additionals has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition: GNENet.cpp:128
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:122
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced