diff --git a/include/cserver/engine/components.hpp b/include/cserver/engine/components.hpp index 6a52f9b..0470451 100644 --- a/include/cserver/engine/components.hpp +++ b/include/cserver/engine/components.hpp @@ -13,7 +13,11 @@ template struct Options : utempl::TypeList {}; template -struct ComponentConfig {}; +struct ComponentConfig { + using Type = T; + static constexpr auto kOptions = Options; + static constexpr auto kName = name; +}; namespace impl { @@ -142,6 +146,15 @@ inline constexpr auto InitComponents(T& ccontext) -> void { } // namespace impl +#define COMPONENT_REQUIRES(name, impl) \ + template \ + concept name = impl ; \ + template \ + struct name##M { \ + static constexpr auto value = name;\ + } + + template struct ServiceContext { static constexpr auto kNames = names; @@ -163,6 +176,27 @@ struct ServiceContext { constexpr auto I = utempl::Find(names, name); return *Get(this->storage); }; + template