Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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-2025 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
21#include <netedit/GNENet.h>
22#include <netedit/GNEViewNet.h>
26
27#include "GNEChange_DataSet.h"
28
29// ===========================================================================
30// FOX-declarations
31// ===========================================================================
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 // make sure that element isn't in net before removing
54 // delete data set
55 delete myDataSet;
56 }
57 }
58}
59
60
61void
63 if (myForward) {
64 // delete data set from net
66 } else {
67 // insert data set into net
69 }
70 // require always save elements
72}
73
74
75void
77 if (myForward) {
78 // insert data set into net
80 } else {
81 // delete data set from net
83 }
84 // require always save elements
86}
87
88
89std::string
91 if (myForward) {
92 return (TL("Undo create ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
93 } else {
94 return (TL("Undo delete ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
95 }
96}
97
98
99std::string
101 if (myForward) {
102 return (TL("Redo create ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
103 } else {
104 return (TL("Redo delete ") + myDataSet->getTagStr() + " '" + myDataSet->getID() + "'");
105 }
106}
107
108
109/****************************************************************************/
Supermode
@brie enum for supermodes
@ DATA
Data mode (edgeData, LaneData etc..)
#define TL(string)
Definition MsgHandler.h:305
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:180
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:164
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition GNENet.cpp:146
GNEViewNet * getViewNet() const
get view net
Definition GNENet.cpp:2194
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