a tiny, single-header c++20 hot-reload plugin engine for linux.
it lets you swap out logic while your program is running without losing state. perfect for tools, game logic, or anything where you hate the compile-wait-restart loop.
- engine: watches a folder for
.sofiles. - module: a shared library you write.
- hot-swap: when you overwrite a
.sofile, the engine copies it (to avoid file locks), unloads the old one, and boots the new one. - persistence: there's a
PersistentStatemap passed to every module, so you can save variables and they'll still be there after the reload.
- drop
ndapl.hppinto your project. - implement the
IModuleinterface. - use the
NDAPL_EXPORT(YourClass)macro.
#include "ndapl.hpp"
class HelloModule : public ndapl::IModule {
public:
void on_load(ndapl::Context &ctx) override {
ctx.out << " [mod] hiiii (v1.0)\n";
auto val = ctx.state.get("ticks");
ctx.out << " [mod] persistent ticks: " << (val.empty() ? "0" : val) << "\n";
}
void on_unload(ndapl::Context &ctx) override {
auto val = ctx.state.get("ticks");
int n = val.empty() ? 0 : std::stoi(val);
ctx.state.set("ticks", std::to_string(n + 1));
ctx.out << " [mod] unloading...\n";
}
const char *name() const override { return "hello"; }
};
NDAPL_EXPORT(HelloModule)just link with -ldl. check the makefile in this repo for a quick template.