Change names in templates

This commit is contained in:
sha512sum 2024-03-24 21:09:46 +00:00
parent 0ed7c9cd75
commit d972d5e4e1

View file

@ -233,29 +233,29 @@ struct DependencyGraph {
}; };
template <ConstexprConfig config = {}, typename... Ts> template <ConstexprConfig config = {}, typename... ComponentConfigs>
struct ServiceContextBuilder { struct ServiceContextBuilder {
static constexpr auto kList = utempl::kTypeList<Ts...>; static constexpr auto kList = utempl::kTypeList<ComponentConfigs...>;
static constexpr auto kConfig = config; static constexpr auto kConfig = config;
template <typename T, utempl::ConstexprString name = T::kName, typename... Os> template <typename T, utempl::ConstexprString name = T::kName, typename... Os>
static consteval auto Append(Options<Os...> = {}) -> decltype(T::template Adder<name, Options<Os...>{}>(ServiceContextBuilder<config, Ts..., ComponentConfig<name, T, Options<Os...>{}>>{})) { static consteval auto Append(Options<Os...> = {}) -> decltype(T::template Adder<name, Options<Os...>{}>(ServiceContextBuilder<config, ComponentConfigs..., ComponentConfig<name, T, Options<Os...>{}>>{})) {
return {}; return {};
}; };
template <typename T, utempl::ConstexprString name = T::kName, typename... Os> template <typename T, utempl::ConstexprString name = T::kName, typename... Os>
static consteval auto Append(Options<Os...> = {}) -> ServiceContextBuilder<config, Ts..., ComponentConfig<name, T, Options<Os...>{}>> static consteval auto Append(Options<Os...> = {}) -> ServiceContextBuilder<config, ComponentConfigs..., ComponentConfig<name, T, Options<Os...>{}>>
requires (!requires(ServiceContextBuilder<config, Ts..., ComponentConfig<name, T, Options<Os...>{}>> builder) {T::template Adder<name, Options<Os...>{}>(builder);}) { requires (!requires(ServiceContextBuilder<config, ComponentConfigs..., ComponentConfig<name, T, Options<Os...>{}>> builder) {T::template Adder<name, Options<Os...>{}>(builder);}) {
return {}; return {};
}; };
template <utempl::ConstexprString Key, auto Value> template <utempl::ConstexprString Key, auto Value>
static consteval auto AppendConfigParam() -> ServiceContextBuilder<config.template Append<Key>(Value), Ts...> { static consteval auto AppendConfigParam() -> ServiceContextBuilder<config.template Append<Key>(Value), ComponentConfigs...> {
return {}; return {};
}; };
template <typename F> template <typename F>
static consteval auto TransformComponents(F&& f) -> ServiceContextBuilder<config, decltype(impl::TransformIfOk(Ts{}, f))...> { static consteval auto TransformComponents(F&& f) -> ServiceContextBuilder<config, decltype(impl::TransformIfOk(ComponentConfigs{}, f))...> {
return {}; return {};
}; };
template <utempl::ConstexprString name> template <utempl::ConstexprString name>
@ -264,7 +264,7 @@ struct ServiceContextBuilder {
(const ServiceContextBuilder<config, ComponentConfig<names, TTs, Options>...>&) (const ServiceContextBuilder<config, ComponentConfig<names, TTs, Options>...>&)
-> decltype(utempl::Get<Find<utempl::Wrapper<name>>(utempl::TypeList<utempl::Wrapper<names>...>{})>(utempl::TypeList<TTs...>{})) { -> decltype(utempl::Get<Find<utempl::Wrapper<name>>(utempl::TypeList<utempl::Wrapper<names>...>{})>(utempl::TypeList<TTs...>{})) {
std::unreachable(); std::unreachable();
}(ServiceContextBuilder<config, Ts...>{}); }(ServiceContextBuilder<config, ComponentConfigs...>{});
}; };
static consteval auto Config() { static consteval auto Config() {
@ -272,16 +272,16 @@ struct ServiceContextBuilder {
}; };
static consteval auto GetDependencyGraph() { static consteval auto GetDependencyGraph() {
return [&]<utempl::ConstexprString... names, typename... TTs, Options... Options> return [&]<utempl::ConstexprString... names, typename... Components, Options... Options>
(ComponentConfig<names, TTs, Options>...){ (ComponentConfig<names, Components, Options>...){
return DependencyGraph<DependencyGraphElement<TTs, return DependencyGraph<DependencyGraphElement<Components,
[]<utempl::ConstexprString name, typename T, ::cserver::Options OOptions> []<utempl::ConstexprString name, typename Component, ::cserver::Options OOptions>
(ComponentConfig<name, T, OOptions>) { (ComponentConfig<name, Component, OOptions>) {
impl::DependencyInfoInjector<T, config, Ts...> injector; impl::DependencyInfoInjector<Component, config, ComponentConfigs...> injector;
injector.template Inject<name>(); injector.template Inject<name>();
return injector.GetDependencies(); return injector.GetDependencies();
}(Ts{})>...>{}; }(ComponentConfigs{})>...>{};
}(Ts{}...); }(ComponentConfigs{}...);
}; };
@ -293,7 +293,7 @@ struct ServiceContextBuilder {
for(;;) { for(;;) {
std::this_thread::sleep_for(std::chrono::minutes(1)); std::this_thread::sleep_for(std::chrono::minutes(1));
}; };
}(utempl::TypeList<Ts...>{}); }(utempl::TypeList<ComponentConfigs...>{});
}; };
}; };
} // namespace cserver } // namespace cserver