8#include "factorylist.h"
23 template <
typename _FactoryEntries>
26 using FactoryEntries = _FactoryEntries;
27 static constexpr size_t N = std::tuple_size_v<FactoryEntries>;
30 : m_entries([]<std::size_t... Is>(std::index_sequence<Is...>) {
31 return FactoryEntries{std::tuple_element_t<Is, FactoryEntries>{Is}...};
32 }(std::make_index_sequence<std::tuple_size_v<FactoryEntries>>{}))
41 template <
template <
typename>
class... Preds>
45 return ComputeObjectList<
typename filterList<conjunction<Preds...>, FactoryEntries>::type>{};
56 return Filter<MethodProvider<Names>::template pred...>();
69 template <StringLiteral Name>
72 using MethodList =
decltype(Filter<MethodProvider<Name>::template pred>());
74 static_assert(std::tuple_size_v<typename MethodList::FactoryEntries> == 1);
75 return std::get<0>(
typename MethodList::FactoryEntries{0}).
object;
98 template <
typename Func>
99 void foreach (Func&& fun)
101 std::apply([&](
auto&&... xs) { (fun(xs), ...); }, m_entries);
104 template <
typename Func>
105 void ApplyAt(
size_t index, Func&& fun)
110 this->
foreach ([&](
auto& x) {
116 template <
typename Func>
117 void ApplyAt(
const char* name, Func&& fun)
122 this->
foreach ([&](
auto& x) {
123 if (strcmp(name, x.name) == 0)
131 constexpr static size_t size() {
return N; }
138 return []<std::size_t... Is>(std::index_sequence<Is...>) {
139 return std::array{std::tuple_element_t<Is, FactoryEntries>::name...};
140 }(std::make_index_sequence<std::tuple_size_v<FactoryEntries>>{});
144 FactoryEntries m_entries;
155 template <
typename _FactoryEntries>
158 using FactoryEntries = _FactoryEntries;
164 template <
template <
typename>
class... Preds>
167 return FullComputeObjectList::template
Filter<Preds...>();
176 return FullComputeObjectList::template
Filter<Names...>();
182 template <StringLiteral Name>
185 return FullComputeObjectList::template GetMethod<Name>();
191 template <
typename Func>
192 static void foreach (Func&& fun)
200 constexpr static size_t size() {
return FullComputeObjectList::N; }
216 template <
typename P,
typename NF, DiffType DerType>
230 template <
typename P,
typename NF, DiffType DerType>
245 template <
typename P,
typename NF, DiffType DerType>
This Source Code Form is subject to the terms of the Mozilla Public License, v.
@ FitSpaceDer
Flag indicating a space differentiation.
Default factory templated on Point, Filter and Derivative.
StringLiteral as template parameters.
List of compute object that can be iterated over.
static constexpr size_t size()
Return the number of object held within the object.
static decltype(auto) Filter()
Returns a new object that is a filtered version of the current one.
static constexpr decltype(auto) GetNames()
Return the names of the currently held objects.
static decltype(auto) GetMethod()
Return an object by it's id.
void foreach(Func &&fun)
Applies a function to each entry of the list.
static constexpr decltype(auto) GetNames()
Return the names of the currently held objects.
static decltype(auto) Filter()
Returns a new object that is a filtered version of the current one.
static decltype(auto) GetMethod()
Return an object by it's id.
static constexpr size_t size()
Return the number of object held within the Factory.