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-2020 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(forward, dataInterval->isAttributeCarrierSelected()),
38  myDataInterval(dataInterval),
39  myDataSetParent(dataInterval->getDataSetParent()) {
40  myDataInterval->incRef("GNEChange_DataInterval");
41 }
42 
43 
45  myDataInterval->decRef("GNEChange_DataInterval");
47  // show extra information for tests
48  WRITE_DEBUG("Deleting unreferenced " + myDataInterval->getTagStr() + " [" +
50  myDataInterval->getAttribute(SUMO_ATTR_END) + "] in ~GNEChange_DataInterval()");
51  // check that data interval don't exist
55  }
56  // delete dataInterval
57  delete myDataInterval;
58  }
59 }
60 
61 
62 void
64  if (myForward) {
65  // show extra information for tests
66  WRITE_DEBUG("Removing " + myDataInterval->getTagStr() + " [" +
68  myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
69  // remove data interval from data set parent
71  } else {
72  // show extra information for tests
73  WRITE_DEBUG("adding " + myDataInterval->getTagStr() + " [" +
75  myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
76  // add data interval into data set parent
78  }
79  // Requiere always save elements
81 }
82 
83 
84 void
86  if (myForward) {
87  // show extra information for tests
88  WRITE_DEBUG("adding " + myDataInterval->getTagStr() + " [" +
90  myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
91  // add data interval into data set parent
93  } else {
94  // show extra information for tests
95  WRITE_DEBUG("Removing " + myDataInterval->getTagStr() + " [" +
97  myDataInterval->getAttribute(SUMO_ATTR_END) + "] in GNEChange_DataInterval");
98  // remove data interval from data set parent
100  }
101  // Requiere always save elements
103 }
104 
105 
106 FXString
108  if (myForward) {
109  return ("Undo create " + myDataInterval->getTagStr()).c_str();
110  } else {
111  return ("Undo delete " + myDataInterval->getTagStr()).c_str();
112  }
113 }
114 
115 
116 FXString
118  if (myForward) {
119  return ("Redo create " + myDataInterval->getTagStr()).c_str();
120  } else {
121  return ("Redo delete " + myDataInterval->getTagStr()).c_str();
122  }
123 }
124 
125 
126 /****************************************************************************/
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
@ SUMO_ATTR_BEGIN
weights: time range begin
@ SUMO_ATTR_END
weights: time range end
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
FXString undoName() const
return undoName
FXString redoName() const
get Redo name
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:65
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag
Definition: GNEChange.h:215
An Element which don't belongs to GNENet but has influency in the simulation.
std::string getAttribute(SumoXMLAttr key) const
GNEDataSet * getDataSetParent() const
Returns a pointer to GNEDataSet parent.
bool dataIntervalChildrenExist(GNEDataInterval *dataInterval) const
check if given data interval exist
Definition: GNEDataSet.cpp:238
void removeDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:223
void addDataIntervalChild(GNEDataInterval *dataInterval)
add data interval child
Definition: GNEDataSet.cpp:211
bool dataSetExist(const GNEDataSet *dataSet) const
return true if given demand element exist
GNENetHelper::AttributeCarriers * getAttributeCarriers() const
retrieve all attribute carriers of Net
Definition: GNENet.cpp:130
void requireSaveDataElements(bool value)
inform that data sets has to be saved
Definition: GNENet.cpp:2645
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced