Eclipse SUMO - Simulation of Urban MObility
GNEChange_GenericData.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 generic data set is created or deleted
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #include <config.h>
25 
26 #include <netedit/GNENet.h>
28 
29 #include "GNEChange_GenericData.h"
30 
31 // ===========================================================================
32 // FOX-declarations
33 // ===========================================================================
34 FXIMPLEMENT_ABSTRACT(GNEChange_GenericData, GNEChange, nullptr, 0)
35 
36 // ===========================================================================
37 // member method definitions
38 // ===========================================================================
39 
41  GNEChange(Supermode::DATA, genericData, forward, genericData->isAttributeCarrierSelected()),
42  myGenericData(genericData),
43  myDataSetParent(genericData->getDataIntervalParent()->getDataSetParent()),
44  myDataIntervalParent(genericData->getDataIntervalParent()) {
45  myGenericData->incRef("GNEChange_GenericData");
46 }
47 
48 
50  assert(myGenericData);
51  myGenericData->decRef("GNEChange_GenericData");
52  if (myGenericData->unreferenced() &&
55  // show extra information for tests
56  WRITE_DEBUG("Deleting unreferenced " + myGenericData->getTagStr());
57  // delete generic data from interval parent
59  // delete generic data
60  delete myGenericData;
61  }
62 }
63 
64 
65 void
67  if (myForward) {
68  // show extra information for tests
69  WRITE_DEBUG("Removing " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
70  // unselect if mySelectedElement is enabled
71  if (mySelectedElement) {
73  }
74  // delete generic data from interval parent
76  // restore container
78  } else {
79  // show extra information for tests
80  WRITE_DEBUG("Adding " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
81  // select if mySelectedElement is enabled
82  if (mySelectedElement) {
84  }
85  // insert generic data into interval parent
87  // restore container
89  }
90  // require always save elements
92 }
93 
94 
95 void
97  if (myForward) {
98  // show extra information for tests
99  WRITE_DEBUG("Adding " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
100  // select if mySelectedElement is enabled
101  if (mySelectedElement) {
103  }
104  // insert generic data into interval parent
106  // add genericData in parents and children
108  } else {
109  // show extra information for tests
110  WRITE_DEBUG("Removing " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
111  // unselect if mySelectedElement is enabled
112  if (mySelectedElement) {
114  }
115  // delete generic data from interval parent
117  // remove genericData from parents and children
119  }
120  // require always save elements
122 }
123 
124 
125 std::string
127  if (myForward) {
128  return (TL("Undo create ") + myGenericData->getTagStr());
129  } else {
130  return (TL("Undo delete ") + myGenericData->getTagStr());
131  }
132 }
133 
134 
135 std::string
137  if (myForward) {
138  return (TL("Redo create ") + myGenericData->getTagStr());
139  } else {
140  return (TL("Redo delete ") + myGenericData->getTagStr());
141  }
142 }
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:306
#define TL(string)
Definition: MsgHandler.h:315
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 undoName() const
return undoName
GNEGenericData * myGenericData
full information regarding the generic data set that is to be created/deleted
std::string redoName() const
get Redo name
GNEDataInterval * myDataIntervalParent
data interval parent
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
void removeGenericDataChild(GNEGenericData *genericData)
add generic data child
void addGenericDataChild(GNEGenericData *genericData)
add generic data child
An Element which don't belong to GNENet but has influence in the simulation.
GNEDataInterval * retrieveDataInterval(const GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
GNEGenericData * retrieveGenericData(const GUIGlObject *glObject, bool hardFail=true) const
Returns the generic data.
void requireSaveDataElements()
inform that data elements has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition: GNENet.cpp:127
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:121
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced