From 175f6cb5c131d0cfd5a2de8938ce1a6774252437 Mon Sep 17 00:00:00 2001 From: Faumaray Date: Mon, 20 Oct 2025 01:02:54 +0300 Subject: [PATCH] enforce ctx in constructor Signed-off-by: Faumaray --- include/Mod/Mod.hpp | 35 ++++------------------------------- 1 file changed, 4 insertions(+), 31 deletions(-) diff --git a/include/Mod/Mod.hpp b/include/Mod/Mod.hpp index f922e22..a4b0f73 100644 --- a/include/Mod/Mod.hpp +++ b/include/Mod/Mod.hpp @@ -5,30 +5,7 @@ #include #include #include -template -concept HasCtorWithContext = - requires(const vl::mod::Context& ctx) { - { T(ctx) }; - }; - -template -concept HasStaticName = - requires { - { T::Name() } -> std::same_as; - }; - -template -concept HasStaticVersion = - requires { - { T::Version() } -> std::same_as; - }; - -template -concept HasLifecycle = - requires(T obj) { - { obj.onStart() } -> std::same_as; - { obj.onStop() } -> std::same_as; - };namespace vl::mod { +namespace vl::mod { #if defined(__ELF__) #define VL_MOD_SECTION __attribute__((section("vlmods"), used)) @@ -39,13 +16,7 @@ concept HasLifecycle = // ---- Contract Concepts ---- -template < - class T -> requires - HasCtorWithContext && - HasStaticName && - HasStaticVersion && - HasLifecycle +template class Mod : public Base { private: static std::unique_ptr _vl_factory(const Context& ctx) { @@ -61,9 +32,11 @@ private: }; public: + Mod(const Context& ctx) : m_ctx(ctx){}; virtual void onStart() = 0; virtual void onStop() = 0; virtual ~Mod() = default; + Context m_ctx; // T provides: T(const Context&), onStart(), onStop() };