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.org/sumo
3 // Copyright (C) 2001-2022 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()) {
53  // show extra information for tests
54  WRITE_DEBUG("Deleting unreferenced " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "'");
55  // check that generic data don't exist
59  // delete generic data from interval parent
61  }
62  // delete generic data
63  delete myGenericData;
64  }
65 }
66 
67 
68 void
70  if (myForward) {
71  // show extra information for tests
72  WRITE_DEBUG("Removing " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
73  // unselect if mySelectedElement is enabled
74  if (mySelectedElement) {
76  }
77  // delete generic data from interval parent
79  // restore container
81  } else {
82  // show extra information for tests
83  WRITE_DEBUG("Adding " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
84  // select if mySelectedElement is enabled
85  if (mySelectedElement) {
87  }
88  // insert generic data into interval parent
90  // restore container
92  }
93  // require always save elements
95 }
96 
97 
98 void
100  if (myForward) {
101  // show extra information for tests
102  WRITE_DEBUG("Adding " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
103  // select if mySelectedElement is enabled
104  if (mySelectedElement) {
106  }
107  // insert generic data into interval parent
109  // add genericData in parents and children
111  } else {
112  // show extra information for tests
113  WRITE_DEBUG("Removing " + myGenericData->getTagStr() + " '" + myGenericData->getID() + "' in GNEChange_GenericData");
114  // unselect if mySelectedElement is enabled
115  if (mySelectedElement) {
117  }
118  // delete generic data from interval parent
120  // remove genericData from parents and children
122  }
123  // require always save elements
125 }
126 
127 
128 std::string
130  if (myForward) {
131  return ("Undo create " + myGenericData->getTagStr());
132  } else {
133  return ("Undo delete " + myGenericData->getTagStr());
134  }
135 }
136 
137 
138 std::string
140  if (myForward) {
141  return ("Redo create " + myGenericData->getTagStr());
142  } else {
143  return ("Redo delete " + myGenericData->getTagStr());
144  }
145 }
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:290
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
GNEDataSet * myDataSetParent
data set parent
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:64
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:244
const bool mySelectedElement
flag for check if element is selected
Definition: GNEChange.h:247
void addElementInParentsAndChildren(T *element)
add given element into parents and children (only use in redo() function)
Definition: GNEChange.h:132
void removeElementFromParentsAndChildren(T *element)
remove given element from parents and children (only use in redo() function)
Definition: GNEChange.h:187
void restoreHierarchicalContainers()
restore container (only use in undo() function)
Definition: GNEChange.cpp:94
void removeGenericDataChild(GNEGenericData *genericData)
add generic data child
bool hasGenericDataChild(GNEGenericData *genericData) const
check if given generic data is child of this data interval
void addGenericDataChild(GNEGenericData *genericData)
add generic data child
bool dataIntervalChildrenExist(GNEDataInterval *dataInterval) const
check if given data interval exist
Definition: GNEDataSet.cpp:243
An Element which don't belongs to GNENet but has influency in the simulation.
const std::string & getID() const
get ID
bool dataSetExist(GNEDataSet *dataSet) const
return true if given demand element exist
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:125
void requireSaveDataElements(bool value)
inform that data sets has to be saved
Definition: GNENet.cpp:2123
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced