• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.8
    All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
    ParameterDescriptor.hpp
    Go to the documentation of this file.
    1
    2//
    3// Notice
    4// ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES
    5// NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO
    6// THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT,
    7// MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
    8//
    9// NVIDIA CORPORATION & AFFILIATES assumes no responsibility for the consequences of use of such
    10// information or for any infringement of patents or other rights of third parties that may
    11// result from its use. No license is granted by implication or otherwise under any patent
    12// or patent rights of NVIDIA CORPORATION & AFFILIATES. No third party distribution is allowed unless
    13// expressly authorized by NVIDIA. Details are subject to change without notice.
    14// This code supersedes and replaces all information previously supplied.
    15// NVIDIA CORPORATION & AFFILIATES products are not authorized for use as critical
    16// components in life support devices or systems without express written approval of
    17// NVIDIA CORPORATION & AFFILIATES.
    18//
    19// SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
    20// SPDX-License-Identifier: LicenseRef-NvidiaProprietary
    21//
    22// NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
    23// property and proprietary rights in and to this material, related
    24// documentation and any modifications thereto. Any use, reproduction,
    25// disclosure or distribution of this material and related documentation
    26// without an express license agreement from NVIDIA CORPORATION or
    27// its affiliates is strictly prohibited.
    28//
    30
    31#ifndef DW_FRAMEWORK_PARAMETERDESCRIPTOR_HPP_
    32#define DW_FRAMEWORK_PARAMETERDESCRIPTOR_HPP_
    33
    36#include <dw/core/container/StringView.hpp>
    37#include <dw/core/language/Tuple.hpp>
    38
    39namespace dw
    40{
    41namespace framework
    42{
    43
    44// Indices within the tuple describing constructor arguments
    45// coverity[autosar_cpp14_a0_1_1_violation]
    46// coverity[autosar_cpp14_m0_1_4_violation]
    47static constexpr size_t PARAMETER_CONSTRUCTOR_ARGUMENT_TYPE{0U};
    48// coverity[autosar_cpp14_a0_1_1_violation]
    49// coverity[autosar_cpp14_m0_1_4_violation]
    51
    58constexpr std::tuple<> describeConstructorArguments()
    59{
    60 return std::make_tuple();
    61}
    62
    69template <
    70 typename Argument1T,
    71 typename Arg1>
    72// Overloaded functions are provided for ease of use
    73// coverity[autosar_cpp14_a2_10_5_violation]
    74constexpr auto describeConstructorArguments(const Arg1&& arg1)
    75{
    76 return std::make_tuple(
    77 std::make_tuple(
    78 static_cast<Argument1T*>(nullptr),
    79 std::forward<const Arg1>(arg1)));
    80}
    81
    88template <
    89 typename Argument1T, typename Argument2T,
    90 typename Arg1, typename Arg2>
    91// Overloaded functions are provided for ease of use
    92// coverity[autosar_cpp14_a2_10_5_violation]
    93constexpr auto describeConstructorArguments(const Arg1&& arg1, const Arg2&& arg2)
    94{
    95 return std::make_tuple(
    96 std::make_tuple(
    97 static_cast<Argument1T*>(nullptr),
    98 std::forward<const Arg1>(arg1)),
    99 std::make_tuple(
    100 static_cast<Argument2T*>(nullptr),
    101 std::forward<const Arg2>(arg2)));
    102}
    103
    110template <
    111 typename Argument1T, typename Argument2T, typename Argument3T,
    112 typename Arg1, typename Arg2, typename Arg3>
    113// Overloaded functions are provided for ease of use
    114// coverity[autosar_cpp14_a2_10_5_violation]
    115constexpr auto describeConstructorArguments(const Arg1&& arg1, const Arg2&& arg2, const Arg3&& arg3)
    116{
    117 return std::make_tuple(
    118 std::make_tuple(
    119 static_cast<Argument1T*>(nullptr),
    120 std::forward<const Arg1>(arg1)),
    121 std::make_tuple(
    122 static_cast<Argument2T*>(nullptr),
    123 std::forward<const Arg2>(arg2)),
    124 std::make_tuple(
    125 static_cast<Argument3T*>(nullptr),
    126 std::forward<const Arg3>(arg3)));
    127}
    128
    135template <
    136 typename Argument1T, typename Argument2T, typename Argument3T, typename Argument4T,
    137 typename Arg1, typename Arg2, typename Arg3, typename Arg4>
    138// Overloaded functions are provided for ease of use
    139// coverity[autosar_cpp14_a2_10_5_violation]
    140constexpr auto describeConstructorArguments(const Arg1&& arg1, const Arg2&& arg2, const Arg3&& arg3, const Arg4&& arg4)
    141{
    142 return std::make_tuple(
    143 std::make_tuple(
    144 static_cast<Argument1T*>(nullptr),
    145 std::forward<const Arg1>(arg1)),
    146 std::make_tuple(
    147 static_cast<Argument2T*>(nullptr),
    148 std::forward<const Arg2>(arg2)),
    149 std::make_tuple(
    150 static_cast<Argument3T*>(nullptr),
    151 std::forward<const Arg3>(arg3)),
    152 std::make_tuple(
    153 static_cast<Argument4T*>(nullptr),
    154 std::forward<const Arg4>(arg4)));
    155}
    156
    163template <
    164 typename Argument1T, typename Argument2T, typename Argument3T, typename Argument4T, typename Argument5T,
    165 typename Arg1, typename Arg2, typename Arg3, typename Arg4, typename Arg5>
    166// Overloaded functions are provided for ease of use
    167// coverity[autosar_cpp14_a2_10_5_violation]
    168constexpr auto describeConstructorArguments(const Arg1&& arg1, const Arg2&& arg2, const Arg3&& arg3, const Arg4&& arg4, const Arg5&& arg5)
    169{
    170 return std::make_tuple(
    171 std::make_tuple(
    172 static_cast<Argument1T*>(nullptr),
    173 std::forward<const Arg1>(arg1)),
    174 std::make_tuple(
    175 static_cast<Argument2T*>(nullptr),
    176 std::forward<const Arg2>(arg2)),
    177 std::make_tuple(
    178 static_cast<Argument3T*>(nullptr),
    179 std::forward<const Arg3>(arg3)),
    180 std::make_tuple(
    181 static_cast<Argument4T*>(nullptr),
    182 std::forward<const Arg4>(arg4)),
    183 std::make_tuple(
    184 static_cast<Argument5T*>(nullptr),
    185 std::forward<const Arg5>(arg5)));
    186}
    187
    194template <typename... Args>
    195constexpr auto describeConstructorArgument(const Args&&... args)
    196{
    197 return dw::core::make_tuple(
    198 std::forward<const Args>(args)...);
    199}
    200
    201// Indices within the tuple describing parameters
    202// coverity[autosar_cpp14_a0_1_1_violation]
    203// coverity[autosar_cpp14_m0_1_4_violation]
    204static constexpr size_t PARAMETER_TYPE_NAME{0U};
    205// coverity[autosar_cpp14_a0_1_1_violation]
    206// coverity[autosar_cpp14_m0_1_4_violation]
    207static constexpr size_t PARAMETER_NAME{1U};
    208// coverity[autosar_cpp14_a0_1_1_violation]
    209// coverity[autosar_cpp14_m0_1_4_violation]
    210static constexpr size_t PARAMETER_TYPE{2U};
    211// coverity[autosar_cpp14_a0_1_1_violation]
    212// coverity[autosar_cpp14_m0_1_4_violation]
    213static constexpr size_t PARAMETER_SEMANTIC_TYPE{3U};
    214// coverity[autosar_cpp14_a0_1_1_violation]
    215// coverity[autosar_cpp14_m0_1_4_violation]
    216static constexpr size_t PARAMETER_IS_INDEX{4U};
    217// coverity[autosar_cpp14_a0_1_1_violation]
    218// coverity[autosar_cpp14_m0_1_4_violation]
    219static constexpr size_t PARAMETER_ARRAY_SIZE{5U};
    220// coverity[autosar_cpp14_a0_1_1_violation]
    221// coverity[autosar_cpp14_m0_1_4_violation]
    222static constexpr size_t PARAMETER_MEMBER_PTRS{6U};
    223// coverity[autosar_cpp14_a0_1_1_violation]
    224// coverity[autosar_cpp14_m0_1_4_violation]
    225static constexpr size_t PARAMETER_DEFAULT_VALUE{7U};
    226
    227} // namespace framework
    228} // namespace dw
    229
    230#define DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME_STR) TYPE_NAME_STR##_sv
    231#define DW_DESCRIBE_PARAMETER(TYPE_NAME, args...) dw::framework::describeParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
    232#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)
    233
    234namespace dw
    235{
    236namespace framework
    237{
    238
    247template <typename T, typename S, typename... MemberPointers>
    248constexpr auto describeParameter(
    249 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, const MemberPointers&&... memberPointers)
    250{
    251 return std::make_tuple(
    252 std::move(typeName),
    253 std::move(parameterName),
    254 static_cast<T*>(nullptr),
    255 static_cast<S*>(nullptr),
    256 false,
    257 static_cast<size_t>(0),
    258 std::move(
    259 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
    260}
    261
    262} // namespace framework
    263} // namespace dw
    264
    265#define DW_DESCRIBE_ABSTRACT_PARAMETER(TYPE_NAME, args...) dw::framework::describeAbstractParameter<TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
    266#define DW_DESCRIBE_ABSTRACT_ARRAY_PARAMETER(TYPE_NAME, args...) dw::framework::describeAbstractArrayParameter<TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
    267
    268namespace dw
    269{
    270namespace framework
    271{
    272
    278template <typename T>
    280 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName)
    281{
    282 return std::make_tuple(
    283 std::move(typeName),
    284 std::move(parameterName),
    285 static_cast<T*>(nullptr),
    286 static_cast<T*>(nullptr),
    287 false,
    288 static_cast<size_t>(0));
    289}
    290
    296template <typename T>
    298 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, size_t arraySize)
    299{
    300 return std::make_tuple(
    301 std::move(typeName),
    302 std::move(parameterName),
    303 static_cast<T*>(nullptr),
    304 static_cast<T*>(nullptr),
    305 false,
    306 arraySize);
    307}
    308
    309} // namespace framework
    310} // namespace dw
    311
    312#define DW_DESCRIBE_INDEX_PARAMETER(TYPE_NAME, args...) dw::framework::describeIndexParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
    313#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)
    314
    315namespace dw
    316{
    317namespace framework
    318{
    319
    326template <typename T, typename S, typename... MemberPointers>
    328 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, const MemberPointers&&... memberPointers)
    329{
    330 return std::make_tuple(
    331 std::move(typeName),
    332 std::move(parameterName),
    333 static_cast<T*>(nullptr),
    334 static_cast<S*>(nullptr),
    335 true,
    336 static_cast<size_t>(0),
    337 std::move(
    338 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
    339}
    340
    341} // namespace framework
    342} // namespace dw
    343
    344#define DW_DESCRIBE_ARRAY_PARAMETER(TYPE_NAME, args...) dw::framework::describeArrayParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
    345#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)
    346
    347namespace dw
    348{
    349namespace framework
    350{
    351
    357template <typename T, typename S, typename... MemberPointers>
    359 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, size_t arraySize, const MemberPointers&&... memberPointers)
    360{
    361 return std::make_tuple(
    362 std::move(typeName),
    363 std::move(parameterName),
    364 static_cast<T*>(nullptr),
    365 static_cast<S*>(nullptr),
    366 false,
    367 arraySize,
    368 std::move(
    369 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
    370}
    371
    372} // namespace framework
    373} // namespace dw
    374
    375#define DW_DESCRIBE_UNNAMED_PARAMETER(TYPE_NAME, args...) dw::framework::describeUnnamedParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(#TYPE_NAME), ##args)
    376#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)
    377
    378namespace dw
    379{
    380namespace framework
    381{
    382
    389template <typename T, typename S, typename... MemberPointers>
    391 dw::core::StringView const&& typeName, const MemberPointers&&... memberPointers)
    392{
    393 return describeParameter<T, S>(
    394 std::move(typeName),
    395 ""_sv,
    396 std::forward<const MemberPointers>(memberPointers)...);
    397}
    398
    399} // namespace framework
    400} // namespace dw
    401
    402#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)
    403#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)
    404
    405namespace dw
    406{
    407namespace framework
    408{
    409
    416template <typename T, typename S, typename... MemberPointers>
    418 dw::core::StringView const&& typeName, size_t arraySize, const MemberPointers&&... memberPointers)
    419{
    420 return describeArrayParameter<T, S>(
    421 std::move(typeName),
    422 ""_sv,
    423 arraySize,
    424 std::forward<const MemberPointers>(memberPointers)...);
    425}
    426
    427} // namespace framework
    428} // namespace dw
    429
    430#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)
    431
    432namespace dw
    433{
    434namespace framework
    435{
    436
    442template <typename T, typename S, typename... MemberPointers>
    444 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, T defaultValue, const MemberPointers&&... memberPointers)
    445{
    446 return std::make_tuple(
    447 std::move(typeName),
    448 std::move(parameterName),
    449 static_cast<T*>(nullptr),
    450 static_cast<S*>(nullptr),
    451 false,
    452 static_cast<size_t>(0),
    453 std::move(
    454 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)),
    455 std::move(defaultValue));
    456}
    457
    458} // namespace framework
    459} // namespace dw
    460
    461#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)
    462
    463namespace dw
    464{
    465namespace framework
    466{
    467
    473template <typename T, typename S, size_t ArraySize, typename... MemberPointers>
    475 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, std::array<T, ArraySize> defaultValue, const MemberPointers&&... memberPointers)
    476{
    477 return std::make_tuple(
    478 std::move(typeName),
    479 std::move(parameterName),
    480 static_cast<T*>(nullptr),
    481 static_cast<S*>(nullptr),
    482 false,
    483 ArraySize,
    484 std::move(
    485 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)),
    486 std::move(defaultValue));
    487}
    488
    490template <typename NodeT>
    491constexpr auto describeParameters()
    492{
    494}
    495
    496namespace detail
    497{
    498
    500template <
    501 typename Param, typename MemberPtr,
    502 typename std::enable_if_t<std::tuple_size<Param>() <= PARAMETER_DEFAULT_VALUE, void>* = nullptr>
    503void populateDefault(const Param& param, MemberPtr& memberPtr)
    504{
    505 static_cast<void>(param);
    506 static_cast<void>(memberPtr);
    507}
    508
    510template <
    511 typename Param, typename MemberPtr,
    512 typename std::enable_if_t<PARAMETER_DEFAULT_VALUE<std::tuple_size<Param>(), void>* = nullptr>
    513 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    514 // coverity[autosar_cpp14_a2_10_5_violation]
    515 void populateDefault(const Param& param, MemberPtr& memberPtr)
    516{
    517 auto defaultValue = std::get<PARAMETER_DEFAULT_VALUE>(param);
    518 memberPtr = defaultValue;
    519}
    520
    522template <
    523 typename Param, typename MemberPtr,
    524 typename std::enable_if_t<std::tuple_size<Param>() <= PARAMETER_DEFAULT_VALUE, void>* = nullptr>
    525void populateArrayDefault(const Param& param, MemberPtr& memberPtr, size_t index)
    526{
    527 static_cast<void>(param);
    528 static_cast<void>(memberPtr);
    529 static_cast<void>(index);
    530}
    531
    533template <
    534 typename Param, typename MemberPtr,
    535 typename std::enable_if_t<PARAMETER_DEFAULT_VALUE<std::tuple_size<Param>(), void>* = nullptr>
    536 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    537 // coverity[autosar_cpp14_a2_10_5_violation]
    538 void populateArrayDefault(const Param& param, MemberPtr& memberPtr, size_t index)
    539{
    540 auto defaultValue = std::get<PARAMETER_DEFAULT_VALUE>(param);
    541 memberPtr[index] = defaultValue[index];
    542}
    543
    545template <
    546 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    547 typename std::enable_if_t<std::tuple_size<MemberPtrs>() == 0, void>* = nullptr>
    548auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    549{
    550 static_cast<void>(memberPtrs);
    551 return arg;
    552}
    553
    555template <
    556 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    557 typename std::enable_if_t<MemberIndex + 1 == std::tuple_size<MemberPtrs>(), void>* = nullptr>
    558// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    559// coverity[autosar_cpp14_a2_10_5_violation]
    560auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    561{
    562 auto member = std::get<MemberIndex>(memberPtrs);
    563 return arg.*member;
    564}
    565
    567template <
    568 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    569 typename std::enable_if_t<MemberIndex + 1 < std::tuple_size<MemberPtrs>(), void>* = nullptr>
    570// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    571// coverity[autosar_cpp14_a2_10_5_violation]
    572auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    573{
    574 auto& member = std::get<MemberIndex>(memberPtrs);
    575 auto& m = arg.*member;
    576 return getMemberPtr<MemberIndex + 1>(m, memberPtrs);
    577}
    578
    580template <typename NodeT, size_t ConstructorParameterIndex>
    581constexpr size_t constructorArgumentParameterSize()
    582{
    583 return dw::core::tuple_size<
    584 std::tuple_element_t<
    586 std::tuple_element_t<
    587 ConstructorParameterIndex,
    588 decltype(describeParameters<NodeT>())>>>();
    589}
    590
    592template <
    593 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    594 typename std::enable_if_t<ParamIndex == constructorArgumentParameterSize<NodeT, ConstructorParameterIndex>(), void>* = nullptr>
    595void populateParametersRecursion(const ParameterProvider& provider, ArgType& arg)
    596{
    597 static_cast<void>(arg);
    598 static_cast<void>(provider);
    599}
    600
    602template <typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex>
    603constexpr bool isIndexParameter()
    604{
    605 constexpr auto param = dw::core::get<ParamIndex>(
    606 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    607 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    608 return std::get<PARAMETER_IS_INDEX>(param);
    609}
    610
    612template <typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex>
    613constexpr bool isArrayParameter()
    614{
    615 constexpr auto param = dw::core::get<ParamIndex>(
    616 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    617 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    618 constexpr size_t arraySize = std::get<
    619 PARAMETER_ARRAY_SIZE>(param);
    620 return arraySize > 0;
    621}
    622
    624template <typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex>
    625constexpr bool isAbstractParameter()
    626{
    627 constexpr auto param = dw::core::get<ParamIndex>(
    628 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    629 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    630 return std::tuple_size<decltype(param)>() <= PARAMETER_MEMBER_PTRS;
    631}
    632
    634template <
    635 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    636 typename std::enable_if_t<isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>(), void>* = nullptr>
    637// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    638// coverity[autosar_cpp14_a2_10_5_violation]
    639void populateParameter(const ParameterProvider& provider, ArgType& arg)
    640{
    641 static_cast<void>(arg);
    642 static_cast<void>(provider);
    643}
    644
    650template <
    651 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    652 typename std::enable_if_t<!isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && !isArrayParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && !isIndexParameter<NodeT, ConstructorParameterIndex, ParamIndex>(), void>* = nullptr>
    653// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    654// coverity[autosar_cpp14_a2_10_5_violation]
    655void populateParameter(const ParameterProvider& provider, ArgType& arg)
    656{
    657 constexpr auto param = dw::core::get<ParamIndex>(
    658 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    659 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    660
    661 using DataType = std::remove_pointer_t<
    662 std::tuple_element_t<
    663 PARAMETER_TYPE, decltype(param)>>;
    664 using SemanticDataType = std::remove_pointer_t<
    665 std::tuple_element_t<
    666 PARAMETER_SEMANTIC_TYPE, decltype(param)>>;
    667
    668 DataType& memberPtr = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
    669 bool hadParameter = provider.getOptional<SemanticDataType, DataType>(std::get<PARAMETER_NAME>(param), &memberPtr);
    670 if (!hadParameter)
    671 {
    672 populateDefault(param, memberPtr);
    673 }
    674}
    675
    681template <
    682 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    683 typename std::enable_if_t<!isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && !isArrayParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && isIndexParameter<NodeT, ConstructorParameterIndex, ParamIndex>(), void>* = nullptr>
    684// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    685// coverity[autosar_cpp14_a2_10_5_violation]
    686void populateParameter(const ParameterProvider& provider, ArgType& arg)
    687{
    688 constexpr auto param = dw::core::get<ParamIndex>(
    689 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    690 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    691
    692 using DataType = std::remove_pointer_t<
    693 std::tuple_element_t<
    694 PARAMETER_TYPE, decltype(param)>>;
    695 using SemanticDataType = std::remove_pointer_t<
    696 std::tuple_element_t<
    697 PARAMETER_SEMANTIC_TYPE, decltype(param)>>;
    698 DataType& memberPtr = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
    699
    700 size_t index = static_cast<size_t>(-1);
    701 bool hadParameter = provider.getOptional<size_t, size_t>(std::get<PARAMETER_NAME>(param), &index);
    702 if (hadParameter)
    703 {
    704 hadParameter = provider.getOptional<SemanticDataType, DataType>("", index, &memberPtr);
    705 }
    706 if (!hadParameter)
    707 {
    708 populateDefault(param, memberPtr);
    709 }
    710}
    711
    717template <
    718 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    719 typename std::enable_if_t<!isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>() && isArrayParameter<NodeT, ConstructorParameterIndex, ParamIndex>(), void>* = nullptr>
    720// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    721// coverity[autosar_cpp14_a2_10_5_violation]
    722void populateParameter(const ParameterProvider& provider, ArgType& arg)
    723{
    724 constexpr auto param = dw::core::get<ParamIndex>(
    725 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    726 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    727
    728 using DataType = std::remove_pointer_t<
    729 std::tuple_element_t<
    730 PARAMETER_TYPE, decltype(param)>>;
    731 using SemanticDataType = std::remove_pointer_t<
    732 std::tuple_element_t<
    733 PARAMETER_SEMANTIC_TYPE, decltype(param)>>;
    734
    735 constexpr size_t arraySize = std::get<PARAMETER_ARRAY_SIZE>(
    736 param);
    737
    738 DataType(&memberPtr)[arraySize] = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
    739 for (size_t i = 0; i < arraySize; ++i)
    740 {
    741 bool hadParameter = provider.getOptional<SemanticDataType, DataType>(std::get<PARAMETER_NAME>(param), i, &memberPtr[i]);
    742 if (!hadParameter)
    743 {
    744 populateArrayDefault(param, memberPtr, i);
    745 }
    746 }
    747}
    748
    750template <
    751 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    752 typename std::enable_if_t<ParamIndex<constructorArgumentParameterSize<NodeT, ConstructorParameterIndex>(), void>* = nullptr>
    753 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    754 // coverity[autosar_cpp14_a2_10_5_violation]
    755 void populateParametersRecursion(const ParameterProvider& provider, ArgType& arg)
    756{
    757 populateParameter<NodeT, ConstructorParameterIndex, ParamIndex>(provider, arg);
    758
    759 populateParametersRecursion<NodeT, ConstructorParameterIndex, ParamIndex + 1>(provider, arg);
    760}
    761
    767template <typename NodeT, size_t ConstructorParameterIndex, typename ArgType>
    768// TODO(dwplc): FP -- The other populateParameters() functions are defined in the parent namespace
    769// coverity[autosar_cpp14_a2_10_5_violation]
    770void populateParameters(const ParameterProvider& provider, ArgType& arg)
    771{
    772 try
    773 {
    774 populateParametersRecursion<NodeT, ConstructorParameterIndex, 0>(provider, arg);
    775 }
    776 catch (Exception& e)
    777 {
    778 throw Exception(e.status(), "Exception while populating parameters of mangled node type ", typeid(NodeT).name(), ": ", e.messageStr());
    779 }
    780}
    781
    782} // namespace detail
    783
    785template <
    786 typename NodeT,
    787 class ConstructorArguments,
    788 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 1, void>* = nullptr>
    789// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    790// coverity[autosar_cpp14_a2_10_5_violation]
    791void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    792{
    793 auto& arg0 = std::get<0>(constructorArguments);
    794 detail::populateParameters<NodeT, 0>(provider, arg0);
    795}
    796
    798template <
    799 typename NodeT,
    800 class ConstructorArguments,
    801 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 2, void>* = nullptr>
    802// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    803// coverity[autosar_cpp14_a2_10_5_violation]
    804void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    805{
    806 auto& arg0 = std::get<0>(constructorArguments);
    807 detail::populateParameters<NodeT, 0>(provider, arg0);
    808 auto& arg1 = std::get<1>(constructorArguments);
    809 detail::populateParameters<NodeT, 1>(provider, arg1);
    810}
    811
    813template <
    814 typename NodeT,
    815 class ConstructorArguments,
    816 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 3, void>* = nullptr>
    817// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    818// coverity[autosar_cpp14_a2_10_5_violation]
    819void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    820{
    821 auto& arg0 = std::get<0>(constructorArguments);
    822 detail::populateParameters<NodeT, 0>(provider, arg0);
    823 auto& arg1 = std::get<1>(constructorArguments);
    824 detail::populateParameters<NodeT, 1>(provider, arg1);
    825 auto& arg2 = std::get<2>(constructorArguments);
    826 detail::populateParameters<NodeT, 2>(provider, arg2);
    827}
    828
    830template <
    831 typename NodeT,
    832 class ConstructorArguments,
    833 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 4, void>* = nullptr>
    834// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    835// coverity[autosar_cpp14_a2_10_5_violation]
    836void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    837{
    838 auto& arg0 = std::get<0>(constructorArguments);
    839 detail::populateParameters<NodeT, 0>(provider, arg0);
    840 auto& arg1 = std::get<1>(constructorArguments);
    841 detail::populateParameters<NodeT, 1>(provider, arg1);
    842 auto& arg2 = std::get<2>(constructorArguments);
    843 detail::populateParameters<NodeT, 2>(provider, arg2);
    844 auto& arg3 = std::get<3>(constructorArguments);
    845 detail::populateParameters<NodeT, 3>(provider, arg3);
    846}
    847
    849template <
    850 typename NodeT,
    851 class ConstructorArguments,
    852 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 5, void>* = nullptr>
    853// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    854// coverity[autosar_cpp14_a2_10_5_violation]
    855void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    856{
    857 auto& arg0 = std::get<0>(constructorArguments);
    858 detail::populateParameters<NodeT, 0>(provider, arg0);
    859 auto& arg1 = std::get<1>(constructorArguments);
    860 detail::populateParameters<NodeT, 1>(provider, arg1);
    861 auto& arg2 = std::get<2>(constructorArguments);
    862 detail::populateParameters<NodeT, 2>(provider, arg2);
    863 auto& arg3 = std::get<3>(constructorArguments);
    864 detail::populateParameters<NodeT, 3>(provider, arg3);
    865 auto& arg4 = std::get<4>(constructorArguments);
    866 detail::populateParameters<NodeT, 4>(provider, arg4);
    867}
    868
    869namespace detail
    870{
    871
    872// Get the Number of constructor arguments of the passed node.
    873template <typename NodeT>
    874constexpr std::size_t parameterConstructorArgumentSize()
    875{
    876 return std::tuple_size<decltype(describeParameters<NodeT>())>::value;
    877}
    878
    880template <
    881 typename NodeT, size_t ConstructorArgumentIndex,
    882 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    883// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    884// coverity[autosar_cpp14_a2_10_5_violation]
    886{
    887 return std::make_tuple();
    888}
    889
    891template <
    892 typename NodeT, size_t ConstructorArgumentIndex,
    893 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    894 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    895 // coverity[autosar_cpp14_a2_10_5_violation]
    897{
    898 using NodeParams = decltype(describeParameters<NodeT>());
    899
    900 using ConstructorParameter = std::tuple_element_t<ConstructorArgumentIndex, NodeParams>;
    901 using ArgType = std::remove_pointer_t<
    902 typename std::tuple_element_t<PARAMETER_CONSTRUCTOR_ARGUMENT_TYPE, ConstructorParameter>>;
    903 ArgType arg{};
    904
    905 return std::tuple_cat(std::make_tuple(arg), createConstructorArguments<NodeT, ConstructorArgumentIndex + 1>());
    906}
    907
    908} // namespace detail
    909
    911template <typename NodeT>
    913{
    914 return detail::createConstructorArguments<NodeT, 0>();
    915}
    916
    917namespace detail
    918{
    919
    921template <class T, class Tuple, size_t... Is>
    922// TODO(dwplc): FP -- The other parameterSize() functions are defined in a namespace
    923// coverity[autosar_cpp14_a2_10_5_violation]
    924auto makeUniqueFromTuple(const Tuple&& tuple, std::index_sequence<Is...>) -> std::unique_ptr<T>
    925{
    926 return std::unique_ptr<T>(new T{std::get<Is>(std::move(tuple))...});
    927}
    928}
    929
    931template <typename NodeT, class ConstructorArguments>
    932auto makeUniqueFromTuple(const ConstructorArguments&& constructorArguments) -> std::unique_ptr<NodeT>
    933{
    934 return detail::makeUniqueFromTuple<NodeT>(
    935 std::move(constructorArguments),
    936 std::make_index_sequence<std::tuple_size<std::decay_t<ConstructorArguments>>::value>{});
    937}
    938
    947template <typename NodeT>
    948auto create(const ParameterProvider& provider) -> std::unique_ptr<NodeT>
    949{
    950 auto constructorArguments = createConstructorArguments<NodeT>();
    951 populateParameters<NodeT>(constructorArguments, provider);
    952 return makeUniqueFromTuple<NodeT>(std::move(constructorArguments));
    953}
    954
    955// Number of parameters (sum across all constructor arguments)
    956namespace detail
    957{
    958
    960template <
    961 typename NodeT, size_t ConstructorArgumentIndex,
    962 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    963// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    964// coverity[autosar_cpp14_a2_10_5_violation]
    965constexpr std::size_t parameterSize()
    966{
    967 return 0;
    968}
    969
    971template <
    972 typename NodeT, size_t ConstructorArgumentIndex,
    973 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    974 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    975 // coverity[autosar_cpp14_a2_10_5_violation]
    976 constexpr std::size_t parameterSize()
    977{
    978 return constructorArgumentParameterSize<NodeT, ConstructorArgumentIndex>() + parameterSize<NodeT, ConstructorArgumentIndex + 1>();
    979}
    980
    981} // namespace detail
    982
    984// TODO(dwplc): FP -- The other parameterSize() functions are defined in a namespace
    985// coverity[autosar_cpp14_a2_10_5_violation]
    986template <typename NodeT>
    987constexpr std::size_t parameterSize()
    988{
    989 return detail::parameterSize<NodeT, 0>();
    990}
    991
    992} // namespace framework
    993} // namespace dw
    994
    995#endif // DW_FRAMEWORK_PARAMETERDESCRIPTOR_HPP_
    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 &&parameterName, std::array< T, ArraySize > defaultValue, const MemberPointers &&... memberPointers)
    constexpr auto describeAbstractParameter(dw::core::StringView const &&typeName, dw::core::StringView const &&parameterName)
    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 &&parameterName, 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 &&parameterName, const MemberPointers &&... memberPointers)
    constexpr auto describeAbstractArrayParameter(dw::core::StringView const &&typeName, dw::core::StringView const &&parameterName, 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 &&parameterName, size_t arraySize, const MemberPointers &&... memberPointers)
    constexpr auto describeParameterWithDefault(dw::core::StringView const &&typeName, dw::core::StringView const &&parameterName, 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
    Definition: Exception.hpp:47
    人人超碰97caoporen国产