Eclipse SUMO - Simulation of Urban MObility
Loading...
Searching...
No Matches
GNEChange_DataInterval.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 interval element is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
23#include <netedit/GNEViewNet.h>
27
29
30// ===========================================================================
31// FOX-declarations
32// ===========================================================================
33FXIMPLEMENT_ABSTRACT(GNEChange_DataInterval, GNEChange, nullptr, 0)
34
35// ===========================================================================
36// member method definitions
37// ===========================================================================
38
40 GNEChange(Supermode::DATA, forward, dataInterval->isAttributeCarrierSelected()),
41 myDataInterval(dataInterval),
42 myDataSetParent(dataInterval->getDataSetParent()) {
43 myDataInterval->incRef("GNEChange_DataInterval");
44}
45
46
48 // only continue we have undo-redo mode enabled
50 myDataInterval->decRef("GNEChange_DataInterval");
54 // show extra information for tests
55 WRITE_DEBUG("Deleting unreferenced " + myDataInterval->getTagStr() + " [" +
57 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in ~GNEChange_DataInterval()");
58 // check that data interval don't exist
60 // delete dataInterval
61 delete myDataInterval;
62 }
63 }
64}
65
66
67void
69 if (myForward) {
70 // show extra information for tests
71 WRITE_DEBUG("Removing " + myDataInterval->getTagStr() + " [" +
73 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
74 // remove data interval from data set parent
76 } else {
77 // show extra information for tests
78 WRITE_DEBUG("adding " + myDataInterval->getTagStr() + " [" +
80 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
81 // add data interval into data set parent
83 }
84 // require always save elements
86}
87
88
89void
91 if (myForward) {
92 // show extra information for tests
93 WRITE_DEBUG("adding " + myDataInterval->getTagStr() + " [" +
95 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
96 // add data interval into data set parent
98 } else {
99 // show extra information for tests
100 WRITE_DEBUG("Removing " + myDataInterval->getTagStr() + " [" +
102 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
103 // remove data interval from data set parent
105 }
106 // require always save elements
108}
109
110
111std::string
113 if (myForward) {
114 return (TL("Undo create ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
115 } else {
116 return (TL("Undo delete ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
117 }
118}
119
120
121std::string
123 if (myForward) {
124 return (TL("Redo create ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
125 } else {
126 return (TL("Redo delete ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
127 }
128}
129
130
131/****************************************************************************/
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
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
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
GNEDataInterval * myDataInterval
full information regarding the data interval element that is to be created/deleted
GNEDataSet * myDataSetParent
pointer to data set parent
std::string undoName() const
return undoName
std::string redoName() const
get Redo name
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
An Element which don't belong to GNENet but has influence in the simulation.
std::string getAttribute(SumoXMLAttr key) const
GNEDataSet * getDataSetParent() const
Returns a pointer to GNEDataSet parent.
void removeDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
GNEDataInterval * retrieveDataInterval(const GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
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