Enzo
Loading...
Searching...
No Matches
DeleteNodeCommand.h
1#pragma once
2
3#include "Engine/Core/Types.h"
4#include "Engine/Network/NetworkManager.h"
5#include "Engine/Network/NodeSnapshot.h"
6#include "Engine/UndoRedo/UndoCommand.h"
7
8namespace enzo::nt {
9
11{
12 public:
14 : nodeId_(nodeId), snapshot_(NodeSnapshot::capture(nm().getNode(nodeId)))
15 {
16 }
17
18 void undo() override { snapshot_.restore(nodeId_); }
19
20 void redo() override { nm().deleteNode(nodeId_); }
21
22 UndoCommandType type() const override { return UndoCommandType::DeleteNode; }
23
24 private:
25 NodeId nodeId_;
26 NodeSnapshot snapshot_;
27};
28
29} // namespace enzo::nt
Basic attribute, parameter, and node types for Enzo.
uint64_t NodeId
The unique ID assigned to each node in the network.
Definition Types.h:306
Definition DeleteNodeCommand.h:11
void deleteNode(NodeId nodeId)
Deletes a node, pushing an undo command.
Definition NetworkManager.cpp:52
Everything one node carries, held apart from the network so it can be rebuilt.
Definition NodeSnapshot.h:25
void restore(NodeId nodeId) const
Rebuilds the node under the given id with the path, position, and parameters it had.
Definition NodeSnapshot.cpp:22
static NodeSnapshot capture(Node &node)
Returns a snapshot of the node as it stands.
Definition NodeSnapshot.cpp:8
Definition UndoCommand.h:8