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