Skip to content

a tiny, single-header c++20 hot-reload plugin engine for linux

License

Notifications You must be signed in to change notification settings

obscurecomputer/ndapl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ndapl

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.

how it works

  • engine: watches a folder for .so files.
  • module: a shared library you write.
  • hot-swap: when you overwrite a .so file, the engine copies it (to avoid file locks), unloads the old one, and boots the new one.
  • persistence: there's a PersistentState map passed to every module, so you can save variables and they'll still be there after the reload.

how to use

  1. drop ndapl.hpp into your project.
  2. implement the IModule interface.
  3. use the NDAPL_EXPORT(YourClass) macro.

example module

#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)

building

just link with -ldl. check the makefile in this repo for a quick template.

license

apache2

About

a tiny, single-header c++20 hot-reload plugin engine for linux

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors