SUMO - Simulation of Urban MObility
GNEChange_Lane.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a single lane 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 <cassert>
31 #include "GNEChange_Lane.h"
32 #include "GNEEdge.h"
33 #include "GNELane.h"
34 
35 #ifdef CHECK_MEMORY_LEAKS
36 #include <foreign/nvwa/debug_new.h>
37 #endif
38 
39 
40 // ===========================================================================
41 // FOX-declarations
42 // ===========================================================================
43 FXIMPLEMENT_ABSTRACT(GNEChange_Lane, GNEChange, NULL, 0)
44 
45 // ===========================================================================
46 // member method definitions
47 // ===========================================================================
48 
49 
50 // Constructor for creating an edge
51 GNEChange_Lane::GNEChange_Lane(GNEEdge* edge, GNELane* lane, const NBEdge::Lane& laneAttrs, bool forward):
52  GNEChange(0, forward),
53  myEdge(edge),
54  myLane(lane),
55  myLaneAttrs(laneAttrs) {
56  myEdge->incRef("GNEChange_Lane");
57  if (myLane) { // non-zero pointer is only passsed in case of removal
58  assert(!forward);
59  myLane->incRef("GNEChange_Lane");
60  } else {
61  assert(forward);
62  }
63 }
64 
65 
67  assert(myEdge);
68  myEdge->decRef("GNEChange_Lane");
69  if (myEdge->unreferenced()) {
70  delete myEdge;
71  }
72  if (myLane) {
73  myLane->decRef("GNEChange_Lane");
74  if (myLane->unreferenced()) {
75  delete myLane;
76  }
77  }
78 }
79 
80 
82  if (myForward) {
84  } else {
86  }
87 }
88 
89 
91  if (myForward) {
93  } else {
95  }
96 }
97 
98 
99 FXString GNEChange_Lane::undoName() const {
100  if (myForward) {
101  return ("Undo create lane");
102  } else {
103  return ("Undo delete lane");
104  }
105 }
106 
107 
108 FXString GNEChange_Lane::redoName() const {
109  if (myForward) {
110  return ("Redo create lane");
111  } else {
112  return ("Redo delete lane");
113  }
114 }
void addLane(GNELane *lane, const NBEdge::Lane &laneAttrs)
increase number of lanes by one use the given attributes and restore the GNELane
Definition: GNEEdge.cpp:694
const NBEdge::Lane myLaneAttrs
~GNEChange_Lane()
Destructor.
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:48
The representation of a single edge during network building.
Definition: NBEdge.h:70
This lane is powered by an underlying GNEEdge and basically knows how to draw itself.
Definition: GNELane.h:56
FXString redoName() const
FXString undoName() const
void removeLane(GNELane *lane)
Definition: GNEEdge.cpp:727
void decRef(const std::string &debugMsg="")
A road/street connecting two junctions (netedit-version)
Definition: GNEEdge.h:61
GNEEdge * myEdge
full information regarding the lane that is to be created/deleted we assume shared responsibility for...
GNELane * myLane
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:86