#pragma once #include #include #include #include #include #include namespace vl::mod { #if defined(__ELF__) #define VL_MOD_SECTION __attribute__((section("vlmods"), used)) #else #define VL_MOD_SECTION __attribute__((used)) #endif template class Mod : public Base { private: // ---- ENFORCE REQUIRED CONSTRUCTOR: T(const Context&) ---- static_assert( std::is_constructible_v, "Any class derived from Mod must have a constructor: T(const Context&)" ); // factory used by the registry static std::unique_ptr _vl_factory(const Context& ctx) { return std::make_unique(ctx); } // auto-registration record (ELF) static inline const Registration _vl_reg VL_MOD_SECTION { kModRegMagic, &_vl_factory, typeid(T).name() }; public: // ModBase behavior implemented by T through overrides }; } // namespace vl::log