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.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>
24 
25 #include "GNEChange_DataInterval.h"
26 
27 // ===========================================================================
28 // FOX-declarations
29 // ===========================================================================
30 FXIMPLEMENT_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 
61 void
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 
83 void
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 
105 std::string
107  if (myForward) {
108  return (TL("Undo create ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
109  } else {
110  return (TL("Undo delete ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
111  }
112 }
113 
114 
115 std::string
117  if (myForward) {
118  return (TL("Redo create ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
119  } else {
120  return (TL("Redo delete ") + myDataInterval->getTagStr() + " '" + myDataInterval->getID() + "'");
121  }
122 }
123 
124 
125 /****************************************************************************/
Supermode
@brie enum for supermodes
#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
Definition: GNEDataSet.cpp:268
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:254
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:128
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
get all attribute carriers used in this net
Definition: GNENet.cpp:122
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced