Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_DataSet.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 data set element is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
27
28#include "GNEChange_DataSet.h"
29
30// ===========================================================================
31// FOX-declarations
32// ===========================================================================
33FXIMPLEMENT_ABSTRACT(GNEChange_DataSet, GNEChange, nullptr, 0)
34
35// ===========================================================================
36// member method definitions
37// ===========================================================================
38
40 GNEChange(Supermode::DATA, forward, dataSet->isAttributeCarrierSelected()),
41 myDataSet(dataSet) {
42 myDataSet->incRef("GNEChange_DataSet");
43}
44
45
47 // only continue we have undo-redo mode enabled
49 myDataSet->decRef("GNEChange_DataSet");
50 if (myDataSet->unreferenced() &&
52 // show extra information for tests
53 WRITE_DEBUG("Deleting unreferenced " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
54 // make sure that element isn't in net before removing
56 // delete data set
57 delete myDataSet;
58 }
59 }
60}
61
62
63void
65 if (myForward) {
66 // show extra information for tests
67 WRITE_DEBUG("Removing " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
68 // delete data set from net
70 } else {
71 // show extra information for tests
72 WRITE_DEBUG("Adding " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
73 // insert data set into net
75 }
76 // require always save elements
78}
79
80
81void
83 if (myForward) {
84 // show extra information for tests
85 WRITE_DEBUG("Adding " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
86 // insert data set into net
88 } else {
89 // show extra information for tests
90 WRITE_DEBUG("Removing " + myDataSet->getTagStr() + " '" + myDataSet->getID() + "' in GNEChange_DataSet");
91 // delete data set from net
93 }
94 // require always save elements
96}
97
98
99std::string
101 if (myForward) {
102 return (TL("Undo create ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
103 } else {
104 return (TL("Undo delete ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
105 }
106}
107
108
109std::string
111 if (myForward) {
112 return (TL("Redo create ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
113 } else {
114 return (TL("Redo delete ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
115 }
116}
117
118
119/****************************************************************************/
Supermode
@brie enum for supermodes
@ DATA
Data mode (edgeData, LaneData etc..)
#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
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:56
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition GNEChange.h:212
void deleteDataSet(GNEDataSet *dataSet)
delete data set of container
void insertDataSet(GNEDataSet *dataSet)
Insert a data set in container.
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
void requireSaveDataElements()
inform that data elements has to be saved
GNENetHelper::SavingStatus * getSavingStatus() const
get saving status
Definition GNENet.cpp:133
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:127
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2155
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
GNEViewParent * getViewParent() const
get the net object
GNEApplicationWindow * getGNEAppWindows() const
get GNE Application Windows