Eclipse SUMO - Simulation of Urban MObility
GNEChange_EnableAttribute.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 something is changed (for undo/redo)
19 /****************************************************************************/
20 #include <config.h>
21 
22 #include <netedit/GNENet.h>
23 
25 
26 // ===========================================================================
27 // FOX-declarations
28 // ===========================================================================
29 FXIMPLEMENT_ABSTRACT(GNEChange_EnableAttribute, GNEChange, nullptr, 0)
30 
31 // ===========================================================================
32 // member method definitions
33 // ===========================================================================
34 
35 GNEChange_EnableAttribute::GNEChange_EnableAttribute(GNEAttributeCarrier* ac, const int originalAttributes, const int newAttributes) :
36  GNEChange(true, false),
37  myAC(ac),
38  myOriginalAttributes(originalAttributes),
39  myNewAttributes(newAttributes) {
40  myAC->incRef("GNEChange_EnableAttribute " + myAC->getTagProperty().getTagStr());
41 }
42 
43 
45  // decrease reference
46  myAC->decRef("GNEChange_EnableAttribute " + myAC->getTagProperty().getTagStr());
47  // remove if is unreferenced
48  if (myAC->unreferenced()) {
49  // show extra information for tests
50  WRITE_DEBUG("Deleting unreferenced " + myAC->getTagStr() + " '" + myAC->getID() + "' in GNEChange_EnableAttribute");
51  // delete AC
52  delete myAC;
53  }
54 }
55 
56 
57 void
59  // show extra information for tests
60  WRITE_DEBUG("Setting previous attribute into " + myAC->getTagStr() + " '" + myAC->getID() + "'");
61  // set original attributes
63  // check if networkElements, additional or shapes has to be saved
65  myAC->getNet()->requireSaveNet(true);
68  } else if (myAC->getTagProperty().isDemandElement()) {
70  }
71 }
72 
73 
74 void
76  // show extra information for tests
77  WRITE_DEBUG("Setting new attribute into " + myAC->getTagStr() + " '" + myAC->getID() + "'");
78  // set new attributes
80  // check if networkElements, additional or shapes has to be saved
82  myAC->getNet()->requireSaveNet(true);
85  } else if (myAC->getTagProperty().isDemandElement()) {
87  }
88 }
89 
90 
91 FXString
93  return ("Undo change " + myAC->getTagStr() + " attribute").c_str();
94 }
95 
96 
97 FXString
99  return ("Redo change " + myAC->getTagStr() + " attribute").c_str();
100 }
101 
102 
103 /****************************************************************************/
#define WRITE_DEBUG(msg)
Definition: MsgHandler.h:286
virtual void setEnabledAttribute(const int enabledAttributes)=0
method for enabling the attribute and nothing else (used in GNEChange_EnableAttribute)
virtual const std::string & getID() const =0
return ID of object
const std::string & getTagStr() const
get tag assigned to this object in string format
const GNETagProperties & getTagProperty() const
get Tag Property assigned to this object
GNENet * getNet() const
get pointer to net
the function-object for an editing operation (abstract base)
GNEAttributeCarrier * myAC
the net to which all operations shall be applied
const int myNewAttributes
original attributes
FXString undoName() const
return undoName
FXString redoName() const
get Redo name
const int myOriginalAttributes
original attributes
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:65
void requireSaveNet(bool value)
inform that net has to be saved
Definition: GNENet.cpp:1047
void requireSaveAdditionals(bool value)
inform that additionals has to be saved
Definition: GNENet.cpp:2361
void requireSaveDemandElements(bool value)
inform that demand elements has to be saved
Definition: GNENet.cpp:2474
void decRef(const std::string &debugMsg="")
Decrease reference.
bool unreferenced()
check if object ins't referenced
bool isShape() const
return true if tag correspond to a shape
const std::string & getTagStr() const
get Tag vinculated with this attribute Property in String Format (used to avoid multiple calls to toS...
bool isNetworkElement() const
return true if tag correspond to a network element
bool isDemandElement() const
return true if tag correspond to a demand element
bool isAdditionalElement() const
return true if tag correspond to an additional element