31#ifndef DW_FRAMEWORK_PARAMETERDESCRIPTOR_HPP_
32#define DW_FRAMEWORK_PARAMETERDESCRIPTOR_HPP_
36#include <dw/core/container/StringView.hpp>
37#include <dw/core/language/Tuple.hpp>
60 return std::make_tuple();
76 return std::make_tuple(
78 static_cast<Argument1T*
>(
nullptr),
79 std::forward<const Arg1>(arg1)));
89 typename Argument1T,
typename Argument2T,
90 typename Arg1,
typename Arg2>
95 return std::make_tuple(
97 static_cast<Argument1T*
>(
nullptr),
98 std::forward<const Arg1>(arg1)),
100 static_cast<Argument2T*
>(
nullptr),
101 std::forward<const Arg2>(arg2)));
111 typename Argument1T,
typename Argument2T,
typename Argument3T,
112 typename Arg1,
typename Arg2,
typename Arg3>
117 return std::make_tuple(
119 static_cast<Argument1T*
>(
nullptr),
120 std::forward<const Arg1>(arg1)),
122 static_cast<Argument2T*
>(
nullptr),
123 std::forward<const Arg2>(arg2)),
125 static_cast<Argument3T*
>(
nullptr),
126 std::forward<const Arg3>(arg3)));
136 typename Argument1T,
typename Argument2T,
typename Argument3T,
typename Argument4T,
137 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4>
142 return std::make_tuple(
144 static_cast<Argument1T*
>(
nullptr),
145 std::forward<const Arg1>(arg1)),
147 static_cast<Argument2T*
>(
nullptr),
148 std::forward<const Arg2>(arg2)),
150 static_cast<Argument3T*
>(
nullptr),
151 std::forward<const Arg3>(arg3)),
153 static_cast<Argument4T*
>(
nullptr),
154 std::forward<const Arg4>(arg4)));
164 typename Argument1T,
typename Argument2T,
typename Argument3T,
typename Argument4T,
typename Argument5T,
165 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
typename Arg5>
170 return std::make_tuple(
172 static_cast<Argument1T*
>(
nullptr),
173 std::forward<const Arg1>(arg1)),
175 static_cast<Argument2T*
>(
nullptr),
176 std::forward<const Arg2>(arg2)),
178 static_cast<Argument3T*
>(
nullptr),
179 std::forward<const Arg3>(arg3)),
181 static_cast<Argument4T*
>(
nullptr),
182 std::forward<const Arg4>(arg4)),
184 static_cast<Argument5T*
>(
nullptr),
185 std::forward<const Arg5>(arg5)));
195 typename Argument1T,
typename Argument2T,
typename Argument3T,
typename Argument4T,
typename Argument5T,
typename Argument6T,
196 typename Arg1,
typename Arg2,
typename Arg3,
typename Arg4,
typename Arg5,
typename Arg6>
200constexpr auto describeConstructorArguments(
const Arg1&& arg1,
const Arg2&& arg2,
const Arg3&& arg3,
const Arg4&& arg4,
const Arg5&& arg5,
const Arg6&& arg6)
202 return std::make_tuple(
204 static_cast<Argument1T*
>(
nullptr),
205 std::forward<const Arg1>(arg1)),
207 static_cast<Argument2T*
>(
nullptr),
208 std::forward<const Arg2>(arg2)),
210 static_cast<Argument3T*
>(
nullptr),
211 std::forward<const Arg3>(arg3)),
213 static_cast<Argument4T*
>(
nullptr),
214 std::forward<const Arg4>(arg4)),
216 static_cast<Argument5T*
>(
nullptr),
217 std::forward<const Arg5>(arg5)),
219 static_cast<Argument6T*
>(
nullptr),
220 std::forward<const Arg6>(arg6)));
229template <
typename... Args>
232 return dw::core::make_tuple(
233 std::forward<const Args>(args)...);
265#define DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME_STR) TYPE_NAME_STR##_sv
266#define DW_DESCRIBE_PARAMETER(TYPE_NAME, args...) dw::framework::describeParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
267#define DW_DESCRIBE_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, args...) dw::framework::describeParameter<TYPE_NAME, SEMANTIC_TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
282template <
typename T,
typename S,
typename... MemberPointers>
284 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName,
const MemberPointers&&... memberPointers)
286 return std::make_tuple(
288 std::move(parameterName),
289 static_cast<T*
>(
nullptr),
290 static_cast<S*
>(
nullptr),
292 static_cast<size_t>(0),
294 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
300#define DW_DESCRIBE_ABSTRACT_PARAMETER(TYPE_NAME, args...) dw::framework::describeAbstractParameter<TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
301#define DW_DESCRIBE_ABSTRACT_ARRAY_PARAMETER(TYPE_NAME, args...) dw::framework::describeAbstractArrayParameter<TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
315 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName)
317 return std::make_tuple(
319 std::move(parameterName),
320 static_cast<T*
>(
nullptr),
321 static_cast<T*
>(
nullptr),
323 static_cast<size_t>(0));
333 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName,
size_t arraySize)
335 return std::make_tuple(
337 std::move(parameterName),
338 static_cast<T*
>(
nullptr),
339 static_cast<T*
>(
nullptr),
347#define DW_DESCRIBE_INDEX_PARAMETER(TYPE_NAME, args...) dw::framework::describeIndexParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
348#define DW_DESCRIBE_INDEX_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, args...) dw::framework::describeIndexParameter<TYPE_NAME, SEMANTIC_TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
361template <
typename T,
typename S,
typename... MemberPointers>
363 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName,
const MemberPointers&&... memberPointers)
365 return std::make_tuple(
367 std::move(parameterName),
368 static_cast<T*
>(
nullptr),
369 static_cast<S*
>(
nullptr),
371 static_cast<size_t>(0),
373 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
379#define DW_DESCRIBE_ARRAY_PARAMETER(TYPE_NAME, args...) dw::framework::describeArrayParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
380#define DW_DESCRIBE_ARRAY_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, args...) dw::framework::describeArrayParameter<TYPE_NAME, SEMANTIC_TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
392template <
typename T,
typename S,
typename... MemberPointers>
394 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName,
size_t arraySize,
const MemberPointers&&... memberPointers)
396 return std::make_tuple(
398 std::move(parameterName),
399 static_cast<T*
>(
nullptr),
400 static_cast<S*
>(
nullptr),
404 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
410#define DW_DESCRIBE_UNNAMED_PARAMETER(TYPE_NAME, args...) dw::framework::describeUnnamedParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
411#define DW_DESCRIBE_UNNAMED_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, args...) dw::framework::describeUnnamedParameter<TYPE_NAME, SEMANTIC_TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
424template <
typename T,
typename S,
typename... MemberPointers>
426 dw::core::StringView
const&& typeName,
const MemberPointers&&... memberPointers)
428 return describeParameter<T, S>(
431 std::forward<const MemberPointers>(memberPointers)...);
437#define DW_DESCRIBE_UNNAMED_ARRAY_PARAMETER(TYPE_NAME, args...) dw::framework::describeUnnamedArrayParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
438#define DW_DESCRIBE_UNNAMED_ARRAY_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, args...) dw::framework::describeUnnamedArrayParameter<TYPE_NAME, SEMANTIC_TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
451template <
typename T,
typename S,
typename... MemberPointers>
453 dw::core::StringView
const&& typeName,
size_t arraySize,
const MemberPointers&&... memberPointers)
455 return describeArrayParameter<T, S>(
459 std::forward<const MemberPointers>(memberPointers)...);
465#define DW_DESCRIBE_PARAMETER_WITH_DEFAULT(TYPE_NAME, args...) dw::framework::describeParameterWithDefault<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
477template <
typename T,
typename S,
typename... MemberPointers>
479 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName, T defaultValue,
const MemberPointers&&... memberPointers)
481 return std::make_tuple(
483 std::move(parameterName),
484 static_cast<T*
>(
nullptr),
485 static_cast<S*
>(
nullptr),
487 static_cast<size_t>(0),
489 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)),
490 std::move(defaultValue));
496#define DW_DESCRIBE_ARRAY_PARAMETER_WITH_DEFAULT(TYPE_NAME, args...) dw::framework::describeArrayParameterWithDefault<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
508template <
typename T,
typename S,
size_t ArraySize,
typename... MemberPointers>
510 dw::core::StringView
const&& typeName, dw::core::StringView
const&& parameterName, std::array<T, ArraySize> defaultValue,
const MemberPointers&&... memberPointers)
512 return std::make_tuple(
514 std::move(parameterName),
515 static_cast<T*
>(
nullptr),
516 static_cast<S*
>(
nullptr),
520 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)),
521 std::move(defaultValue));
525template <
typename NodeT>
536 typename Param,
typename MemberPtr,
538void populateDefault(
const Param& param, MemberPtr& memberPtr)
540 static_cast<void>(param);
541 static_cast<void>(memberPtr);
546 typename Param,
typename MemberPtr,
547 typename std::enable_if_t<PARAMETER_DEFAULT_VALUE<std::tuple_size<Param>(),
void>* =
nullptr>
550 void populateDefault(
const Param& param, MemberPtr& memberPtr)
552 auto defaultValue = std::get<PARAMETER_DEFAULT_VALUE>(param);
553 memberPtr = defaultValue;
558 typename Param,
typename MemberPtr,
560void populateArrayDefault(
const Param& param, MemberPtr& memberPtr,
size_t index)
562 static_cast<void>(param);
563 static_cast<void>(memberPtr);
564 static_cast<void>(index);
569 typename Param,
typename MemberPtr,
570 typename std::enable_if_t<PARAMETER_DEFAULT_VALUE<std::tuple_size<Param>(),
void>* =
nullptr>
573 void populateArrayDefault(
const Param& param, MemberPtr& memberPtr,
size_t index)
575 auto defaultValue = std::get<PARAMETER_DEFAULT_VALUE>(param);
576 memberPtr[index] = defaultValue[index];
581 size_t MemberIndex,
typename ArgType,
typename MemberPtrs,
582 typename std::enable_if_t<std::tuple_size<MemberPtrs>() == 0,
void>* =
nullptr>
583auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
585 static_cast<void>(memberPtrs);
591 size_t MemberIndex,
typename ArgType,
typename MemberPtrs,
592 typename std::enable_if_t<MemberIndex + 1 == std::tuple_size<MemberPtrs>(),
void>* =
nullptr>
595auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
597 auto member = std::get<MemberIndex>(memberPtrs);
603 size_t MemberIndex,
typename ArgType,
typename MemberPtrs,
604 typename std::enable_if_t<MemberIndex + 1 < std::tuple_size<MemberPtrs>(),
void>* =
nullptr>
607auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
609 auto& member = std::get<MemberIndex>(memberPtrs);
610 auto& m = arg.*member;
611 return getMemberPtr<MemberIndex + 1>(m, memberPtrs);
615template <
typename NodeT,
size_t ConstructorParameterIndex>
616constexpr size_t constructorArgumentParameterSize()
618 return dw::core::tuple_size<
619 std::tuple_element_t<
621 std::tuple_element_t<
622 ConstructorParameterIndex,
623 decltype(describeParameters<NodeT>())>>>();
628 typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex,
typename ArgType,
629 typename std::enable_if_t<ParamIndex == constructorArgumentParameterSize<NodeT, ConstructorParameterIndex>(),
void>* =
nullptr>
630void populateParametersRecursion(
const ParameterProvider& provider, ArgType& arg)
632 static_cast<void>(arg);
633 static_cast<void>(provider);
637template <
typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex>
638constexpr bool isIndexParameter()
640 constexpr auto param = dw::core::get<ParamIndex>(
641 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
642 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
643 return std::get<PARAMETER_IS_INDEX>(param);
647template <
typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex>
648constexpr bool isArrayParameter()
650 constexpr auto param = dw::core::get<ParamIndex>(
651 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
652 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
653 constexpr size_t arraySize = std::get<
655 return arraySize > 0;
659template <
typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex>
660constexpr bool isAbstractParameter()
662 constexpr auto param = dw::core::get<ParamIndex>(
663 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
664 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
670 typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex,
typename ArgType,
671 typename std::enable_if_t<isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>(),
void>* =
nullptr>
674void populateParameter(
const ParameterProvider& provider, ArgType& arg)
676 static_cast<void>(arg);
677 static_cast<void>(provider);
686 typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex,
typename ArgType,
687 typename std::enable_if_t<!isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && !isArrayParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && !isIndexParameter<NodeT, ConstructorParameterIndex, ParamIndex>(),
void>* =
nullptr>
690void populateParameter(
const ParameterProvider& provider, ArgType& arg)
692 constexpr auto param = dw::core::get<ParamIndex>(
693 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
694 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
696 using DataType = std::remove_pointer_t<
697 std::tuple_element_t<
699 using SemanticDataType = std::remove_pointer_t<
700 std::tuple_element_t<
703 DataType& memberPtr = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
704 bool hadParameter = provider.getOptional<SemanticDataType, DataType>(std::get<PARAMETER_NAME>(param), &memberPtr);
707 populateDefault(param, memberPtr);
717 typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex,
typename ArgType,
718 typename std::enable_if_t<!isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && !isArrayParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && isIndexParameter<NodeT, ConstructorParameterIndex, ParamIndex>(),
void>* =
nullptr>
721void populateParameter(
const ParameterProvider& provider, ArgType& arg)
723 constexpr auto param = dw::core::get<ParamIndex>(
724 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
725 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
727 using DataType = std::remove_pointer_t<
728 std::tuple_element_t<
730 using SemanticDataType = std::remove_pointer_t<
731 std::tuple_element_t<
733 DataType& memberPtr = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
735 size_t index =
static_cast<size_t>(-1);
736 bool hadParameter = provider.getOptional<size_t,
size_t>(std::get<PARAMETER_NAME>(param), &index);
739 hadParameter = provider.getOptional<SemanticDataType, DataType>(
"", index, &memberPtr);
743 populateDefault(param, memberPtr);
753 typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex,
typename ArgType,
754 typename std::enable_if_t<!isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && isArrayParameter<NodeT, ConstructorParameterIndex, ParamIndex>(),
void>* =
nullptr>
757void populateParameter(
const ParameterProvider& provider, ArgType& arg)
759 constexpr auto param = dw::core::get<ParamIndex>(
760 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
761 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
763 using DataType = std::remove_pointer_t<
764 std::tuple_element_t<
766 using SemanticDataType = std::remove_pointer_t<
767 std::tuple_element_t<
770 constexpr size_t arraySize = std::get<PARAMETER_ARRAY_SIZE>(
773 DataType(&memberPtr)[arraySize] = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
774 for (
size_t i = 0; i < arraySize; ++i)
776 bool hadParameter = provider.getOptional<SemanticDataType, DataType>(std::get<PARAMETER_NAME>(param), i, &memberPtr[i]);
779 populateArrayDefault(param, memberPtr, i);
786 typename NodeT,
size_t ConstructorParameterIndex,
size_t ParamIndex,
typename ArgType,
787 typename std::enable_if_t<ParamIndex<constructorArgumentParameterSize<NodeT, ConstructorParameterIndex>(),
void>* =
nullptr>
790 void populateParametersRecursion(
const ParameterProvider& provider, ArgType& arg)
792 populateParameter<NodeT, ConstructorParameterIndex, ParamIndex>(provider, arg);
794 populateParametersRecursion<NodeT, ConstructorParameterIndex, ParamIndex + 1>(provider, arg);
802template <
typename NodeT,
size_t ConstructorParameterIndex,
typename ArgType>
809 populateParametersRecursion<NodeT, ConstructorParameterIndex, 0>(provider, arg);
813 throw ExceptionWithStatus(e.status(),
"Exception while populating parameters of mangled node type ",
typeid(NodeT).name(),
": ", e.message());
822 class ConstructorArguments,
823 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 1,
void>* =
nullptr>
828 auto& arg0 = std::get<0>(constructorArguments);
829 detail::populateParameters<NodeT, 0>(provider, arg0);
835 class ConstructorArguments,
836 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 2,
void>* =
nullptr>
839void populateParameters(ConstructorArguments& constructorArguments,
const ParameterProvider& provider)
841 auto& arg0 = std::get<0>(constructorArguments);
842 detail::populateParameters<NodeT, 0>(provider, arg0);
843 auto& arg1 = std::get<1>(constructorArguments);
844 detail::populateParameters<NodeT, 1>(provider, arg1);
850 class ConstructorArguments,
851 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 3,
void>* =
nullptr>
854void populateParameters(ConstructorArguments& constructorArguments,
const ParameterProvider& provider)
856 auto& arg0 = std::get<0>(constructorArguments);
857 detail::populateParameters<NodeT, 0>(provider, arg0);
858 auto& arg1 = std::get<1>(constructorArguments);
859 detail::populateParameters<NodeT, 1>(provider, arg1);
860 auto& arg2 = std::get<2>(constructorArguments);
861 detail::populateParameters<NodeT, 2>(provider, arg2);
867 class ConstructorArguments,
868 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 4,
void>* =
nullptr>
871void populateParameters(ConstructorArguments& constructorArguments,
const ParameterProvider& provider)
873 auto& arg0 = std::get<0>(constructorArguments);
874 detail::populateParameters<NodeT, 0>(provider, arg0);
875 auto& arg1 = std::get<1>(constructorArguments);
876 detail::populateParameters<NodeT, 1>(provider, arg1);
877 auto& arg2 = std::get<2>(constructorArguments);
878 detail::populateParameters<NodeT, 2>(provider, arg2);
879 auto& arg3 = std::get<3>(constructorArguments);
880 detail::populateParameters<NodeT, 3>(provider, arg3);
886 class ConstructorArguments,
887 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 5,
void>* =
nullptr>
890void populateParameters(ConstructorArguments& constructorArguments,
const ParameterProvider& provider)
892 auto& arg0 = std::get<0>(constructorArguments);
893 detail::populateParameters<NodeT, 0>(provider, arg0);
894 auto& arg1 = std::get<1>(constructorArguments);
895 detail::populateParameters<NodeT, 1>(provider, arg1);
896 auto& arg2 = std::get<2>(constructorArguments);
897 detail::populateParameters<NodeT, 2>(provider, arg2);
898 auto& arg3 = std::get<3>(constructorArguments);
899 detail::populateParameters<NodeT, 3>(provider, arg3);
900 auto& arg4 = std::get<4>(constructorArguments);
901 detail::populateParameters<NodeT, 4>(provider, arg4);
907 class ConstructorArguments,
908 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 6,
void>* =
nullptr>
913void populateParameters(ConstructorArguments& constructorArguments,
const ParameterProvider& provider)
915 auto& arg0 = std::get<0>(constructorArguments);
916 detail::populateParameters<NodeT, 0>(provider, arg0);
917 auto& arg1 = std::get<1>(constructorArguments);
918 detail::populateParameters<NodeT, 1>(provider, arg1);
919 auto& arg2 = std::get<2>(constructorArguments);
920 detail::populateParameters<NodeT, 2>(provider, arg2);
921 auto& arg3 = std::get<3>(constructorArguments);
922 detail::populateParameters<NodeT, 3>(provider, arg3);
923 auto& arg4 = std::get<4>(constructorArguments);
924 detail::populateParameters<NodeT, 4>(provider, arg4);
925 auto& arg5 = std::get<5>(constructorArguments);
926 detail::populateParameters<NodeT, 5>(provider, arg5);
933template <
typename NodeT>
934constexpr std::size_t parameterConstructorArgumentSize()
936 return std::tuple_size<decltype(describeParameters<NodeT>())>::value;
941 typename NodeT,
size_t ConstructorArgumentIndex,
942 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(),
void>* =
nullptr>
947 return std::make_tuple();
952 typename NodeT,
size_t ConstructorArgumentIndex,
953 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(),
void>* =
nullptr>
958 using NodeParams =
decltype(describeParameters<NodeT>());
960 using ConstructorParameter = std::tuple_element_t<ConstructorArgumentIndex, NodeParams>;
961 using ArgType = std::remove_pointer_t<
962 typename std::tuple_element_t<PARAMETER_CONSTRUCTOR_ARGUMENT_TYPE, ConstructorParameter>>;
965 return std::tuple_cat(std::make_tuple(arg), createConstructorArguments<NodeT, ConstructorArgumentIndex + 1>());
971template <
typename NodeT>
974 return detail::createConstructorArguments<NodeT, 0>();
981template <
class T,
class Tuple,
size_t... Is>
984auto makeUniqueFromTuple(
const Tuple&& tuple, std::index_sequence<Is...>) -> std::unique_ptr<T>
986 return std::unique_ptr<T>(
new T{std::get<Is>(std::move(tuple))...});
991template <
typename NodeT,
class ConstructorArguments>
994 return detail::makeUniqueFromTuple<NodeT>(
995 std::move(constructorArguments),
996 std::make_index_sequence<std::tuple_size<std::decay_t<ConstructorArguments>>::value>{});
1007template <
typename NodeT>
1010 auto constructorArguments = createConstructorArguments<NodeT>();
1011 populateParameters<NodeT>(constructorArguments, provider);
1012 return makeUniqueFromTuple<NodeT>(std::move(constructorArguments));
1021 typename NodeT,
size_t ConstructorArgumentIndex,
1022 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(),
void>* =
nullptr>
1032 typename NodeT,
size_t ConstructorArgumentIndex,
1033 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(),
void>* =
nullptr>
1038 return constructorArgumentParameterSize<NodeT, ConstructorArgumentIndex>() + parameterSize<NodeT, ConstructorArgumentIndex + 1>();
1046template <
typename NodeT>
1049 return detail::parameterSize<NodeT, 0>();
The interface to access parameter values identified by name and/or (semantic) type.
constexpr auto describeArrayParameterWithDefault(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName, std::array< T, ArraySize > defaultValue, const MemberPointers &&... memberPointers)
constexpr auto describeAbstractParameter(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName)
static constexpr size_t PARAMETER_SEMANTIC_TYPE
auto makeUniqueFromTuple(const ConstructorArguments &&constructorArguments) -> std::unique_ptr< NodeT >
Instantiate a node using the passed constructor arguments.
static constexpr size_t PARAMETER_DEFAULT_VALUE
constexpr std::tuple describeConstructorArguments()
constexpr auto describeUnnamedArrayParameter(dw::core::StringView const &&typeName, size_t arraySize, const MemberPointers &&... memberPointers)
static constexpr size_t PARAMETER_MEMBER_PTRS
static constexpr size_t PARAMETER_NAME
constexpr auto describeUnnamedParameter(dw::core::StringView const &&typeName, const MemberPointers &&... memberPointers)
static constexpr size_t PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR
constexpr auto describeIndexParameter(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName, const MemberPointers &&... memberPointers)
auto createConstructorArguments()
Create a tuple of constructor argument needed by the constructor of the passed node.
static constexpr size_t PARAMETER_ARRAY_SIZE
constexpr auto describeParameter(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName, const MemberPointers &&... memberPointers)
constexpr auto describeAbstractArrayParameter(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName, size_t arraySize)
void populateParameters(ConstructorArguments &constructorArguments, const ParameterProvider &provider)
Populate the constructor arguments using values from the parameter provider.
constexpr auto describeParameters()
Get described parameters for the passed node.
static constexpr size_t PARAMETER_IS_INDEX
constexpr auto describeConstructorArgument(const Args &&... args)
constexpr std::size_t parameterSize()
Get the number of parameters for a given node.
constexpr auto describeArrayParameter(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName, size_t arraySize, const MemberPointers &&... memberPointers)
constexpr auto describeParameterWithDefault(dw::core::StringView const &&typeName, dw::core::StringView const &¶meterName, T defaultValue, const MemberPointers &&... memberPointers)
auto create(const ParameterProvider &provider) -> std::unique_ptr< NodeT >
static constexpr size_t PARAMETER_TYPE
static constexpr size_t PARAMETER_TYPE_NAME
static constexpr size_t PARAMETER_CONSTRUCTOR_ARGUMENT_TYPE