SUMO - Simulation of Urban MObility
GNEChange_TLS.cpp
Go to the documentation of this file.
1 /****************************************************************************/
7 // A network change in which a traffic light 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>
33 #include <netbuild/NBOwnTLDef.h>
34 #include "GNEChange_TLS.h"
35 #include "GNEJunction.h"
36 
37 #ifdef CHECK_MEMORY_LEAKS
38 #include <foreign/nvwa/debug_new.h>
39 #endif
40 
41 
42 // ===========================================================================
43 // FOX-declarations
44 // ===========================================================================
45 FXIMPLEMENT_ABSTRACT(GNEChange_TLS, GNEChange, NULL, 0)
46 
47 // ===========================================================================
48 // member method definitions
49 // ===========================================================================
50 
51 
52 // Constructor for creating an edge
54  GNEJunction* junction, NBTrafficLightDefinition* tlDef, bool forward, bool forceInsert, const std::string tlID):
55  GNEChange(0, forward),
56  myJunction(junction),
57  myTlDef(tlDef),
58  myForceInsert(forceInsert) {
59  myJunction->incRef("GNEChange_TLS");
60  if (myTlDef == 0) {
61  assert(forward);
62  // potential memory leak if this change is never executed
64  myTlDef = new NBOwnTLDef(tlID == "" ? myJunction->getMicrosimID() : tlID, 0, type);
65  }
66 }
67 
68 
70  assert(myJunction);
71  myJunction->decRef("GNEChange_TLS");
72  if (myJunction->unreferenced()) {
73  delete myJunction;
74  }
75 }
76 
77 
79  if (myForward) {
81  } else {
83  }
84 }
85 
86 
88  if (myForward) {
90  } else {
92  }
93 }
94 
95 
96 FXString GNEChange_TLS::undoName() const {
97  if (myForward) {
98  return ("Undo create traffic light");
99  } else {
100  return ("Undo delete traffic light");
101  }
102 }
103 
104 
105 FXString GNEChange_TLS::redoName() const {
106  if (myForward) {
107  return ("Redo create traffic light");
108  } else {
109  return ("Redo delete traffic light");
110  }
111 }
GNEJunction * myJunction
Definition: GNEChange_TLS.h:84
the function-object for an editing operation (abstract base)
Definition: GNEChange.h:49
void redo()
redo action
The base class for traffic light logic definitions.
bool myForceInsert
check if forceInsert is enabled
Definition: GNEChange_TLS.h:91
NBTrafficLightDefinition * myTlDef
Definition: GNEChange_TLS.h:88
~GNEChange_TLS()
Destructor.
void removeTrafficLight(NBTrafficLightDefinition *tlDef)
removes a traffic light
static OptionsCont & getOptions()
Retrieves the options.
Definition: OptionsCont.cpp:69
void undo()
undo action
static StringBijection< TrafficLightType > TrafficLightTypes
T get(const std::string &str) const
void decRef(const std::string &debugMsg="")
bool myForward
we group antagonistic commands (create junction/delete junction) and keep them apart by this flag ...
Definition: GNEChange.h:87
A traffic light logics which must be computed (only nodes/edges are given)
Definition: NBOwnTLDef.h:54
void addTrafficLight(NBTrafficLightDefinition *tlDef, bool forceInsert)
adds a traffic light
FXString undoName() const
return undoName
FXString redoName() const
get Redo name
TrafficLightType