Eclipse SUMO - Simulation of Urban MObility
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
GNEChangeGroup.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3// Copyright (C) 2006-2025 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18//
19/****************************************************************************/
20
21#include "GNEChangeGroup.h"
22
23// ===========================================================================
24// FOX-declarations
25// ===========================================================================
26
27// Object implementation
28FXIMPLEMENT(GNEChangeGroup, GNEChange, nullptr, 0)
29
30// ---------------------------------------------------------------------------
31// GNEChangeGroup - methods
32// ---------------------------------------------------------------------------
33
34GNEChangeGroup::GNEChangeGroup(Supermode groupSupermode, GUIIcon icon, const std::string& description) :
35 myDescription(description),
36 myGroupSupermode(groupSupermode),
37 myIcon(icon),
38 undoList(nullptr),
39 redoList(nullptr),
40 group(nullptr) {
41 // get current time
42 const auto time = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
43 // extract localTime
44 const auto local_time = *localtime(&time);
45 // convert localtime to HH:MM:SS
46 myTimeStamp = toString(local_time.tm_hour) + ":" +
47 ((local_time.tm_min <= 9) ? "0" : "") + toString(local_time.tm_min) + ":" +
48 ((local_time.tm_sec <= 9) ? "0" : "") + toString(local_time.tm_sec);
49}
50
51
53 GNEChange* change = nullptr;
54 while (redoList) {
55 change = redoList;
57 delete change;
58 }
59 while (undoList) {
60 change = undoList;
62 delete change;
63 }
64 delete group;
65}
66
67
68const std::string&
72
73
74const std::string&
78
79
84
85
88 return myIcon;
89}
90
91
92std::string
94 return (TL("Undo") + std::string(" ") + myDescription);
95}
96
97
98std::string
100 return (TL("Redo") + std::string(" ") + myDescription);
101}
102
103
104bool
106 return (undoList == nullptr);
107}
108
109
110void
112 GNEChange* change = nullptr;
113 while (undoList) {
114 change = undoList;
116 change->undo();
117 change->next = redoList;
118 redoList = change;
119 }
120}
121
122
123void
125 GNEChange* change = nullptr;
126 while (redoList) {
127 change = redoList;
129 change->redo();
130 change->next = undoList;
131 undoList = change;
132 }
133}
134
135
136int
138 FXuint result = sizeof(GNEChangeGroup);
139 GNEChange* change;
140 for (change = undoList; change; change = change->next) {
141 result += change->size();
142 }
143 for (change = redoList; change; change = change->next) {
144 result += change->size();
145 }
146 return result;
147}
148
149
151 myGroupSupermode(Supermode::NETWORK),
152 myIcon(GUIIcon::UNDO),
153 undoList(nullptr),
154 redoList(nullptr),
155 group(nullptr)
156{ }
Supermode
@brie enum for supermodes
@ NETWORK
Network mode (Edges, junctions, etc..)
GUIIcon
An enumeration of icons used by the gui applications.
Definition GUIIcons.h:33
#define TL(string)
Definition MsgHandler.h:305
std::string toString(const T &t, std::streamsize accuracy=gPrecision)
Definition ToString.h:46
GNEChange * undoList
undo list command (can be access by GNEUndoList)
const std::string myDescription
description of command
const Supermode myGroupSupermode
supermode associated with this ChangeGroup
const std::string & getTimeStamp()
get timeStamp
GUIIcon getGroupIcon() const
get icon associated with this ChangeGroup
std::string undoName() const
get undo Name
GNEChange * redoList
redo list command (can be access by GNEUndoList)
GNEChangeGroup * group
group (can be access by GNEUndoList)
int size() const
Return the size of the command group.
const GUIIcon myIcon
icon associated with this ChangeGroup
std::string redoName() const
get redo name
bool empty() const
Return TRUE if empty.
std::string myTimeStamp
timeStamp HH:MM:SS
const std::string & getDescription()
get description
Supermode getGroupSupermode() const
get supermode associated with this ChangeGroup
void redo()
Redo whole command group.
void undo()
Undo whole command group.
GNEChangeGroup()
FOX need this.
~GNEChangeGroup()
Delete undo command and sub-commands.
the function-object for an editing operation (abstract base)
Definition GNEChange.h:56
virtual void redo()=0
redo action/operation
virtual int size() const
Return the size of the command group.
Definition GNEChange.cpp:59
virtual void undo()=0
undo action/operation
GNEChange * next
Definition GNEChange.h:187
Definition json.hpp:4471