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 
73 }
74 
75 
78 }
79 
80 
82  return ("Undo change " + myAC->getDescription() + " attribute").c_str();
83 }
84 
85 
87  return ("Redo change " + myAC->getDescription() + " attribute").c_str();
88 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
SumoXMLAttr myKey
The attribute name.
SumoXMLAttr
Numbers representing SUMO-XML - attributes.
virtual void setAttribute(SumoXMLAttr key, const std::string &value, GNEUndoList *undoList)=0
FXString redoName() const
the function-object for an editing operation (abstract base)
std::string myNewValue
the original value
~GNEChange_Attribute()
Destructor.
std::string toString(const T &t, std::streamsize accuracy=OUTPUT_ACCURACY)
Definition: ToString.h:54
void decRef(const std::string &debugMsg="")
GNEAttributeCarrier * myAC
the net to which all operations shall be applied (we are not responsible for the pointer) ...
virtual std::string getDescription()
how should this attribute carrier be called
FXString undoName() const
std::string myOrigValue
the original value