SUMO - Simulation of Urban MObility
GNEChange_Attribute.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which something is moved (for undo/redo)
8 /****************************************************************************/
9 // SUMO, Simulation of Urban MObility; see http://sumo.dlr.de/
10 // Copyright (C) 2001-2017 DLR (http://www.dlr.de/) and contributors
11 /****************************************************************************/
12 //
13 // This file is part of SUMO.
14 // SUMO is free software: you can redistribute it and/or modify
15 // it under the terms of the GNU General Public License as published by
16 // the Free Software Foundation, either version 3 of the License, or
17 // (at your option) any later version.
18 //
19 /****************************************************************************/
20 
21 // ===========================================================================
22 // included modules
23 // ===========================================================================
24 #ifdef _MSC_VER
25 #include <windows_config.h>
26 #else
27 #include <config.h>
28 #endif
29 
30 #include <cassert>
31 #include "GNEChange_Attribute.h"
32 #include "GNEAttributeCarrier.h"
33 
34 #ifdef CHECK_MEMORY_LEAKS
35 #include <foreign/nvwa/debug_new.h>
36 #endif
37 
38 
39 // ===========================================================================
40 // FOX-declarations
41 // ===========================================================================
42 FXIMPLEMENT_ABSTRACT(GNEChange_Attribute, GNEChange, NULL, 0)
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 
49  SumoXMLAttr key, const std::string& value,
50  bool customOrigValue, const std::string& origValue) :
51  GNEChange(0, true),
52  myAC(ac),
53  myKey(key),
54  myOrigValue(customOrigValue ? origValue : ac->getAttribute(key)),
55  myNewValue(value) {
56  myAC->incRef("GNEChange_Attribute " + toString(myKey));
57 }
58 
59 
61  assert(myAC);
62  myAC->decRef("GNEChange_Attribute " + toString(myKey));
63  if (myAC->unreferenced()) {
64  delete myAC;
65  }
66 }
67 
68 
69 void
72 }
73 
74 
75 void
78 }
79 
80 
81 bool
83  return myOrigValue != myNewValue;
84 }
85 
86 
87 FXString
89  return ("Undo change " + myAC->getDescription() + " attribute").c_str();
90 }
91 
92 
93 FXString
95  return ("Redo change " + myAC->getDescription() + " attribute").c_str();
96 }
97 
98 
99 /****************************************************************************/
void redo()
redo action
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
SumoXMLAttr myKey
The attribute name.
void undo()
undo action
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
FXString redoName() const
get Redo name
the function-object for an editing operation (abstract base)
bool trueChange()
wether original and new value differ
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:55
std::string myNewValue
the original value
~GNEChange_Attribute()
Destructor.
virtual std::string getDescription()
how should this attribute carrier be called
void decRef(const std::string &debugMsg="")
GNEAttributeCarrier * myAC
the net to which all operations shall be applied
FXString undoName() const
return undoName
std::string myOrigValue
the original value