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 
35 // ===========================================================================
36 // FOX-declarations
37 // ===========================================================================
38 FXIMPLEMENT_ABSTRACT(GNEChange_Attribute, GNEChange, NULL, 0)
39 
40 // ===========================================================================
41 // member method definitions
42 // ===========================================================================
43 
45  SumoXMLAttr key, const std::string& value,
46  bool customOrigValue, const std::string& origValue) :
47  GNEChange(0, true),
48  myAC(ac),
49  myKey(key),
50  myOrigValue(customOrigValue ? origValue : ac->getAttribute(key)),
51  myNewValue(value) {
52  myAC->incRef("GNEChange_Attribute " + toString(myKey));
53 }
54 
55 
57  assert(myAC);
58  myAC->decRef("GNEChange_Attribute " + toString(myKey));
59  if (myAC->unreferenced()) {
60  delete myAC;
61  }
62 }
63 
64 
65 void
68 }
69 
70 
71 void
74 }
75 
76 
77 bool
79  return myOrigValue != myNewValue;
80 }
81 
82 
83 FXString
85  return ("Undo change " + myAC->getDescription() + " attribute").c_str();
86 }
87 
88 
89 FXString
91  return ("Redo change " + myAC->getDescription() + " attribute").c_str();
92 }
93 
94 
95 /****************************************************************************/
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 toString(const T &t, std::streamsize accuracy=gPrecision)
Definition: ToString.h:56
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
void decRef(const std::string &debugMsg="")
FXString redoName() const
get Redo name
GNEAttributeCarrier * myAC
the net to which all operations shall be applied
std::string myOrigValue
the original value