Eclipse SUMO - Simulation of Urban MObility
GNEChange_DataSet.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 data set element is created or deleted
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
24 #include <netedit/GNEViewNet.h>
25 
26 #include "GNEChange_DataSet.h"
27 
28 // ===========================================================================
29 // FOX-declarations
30 // ===========================================================================
31 FXIMPLEMENT_ABSTRACT(GNEChange_DataSet, GNEChange, nullptr, 0)
32 
33 // ===========================================================================
34 // member method definitions
35 // ===========================================================================
36 
38  GNEChange(Supermode::DATA, forward, dataSet->isAttributeCarrierSelected()),
39  myDataSet(dataSet) {
40  myDataSet->incRef("GNEChange_DataSet");
41 }
42 
43 
45  assert(myDataSet);
46  myDataSet->decRef("GNEChange_DataSet");
47  if (myDataSet->unreferenced()) {
48  // show extra information for tests
49  WRITE_DEBUG("Deleting unreferenced " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
50  // make sure that element isn't in net before removing
53  }
54  // delete data set
55  delete myDataSet;
56  }
57 }
58 
59 
60 void
62  if (myForward) {
63  // show extra information for tests
64  WRITE_DEBUG("Removing " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
65  // delete data set from net
67  } else {
68  // show extra information for tests
69  WRITE_DEBUG("Adding " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
70  // insert data set into net
72  }
73  // update toolbar
75  // require always save elements
77 }
78 
79 
80 void
82  if (myForward) {
83  // show extra information for tests
84  WRITE_DEBUG("Adding " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
85  // insert data set into net
87  } else {
88  // show extra information for tests
89  WRITE_DEBUG("Removing " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
90  // delete data set from net
92  }
93  // update toolbar
95  // require always save elements
97 }
98 
99 
100 std::string
102  if (myForward) {
103  return ("Undo create " + myDataSet->getTagStr());
104  } else {
105  return ("Undo delete " + myDataSet->getTagStr());
106  }
107 }
108 
109 
110 std::string
112  if (myForward) {
113  return ("Redo create " + myDataSet->getTagStr());
114  } else {
115  return ("Redo delete " + myDataSet->getTagStr());
116  }
117 }
118 
119 
120 /****************************************************************************/
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
GNENet * getNet() const
get pointer to net
std::string redoName() const
get Redo name
void undo()
undo action
~GNEChange_DataSet()
Destructor.
void redo()
redo action
std::string undoName() const
return undoName
GNEDataSet * myDataSet
full information regarding the data set element that is to be created/deleted
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 std::string & getID() const
get ID
Definition: GNEDataSet.cpp:131
void deleteDataSet(GNEDataSet *dataSet)
delete demand element element of GNENet container
void insertDataSet(GNEDataSet *dataSet)
Insert a demand element element int GNENet container.
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
GNEViewNet * getViewNet() const
get view net
Definition: GNENet.cpp:1964
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
void updateIntervalBar()
update interval bar
GNEViewNetHelper::IntervalBar & getIntervalBar()
get interval bar