Eclipse SUMO - Simulation of Urban MObility
GNEChange_DataInterval.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 interval element is created or deleted
19/****************************************************************************/
20#include <config.h>
21
22#include <netedit/GNENet.h>
24
26
27// ===========================================================================
28// FOX-declarations
29// ===========================================================================
30FXIMPLEMENT_ABSTRACT(GNEChange_DataInterval, GNEChange, nullptr, 0)
31
32// ===========================================================================
33// member method definitions
34// ===========================================================================
35
37 GNEChange(Supermode::DATA, forward, dataInterval->isAttributeCarrierSelected()),
38 myDataInterval(dataInterval),
39 myDataSetParent(dataInterval->getDataSetParent()) {
40 myDataInterval->incRef("GNEChange_DataInterval");
41}
42
43
45 myDataInterval->decRef("GNEChange_DataInterval");
49 // show extra information for tests
50 WRITE_DEBUG("Deleting unreferenced " + myDataInterval->getTagStr() + " [" +
52 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in ~GNEChange_DataInterval()");
53 // check that data interval don't exist
55 // delete dataInterval
56 delete myDataInterval;
57 }
58}
59
60
61void
63 if (myForward) {
64 // show extra information for tests
65 WRITE_DEBUG("Removing " + myDataInterval->getTagStr() + " [" +
67 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
68 // remove data interval from data set parent
70 } else {
71 // show extra information for tests
72 WRITE_DEBUG("adding " + myDataInterval->getTagStr() + " [" +
74 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
75 // add data interval into data set parent
77 }
78 // require always save elements
80}
81
82
83void
85 if (myForward) {
86 // show extra information for tests
87 WRITE_DEBUG("adding " + myDataInterval->getTagStr() + " [" +
89 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
90 // add data interval into data set parent
92 } else {
93 // show extra information for tests
94 WRITE_DEBUG("Removing " + myDataInterval->getTagStr() + " [" +
96 myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
97 // remove data interval from data set parent
99 }
100 // require always save elements
102}
103
104
105std::string
107 if (myForward) {
108 return ("Undo create " + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
109 } else {
110 return ("Undo delete " + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
111 }
112}
113
114
115std::string
117 if (myForward) {
118 return ("Redo create " + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
119 } else {
120 return ("Redo delete " + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
121 }
122}
123
124
125/****************************************************************************/
Supermode
@brie enum for supermodes
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:276
@ 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:60
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:216
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
Definition: GNEDataSet.cpp:220
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:206
GNEDataSet * retrieveDataSet(const std::string &id, bool hardFail=true) const
Returns the named data set.
GNEDataInterval * retrieveDataInterval(GNEAttributeCarrier *AC, bool hardFail=true) const
Returns the data interval.
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:132
void requireSaveDataElements(bool value)
inform that data sets has to be saved
Definition: GNENet.cpp:2150
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced