]> git.lizzy.rs Git - nothing.git/blob - src/game/level/level_editor/undo_history.h
bb671d123afbe16840872d4de33652c339b06bf1
[nothing.git] / src / game / level / level_editor / undo_history.h
1 #ifndef UNDO_HISTORY_H_
2 #define UNDO_HISTORY_H_
3
4 #include "stack.h"
5
6 typedef void (*RevertAction)(void *context, size_t context_size);
7
8 typedef struct {
9     Stack actions;
10 } UndoHistory;
11
12 static inline
13 void destroy_undo_history(UndoHistory undo_history)
14 {
15     destroy_stack(undo_history.actions);
16 }
17
18 void undo_history_push(UndoHistory *undo_history,
19                        RevertAction revert,
20                        void *context_data,
21                        size_t context_data_size);
22 void undo_history_pop(UndoHistory *undo_history);
23
24 static inline
25 int undo_history_empty(UndoHistory *undo_history)
26 {
27     return undo_history->actions.size == 0;
28 }
29
30 #endif  // UNDO_HISTORY_H_