SUMO - Simulation of Urban MObility
GNEChange_Edge.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single junction is created or deleted
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 "GNEChange_Edge.h"
31 #include "GNENet.h"
32 #include "GNEEdge.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_Edge, GNEChange, NULL, 0)
43 
44 // ===========================================================================
45 // member method definitions
46 // ===========================================================================
47 
48 
49 // Constructor for creating an edge
50 GNEChange_Edge::GNEChange_Edge(GNENet* net, GNEEdge* edge, bool forward):
51  GNEChange(net, forward),
52  myEdge(edge) {
53  assert(myNet);
54  edge->incRef("GNEChange_Edge");
55 }
56 
57 
59  assert(myEdge);
60  myEdge->decRef("GNEChange_Edge");
61  if (myEdge->unreferenced()) {
62  delete myEdge;
63  }
64 }
65 
66 
68  if (myForward) {
70  } else {
72  }
73 }
74 
75 
77  if (myForward) {
79  } else {
81  }
82 }
83 
84 
85 FXString GNEChange_Edge::undoName() const {
86  if (myForward) {
87  return ("Undo create edge");
88  } else {
89  return ("Undo delete edge");
90  }
91 }
92 
93 
94 FXString GNEChange_Edge::redoName() const {
95  if (myForward) {
96  return ("Redo create edge");
97  } else {
98  return ("Redo delete edge");
99  }
100 }
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
A NBNetBuilder extended by visualisation and editing capabilities.
Definition: GNENet.h:77
void insertEdge(GNEEdge *edge)
inserts a single edge into the net and into the underlying
Definition: GNENet.cpp:919
FXString redoName() const
FXString undoName() const
void decRef(const std::string &debugMsg="")
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
GNENet * myNet
the net to which operations shall be applied or which shall be informed about gui updates (we are not...
Definition: GNEChange.h:73
GNEEdge * myEdge
full information regarding the edge that is to be created/deleted we assume shared responsibility for...
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86
void deleteSingleEdge(GNEEdge *edge)
deletes a single edge
Definition: GNENet.cpp:971
~GNEChange_Edge()
Destructor.