1#ifndef CAPYDI_DEPENDENCY_TAGS_HPP_
2#define CAPYDI_DEPENDENCY_TAGS_HPP_
9#include <initializer_list>
20template<CreationalConfig Decoratee, std::
size_t SIZE>
25 std::array<DependencyTagPair, SIZE> dependency_tags,
28 : dependency_tags_ { dependency_tags }
29 , decoratee_ { std::move(decoratee) }
41 template<
typename... Args>
44 return decoratee_.do_resolve(std::forward<Args>(args)...);
47 template<std::
size_t DependencyIndex>
50 using DecorateeDependenciesTuple
52 using ResultType =
decltype(std::tuple_cat(
53 std::declval<DecorateeDependenciesTuple>(),
54 std::declval<std::tuple<TagInput>>()
57 const auto found_tag_pair_itor = std::find_if(
58 this->dependency_tags_.cbegin(),
59 this->dependency_tags_.cend(),
61 return tag_pair.first == DependencyIndex;
65 if (found_tag_pair_itor == this->dependency_tags_.cend()) [[unlikely]]
67 return std::optional<ResultType> {
72 const auto& [_, found_tag] = *found_tag_pair_itor;
74 auto decoratee_dependencies_input
77 if (decoratee_dependencies_input.has_value()) [[likely]]
79 return std::optional { std::tuple_cat(
80 std::move(decoratee_dependencies_input).value(),
88 return std::optional { std::tuple_cat(
98 std::array<DependencyTagPair, SIZE> dependency_tags_;
106 template<CreationalConfig Decoratee, std::
size_t SIZE>
108 Decoratee&& decoratee,
109 std::array<DependencyTagPair, SIZE> dependency_tags
113 std::forward<Decoratee>(decoratee)
Concept and utilities for creational (factory/constructor) configurations.
Compile-time type pack utilities and metaprogramming foundations.
Definition DependencyTags.hpp:18
Definition Decorator.hpp:19
typename Config::DependenciesPack dependencies_pack_t
Definition CreationalConfig.hpp:82
typename Config::ResolutionKeysPack resolution_keys_pack_t
Helper alias to extract the resolution keys from a CreationalConfig.
Definition CreationalConfig.hpp:79
ConfigType
Categorization of configuration strategies in the DI container.
Definition ConfigType.hpp:24
@ CREATIONAL
Creational configs handle object instantiation and factory patterns. These are responsible for creati...
Definition ConfigType.hpp:27
std::pair< std::size_t, tag_t > DependencyTagPair
Definition DependencyTags.hpp:15
typename Config::CentralType central_type_t
Helper alias to extract the central type from a CreationalConfig.
Definition CreationalConfig.hpp:75