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-2016 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,
50  const std::string& value,
51  bool customOrigValue,
52  const std::string& origValue) :
53  GNEChange(0, true),
54  myAC(ac),
55  myKey(key),
56  myOrigValue(customOrigValue ? origValue : ac->getAttribute(key)),
57  myNewValue(value) {
58  myAC->incRef("GNEChange_Attribute " + toString(myKey));
59 }
60 
61 
63  assert(myAC);
64  myAC->decRef("GNEChange_Attribute " + toString(myKey));
65  if (myAC->unreferenced()) {
66  delete myAC;
67  }
68 }
69 
70 
71 void
74 }
75 
76 
77 void
80 }
81 
82 
83 bool
85  return myOrigValue != myNewValue;
86 }
87 
88 
89 FXString
91  return ("Undo change " + myAC->getDescription() + " attribute").c_str();
92 }
93 
94 
95 FXString
97  return ("Redo change " + myAC->getDescription() + " attribute").c_str();
98 }
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
the function-object for an editing operation (abstract base)
bool trueChange()
wether original and new value differ
std::string myNewValue
the original value
~GNEChange_Attribute()
Destructor.
FXString undoName() const
return undoName
virtual std::string getDescription()
how should this attribute carrier be called
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:55
void decRef(const std::string &debugMsg="")
FXString redoName() const
get Redo name
GNEAttributeCarrier * myAC
the net to which all operations shall be applied (we are not responsible for the pointer) ...
std::string myOrigValue
the original value