Introduction
Nf hist is a library which provides robust, low-overhead, automated data-change tracking.
Your Data Struct → [Reflection Magic] → Tracked Data Struct
auto smith = nf::make_tracked(Npc{.name = "Perrin", .hitpoints = 120});
smith()->hitpoints += 30;
assert(smith->hitpoints == 150);
smith.undo_action();
assert(smith->hitpoints == 120);
Use cases:
-
Track data changes without writing explicit tracking code
-
Enable undo-redo (and in future versions, time-travelling to previous states)
-
Have access to simple, opt-in listener methods for data changes
-
Enable replaying data changes from the start or from a previous state
-
Render data changes (e.g. for auditing or history UIs)
-
Facilitate programmatic traversal of data changes
-
(Future) Automatically stream history to file from a separate thread
-
(Future) Facilitate data-recovery after crashes
-
(Future) Enable data-change scripting
-
(Future) Stream/synchronize data changes (note: spec needs user-specific selections)
Technical features:
-
Minimal Data Usage: Only the minimum data required to remember the change & enable fast undo-redos is used, not the whole state of the object/sub-objects.
-
High Performance: Minimal allocations (individual ops don’t depend on allocations), no polymorphism or type erasure (strong types end-to-end via metaprogramming), copies & stack usage is minimized, unused features & checks excluded at compile time; many specialized ops
-
IDE & auto-complete friendly code: Reflection is used to create the tracked data structure in such a way that the user can use auto-complete and write code to edit their data structures the ~same as though it were their source structure