8#include "factorylist.h"
23 template <
typename _FactoryEntries>
24 struct ComputeObjectList
26 using FactoryEntries = _FactoryEntries;
27 static constexpr size_t N = std::tuple_size_v<FactoryEntries>;
29 constexpr ComputeObjectList()
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>
44 using namespace Factory;
45 return ComputeObjectList<
typename filterList<conjunction<Preds...>, FactoryEntries>::type>{};
69 template <StringLiteral Name>
73 static_assert(MethodList::N == 1);
76 const MethodList list;
77 return std::get<0>(list.entries()).object;
100 template <
typename Func>
101 void foreach (Func&& fun)
103 std::apply([&](
auto&&... xs) { (fun(xs), ...); }, m_entries);
106 template <
typename Func>
107 void ApplyAt(
size_t index, Func&& fun)
112 this->
foreach ([&](
auto& x) {
118 template <
typename Func>
119 void ApplyAt(
const char* name, Func&& fun)
124 this->
foreach ([&](
auto& x) {
125 if (strcmp(name, x.name) == 0)
133 constexpr static size_t size() {
return N; }
140 return []<std::size_t... Is>(std::index_sequence<Is...>) {
141 return std::array{std::tuple_element_t<Is, FactoryEntries>::name...};
142 }(std::make_index_sequence<std::tuple_size_v<FactoryEntries>>{});
148 FactoryEntries&
entries() {
return m_entries; }
153 FactoryEntries
entries()
const {
return m_entries; }
156 FactoryEntries m_entries;
167 template <
typename _FactoryEntries>
170 using FactoryEntries = _FactoryEntries;
176 template <
template <
typename>
class... Preds>
179 return FullComputeObjectList::template
Filter<Preds...>();
188 return FullComputeObjectList::template
Filter<Names...>();
194 template <StringLiteral Name>
203 template <
typename Func>
204 static void foreach (Func&& fun)
206 FullComputeObjectList{}.foreach (std::forward<Func>(fun));
212 constexpr static size_t size() {
return FullComputeObjectList::N; }
228 template <
typename P,
typename NF, DiffType DerType>
242 template <
typename P,
typename NF, DiffType DerType>
257 template <
typename P,
typename NF, DiffType DerType>
Copyright (c) 2022 Jacques-Olivier Lachaud (jacques-olivier.lachaud@univ-savoie.fr) Laboratory of Mat...
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.
FactoryEntries entries() const
Return the list of entries.
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.
FactoryEntries & entries()
Return the list of entries.
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.