• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.10
    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 <
    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>
    197// Overloaded functions are provided for ease of use
    198// coverity[autosar_cpp14_a2_10_5_violation]
    199// coverity[autosar_cpp14_a13_3_1_violation]
    200constexpr auto describeConstructorArguments(const Arg1&& arg1, const Arg2&& arg2, const Arg3&& arg3, const Arg4&& arg4, const Arg5&& arg5, const Arg6&& arg6)
    201{
    202 return std::make_tuple(
    203 std::make_tuple(
    204 static_cast<Argument1T*>(nullptr),
    205 std::forward<const Arg1>(arg1)),
    206 std::make_tuple(
    207 static_cast<Argument2T*>(nullptr),
    208 std::forward<const Arg2>(arg2)),
    209 std::make_tuple(
    210 static_cast<Argument3T*>(nullptr),
    211 std::forward<const Arg3>(arg3)),
    212 std::make_tuple(
    213 static_cast<Argument4T*>(nullptr),
    214 std::forward<const Arg4>(arg4)),
    215 std::make_tuple(
    216 static_cast<Argument5T*>(nullptr),
    217 std::forward<const Arg5>(arg5)),
    218 std::make_tuple(
    219 static_cast<Argument6T*>(nullptr),
    220 std::forward<const Arg6>(arg6)));
    221}
    222
    229template <typename... Args>
    230constexpr auto describeConstructorArgument(const Args&&... args)
    231{
    232 return dw::core::make_tuple(
    233 std::forward<const Args>(args)...);
    234}
    235
    236// Indices within the tuple describing parameters
    237// coverity[autosar_cpp14_a0_1_1_violation]
    238// coverity[autosar_cpp14_m0_1_4_violation]
    239static constexpr size_t PARAMETER_TYPE_NAME{0U};
    240// coverity[autosar_cpp14_a0_1_1_violation]
    241// coverity[autosar_cpp14_m0_1_4_violation]
    242static constexpr size_t PARAMETER_NAME{1U};
    243// coverity[autosar_cpp14_a0_1_1_violation]
    244// coverity[autosar_cpp14_m0_1_4_violation]
    245static constexpr size_t PARAMETER_TYPE{2U};
    246// coverity[autosar_cpp14_a0_1_1_violation]
    247// coverity[autosar_cpp14_m0_1_4_violation]
    248static constexpr size_t PARAMETER_SEMANTIC_TYPE{3U};
    249// coverity[autosar_cpp14_a0_1_1_violation]
    250// coverity[autosar_cpp14_m0_1_4_violation]
    251static constexpr size_t PARAMETER_IS_INDEX{4U};
    252// coverity[autosar_cpp14_a0_1_1_violation]
    253// coverity[autosar_cpp14_m0_1_4_violation]
    254static constexpr size_t PARAMETER_ARRAY_SIZE{5U};
    255// coverity[autosar_cpp14_a0_1_1_violation]
    256// coverity[autosar_cpp14_m0_1_4_violation]
    257static constexpr size_t PARAMETER_MEMBER_PTRS{6U};
    258// coverity[autosar_cpp14_a0_1_1_violation]
    259// coverity[autosar_cpp14_m0_1_4_violation]
    260static constexpr size_t PARAMETER_DEFAULT_VALUE{7U};
    261
    262} // namespace framework
    263} // namespace dw
    264
    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)
    268
    269namespace dw
    270{
    271namespace framework
    272{
    273
    282template <typename T, typename S, typename... MemberPointers>
    283constexpr auto describeParameter(
    284 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, const MemberPointers&&... memberPointers)
    285{
    286 return std::make_tuple(
    287 std::move(typeName),
    288 std::move(parameterName),
    289 static_cast<T*>(nullptr),
    290 static_cast<S*>(nullptr),
    291 false,
    292 static_cast<size_t>(0),
    293 std::move(
    294 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
    295}
    296
    297} // namespace framework
    298} // namespace dw
    299
    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)
    302
    303namespace dw
    304{
    305namespace framework
    306{
    307
    313template <typename T>
    315 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName)
    316{
    317 return std::make_tuple(
    318 std::move(typeName),
    319 std::move(parameterName),
    320 static_cast<T*>(nullptr),
    321 static_cast<T*>(nullptr),
    322 false,
    323 static_cast<size_t>(0));
    324}
    325
    331template <typename T>
    333 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, size_t arraySize)
    334{
    335 return std::make_tuple(
    336 std::move(typeName),
    337 std::move(parameterName),
    338 static_cast<T*>(nullptr),
    339 static_cast<T*>(nullptr),
    340 false,
    341 arraySize);
    342}
    343
    344} // namespace framework
    345} // namespace dw
    346
    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)
    349
    350namespace dw
    351{
    352namespace framework
    353{
    354
    361template <typename T, typename S, typename... MemberPointers>
    363 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, const MemberPointers&&... memberPointers)
    364{
    365 return std::make_tuple(
    366 std::move(typeName),
    367 std::move(parameterName),
    368 static_cast<T*>(nullptr),
    369 static_cast<S*>(nullptr),
    370 true,
    371 static_cast<size_t>(0),
    372 std::move(
    373 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
    374}
    375
    376} // namespace framework
    377} // namespace dw
    378
    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)
    381
    382namespace dw
    383{
    384namespace framework
    385{
    386
    392template <typename T, typename S, typename... MemberPointers>
    394 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, size_t arraySize, const MemberPointers&&... memberPointers)
    395{
    396 return std::make_tuple(
    397 std::move(typeName),
    398 std::move(parameterName),
    399 static_cast<T*>(nullptr),
    400 static_cast<S*>(nullptr),
    401 false,
    402 arraySize,
    403 std::move(
    404 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)));
    405}
    406
    407} // namespace framework
    408} // namespace dw
    409
    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)
    412
    413namespace dw
    414{
    415namespace framework
    416{
    417
    424template <typename T, typename S, typename... MemberPointers>
    426 dw::core::StringView const&& typeName, const MemberPointers&&... memberPointers)
    427{
    428 return describeParameter<T, S>(
    429 std::move(typeName),
    430 ""_sv,
    431 std::forward<const MemberPointers>(memberPointers)...);
    432}
    433
    434} // namespace framework
    435} // namespace dw
    436
    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)
    439
    440namespace dw
    441{
    442namespace framework
    443{
    444
    451template <typename T, typename S, typename... MemberPointers>
    453 dw::core::StringView const&& typeName, size_t arraySize, const MemberPointers&&... memberPointers)
    454{
    455 return describeArrayParameter<T, S>(
    456 std::move(typeName),
    457 ""_sv,
    458 arraySize,
    459 std::forward<const MemberPointers>(memberPointers)...);
    460}
    461
    462} // namespace framework
    463} // namespace dw
    464
    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)
    466
    467namespace dw
    468{
    469namespace framework
    470{
    471
    477template <typename T, typename S, typename... MemberPointers>
    479 dw::core::StringView const&& typeName, dw::core::StringView const&& parameterName, T defaultValue, const MemberPointers&&... memberPointers)
    480{
    481 return std::make_tuple(
    482 std::move(typeName),
    483 std::move(parameterName),
    484 static_cast<T*>(nullptr),
    485 static_cast<S*>(nullptr),
    486 false,
    487 static_cast<size_t>(0),
    488 std::move(
    489 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)),
    490 std::move(defaultValue));
    491}
    492
    493} // namespace framework
    494} // namespace dw
    495
    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)
    497
    498namespace dw
    499{
    500namespace framework
    501{
    502
    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)
    511{
    512 return std::make_tuple(
    513 std::move(typeName),
    514 std::move(parameterName),
    515 static_cast<T*>(nullptr),
    516 static_cast<S*>(nullptr),
    517 false,
    518 ArraySize,
    519 std::move(
    520 std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers)...)),
    521 std::move(defaultValue));
    522}
    523
    525template <typename NodeT>
    526constexpr auto describeParameters()
    527{
    529}
    530
    531namespace detail
    532{
    533
    535template <
    536 typename Param, typename MemberPtr,
    537 typename std::enable_if_t<std::tuple_size<Param>() <= PARAMETER_DEFAULT_VALUE, void>* = nullptr>
    538void populateDefault(const Param& param, MemberPtr& memberPtr)
    539{
    540 static_cast<void>(param);
    541 static_cast<void>(memberPtr);
    542}
    543
    545template <
    546 typename Param, typename MemberPtr,
    547 typename std::enable_if_t<PARAMETER_DEFAULT_VALUE<std::tuple_size<Param>(), void>* = nullptr>
    548 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    549 // coverity[autosar_cpp14_a2_10_5_violation]
    550 void populateDefault(const Param& param, MemberPtr& memberPtr)
    551{
    552 auto defaultValue = std::get<PARAMETER_DEFAULT_VALUE>(param);
    553 memberPtr = defaultValue;
    554}
    555
    557template <
    558 typename Param, typename MemberPtr,
    559 typename std::enable_if_t<std::tuple_size<Param>() <= PARAMETER_DEFAULT_VALUE, void>* = nullptr>
    560void populateArrayDefault(const Param& param, MemberPtr& memberPtr, size_t index)
    561{
    562 static_cast<void>(param);
    563 static_cast<void>(memberPtr);
    564 static_cast<void>(index);
    565}
    566
    568template <
    569 typename Param, typename MemberPtr,
    570 typename std::enable_if_t<PARAMETER_DEFAULT_VALUE<std::tuple_size<Param>(), void>* = nullptr>
    571 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    572 // coverity[autosar_cpp14_a2_10_5_violation]
    573 void populateArrayDefault(const Param& param, MemberPtr& memberPtr, size_t index)
    574{
    575 auto defaultValue = std::get<PARAMETER_DEFAULT_VALUE>(param);
    576 memberPtr[index] = defaultValue[index];
    577}
    578
    580template <
    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)
    584{
    585 static_cast<void>(memberPtrs);
    586 return arg;
    587}
    588
    590template <
    591 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    592 typename std::enable_if_t<MemberIndex + 1 == std::tuple_size<MemberPtrs>(), void>* = nullptr>
    593// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    594// coverity[autosar_cpp14_a2_10_5_violation]
    595auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    596{
    597 auto member = std::get<MemberIndex>(memberPtrs);
    598 return arg.*member;
    599}
    600
    602template <
    603 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    604 typename std::enable_if_t<MemberIndex + 1 < std::tuple_size<MemberPtrs>(), void>* = nullptr>
    605// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    606// coverity[autosar_cpp14_a2_10_5_violation]
    607auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    608{
    609 auto& member = std::get<MemberIndex>(memberPtrs);
    610 auto& m = arg.*member;
    611 return getMemberPtr<MemberIndex + 1>(m, memberPtrs);
    612}
    613
    615template <typename NodeT, size_t ConstructorParameterIndex>
    616constexpr size_t constructorArgumentParameterSize()
    617{
    618 return dw::core::tuple_size<
    619 std::tuple_element_t<
    621 std::tuple_element_t<
    622 ConstructorParameterIndex,
    623 decltype(describeParameters<NodeT>())>>>();
    624}
    625
    627template <
    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)
    631{
    632 static_cast<void>(arg);
    633 static_cast<void>(provider);
    634}
    635
    637template <typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex>
    638constexpr bool isIndexParameter()
    639{
    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);
    644}
    645
    647template <typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex>
    648constexpr bool isArrayParameter()
    649{
    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<
    654 PARAMETER_ARRAY_SIZE>(param);
    655 return arraySize > 0;
    656}
    657
    659template <typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex>
    660constexpr bool isAbstractParameter()
    661{
    662 constexpr auto param = dw::core::get<ParamIndex>(
    663 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    664 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    665 return std::tuple_size<decltype(param)>() <= PARAMETER_MEMBER_PTRS;
    666}
    667
    669template <
    670 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    671 typename std::enable_if_t<isAbstractParameter<NodeT, ConstructorParameterIndex, ParamIndex>(), void>* = nullptr>
    672// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    673// coverity[autosar_cpp14_a2_10_5_violation]
    674void populateParameter(const ParameterProvider& provider, ArgType& arg)
    675{
    676 static_cast<void>(arg);
    677 static_cast<void>(provider);
    678}
    679
    685template <
    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>
    688// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    689// coverity[autosar_cpp14_a2_10_5_violation]
    690void populateParameter(const ParameterProvider& provider, ArgType& arg)
    691{
    692 constexpr auto param = dw::core::get<ParamIndex>(
    693 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    694 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    695
    696 using DataType = std::remove_pointer_t<
    697 std::tuple_element_t<
    698 PARAMETER_TYPE, decltype(param)>>;
    699 using SemanticDataType = std::remove_pointer_t<
    700 std::tuple_element_t<
    701 PARAMETER_SEMANTIC_TYPE, decltype(param)>>;
    702
    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);
    705 if (!hadParameter)
    706 {
    707 populateDefault(param, memberPtr);
    708 }
    709}
    710
    716template <
    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>
    719// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    720// coverity[autosar_cpp14_a2_10_5_violation]
    721void populateParameter(const ParameterProvider& provider, ArgType& arg)
    722{
    723 constexpr auto param = dw::core::get<ParamIndex>(
    724 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    725 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    726
    727 using DataType = std::remove_pointer_t<
    728 std::tuple_element_t<
    729 PARAMETER_TYPE, decltype(param)>>;
    730 using SemanticDataType = std::remove_pointer_t<
    731 std::tuple_element_t<
    732 PARAMETER_SEMANTIC_TYPE, decltype(param)>>;
    733 DataType& memberPtr = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
    734
    735 size_t index = static_cast<size_t>(-1);
    736 bool hadParameter = provider.getOptional<size_t, size_t>(std::get<PARAMETER_NAME>(param), &index);
    737 if (hadParameter)
    738 {
    739 hadParameter = provider.getOptional<SemanticDataType, DataType>("", index, &memberPtr);
    740 }
    741 if (!hadParameter)
    742 {
    743 populateDefault(param, memberPtr);
    744 }
    745}
    746
    752template <
    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>
    755// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    756// coverity[autosar_cpp14_a2_10_5_violation]
    757void populateParameter(const ParameterProvider& provider, ArgType& arg)
    758{
    759 constexpr auto param = dw::core::get<ParamIndex>(
    760 std::get<PARAMETER_CONSTRUCTOR_ARGUMENT_DESCRIPTOR>(
    761 std::get<ConstructorParameterIndex>(describeParameters<NodeT>())));
    762
    763 using DataType = std::remove_pointer_t<
    764 std::tuple_element_t<
    765 PARAMETER_TYPE, decltype(param)>>;
    766 using SemanticDataType = std::remove_pointer_t<
    767 std::tuple_element_t<
    768 PARAMETER_SEMANTIC_TYPE, decltype(param)>>;
    769
    770 constexpr size_t arraySize = std::get<PARAMETER_ARRAY_SIZE>(
    771 param);
    772
    773 DataType(&memberPtr)[arraySize] = getMemberPtr<0>(arg, std::get<PARAMETER_MEMBER_PTRS>(param));
    774 for (size_t i = 0; i < arraySize; ++i)
    775 {
    776 bool hadParameter = provider.getOptional<SemanticDataType, DataType>(std::get<PARAMETER_NAME>(param), i, &memberPtr[i]);
    777 if (!hadParameter)
    778 {
    779 populateArrayDefault(param, memberPtr, i);
    780 }
    781 }
    782}
    783
    785template <
    786 typename NodeT, size_t ConstructorParameterIndex, size_t ParamIndex, typename ArgType,
    787 typename std::enable_if_t<ParamIndex<constructorArgumentParameterSize<NodeT, ConstructorParameterIndex>(), void>* = nullptr>
    788 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    789 // coverity[autosar_cpp14_a2_10_5_violation]
    790 void populateParametersRecursion(const ParameterProvider& provider, ArgType& arg)
    791{
    792 populateParameter<NodeT, ConstructorParameterIndex, ParamIndex>(provider, arg);
    793
    794 populateParametersRecursion<NodeT, ConstructorParameterIndex, ParamIndex + 1>(provider, arg);
    795}
    796
    802template <typename NodeT, size_t ConstructorParameterIndex, typename ArgType>
    803// TODO(dwplc): FP -- The other populateParameters() functions are defined in the parent namespace
    804// coverity[autosar_cpp14_a2_10_5_violation]
    805void populateParameters(const ParameterProvider& provider, ArgType& arg)
    806{
    807 try
    808 {
    809 populateParametersRecursion<NodeT, ConstructorParameterIndex, 0>(provider, arg);
    810 }
    811 catch (Exception& e)
    812 {
    813 throw ExceptionWithStatus(e.status(), "Exception while populating parameters of mangled node type ", typeid(NodeT).name(), ": ", e.message());
    814 }
    815}
    816
    817} // namespace detail
    818
    820template <
    821 typename NodeT,
    822 class ConstructorArguments,
    823 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 1, void>* = nullptr>
    824// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    825// coverity[autosar_cpp14_a2_10_5_violation]
    826void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    827{
    828 auto& arg0 = std::get<0>(constructorArguments);
    829 detail::populateParameters<NodeT, 0>(provider, arg0);
    830}
    831
    833template <
    834 typename NodeT,
    835 class ConstructorArguments,
    836 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 2, void>* = nullptr>
    837// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    838// coverity[autosar_cpp14_a2_10_5_violation]
    839void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    840{
    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);
    845}
    846
    848template <
    849 typename NodeT,
    850 class ConstructorArguments,
    851 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 3, void>* = nullptr>
    852// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    853// coverity[autosar_cpp14_a2_10_5_violation]
    854void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    855{
    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);
    862}
    863
    865template <
    866 typename NodeT,
    867 class ConstructorArguments,
    868 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 4, void>* = nullptr>
    869// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    870// coverity[autosar_cpp14_a2_10_5_violation]
    871void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    872{
    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);
    881}
    882
    884template <
    885 typename NodeT,
    886 class ConstructorArguments,
    887 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 5, void>* = nullptr>
    888// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    889// coverity[autosar_cpp14_a2_10_5_violation]
    890void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    891{
    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);
    902}
    903
    905template <
    906 typename NodeT,
    907 class ConstructorArguments,
    908 typename std::enable_if_t<std::tuple_size<ConstructorArguments>() == 6, void>* = nullptr>
    909// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    910// Output parameter is needed to populate member of arbitrary struct
    911// coverity[autosar_cpp14_a2_10_5_violation]
    912// coverity[autosar_cpp14_a8_4_8_violation]
    913void populateParameters(ConstructorArguments& constructorArguments, const ParameterProvider& provider)
    914{
    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);
    927}
    928
    929namespace detail
    930{
    931
    932// Get the Number of constructor arguments of the passed node.
    933template <typename NodeT>
    934constexpr std::size_t parameterConstructorArgumentSize()
    935{
    936 return std::tuple_size<decltype(describeParameters<NodeT>())>::value;
    937}
    938
    940template <
    941 typename NodeT, size_t ConstructorArgumentIndex,
    942 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    943// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    944// coverity[autosar_cpp14_a2_10_5_violation]
    946{
    947 return std::make_tuple();
    948}
    949
    951template <
    952 typename NodeT, size_t ConstructorArgumentIndex,
    953 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    954 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    955 // coverity[autosar_cpp14_a2_10_5_violation]
    957{
    958 using NodeParams = decltype(describeParameters<NodeT>());
    959
    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>>;
    963 ArgType arg{};
    964
    965 return std::tuple_cat(std::make_tuple(arg), createConstructorArguments<NodeT, ConstructorArgumentIndex + 1>());
    966}
    967
    968} // namespace detail
    969
    971template <typename NodeT>
    973{
    974 return detail::createConstructorArguments<NodeT, 0>();
    975}
    976
    977namespace detail
    978{
    979
    981template <class T, class Tuple, size_t... Is>
    982// TODO(dwplc): FP -- The other parameterSize() functions are defined in a namespace
    983// coverity[autosar_cpp14_a2_10_5_violation]
    984auto makeUniqueFromTuple(const Tuple&& tuple, std::index_sequence<Is...>) -> std::unique_ptr<T>
    985{
    986 return std::unique_ptr<T>(new T{std::get<Is>(std::move(tuple))...});
    987}
    988}
    989
    991template <typename NodeT, class ConstructorArguments>
    992auto makeUniqueFromTuple(const ConstructorArguments&& constructorArguments) -> std::unique_ptr<NodeT>
    993{
    994 return detail::makeUniqueFromTuple<NodeT>(
    995 std::move(constructorArguments),
    996 std::make_index_sequence<std::tuple_size<std::decay_t<ConstructorArguments>>::value>{});
    997}
    998
    1007template <typename NodeT>
    1008auto create(const ParameterProvider& provider) -> std::unique_ptr<NodeT>
    1009{
    1010 auto constructorArguments = createConstructorArguments<NodeT>();
    1011 populateParameters<NodeT>(constructorArguments, provider);
    1012 return makeUniqueFromTuple<NodeT>(std::move(constructorArguments));
    1013}
    1014
    1015// Number of parameters (sum across all constructor arguments)
    1016namespace detail
    1017{
    1018
    1020template <
    1021 typename NodeT, size_t ConstructorArgumentIndex,
    1022 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    1023// TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    1024// coverity[autosar_cpp14_a2_10_5_violation]
    1025constexpr std::size_t parameterSize()
    1026{
    1027 return 0;
    1028}
    1029
    1031template <
    1032 typename NodeT, size_t ConstructorArgumentIndex,
    1033 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    1034 // TODO(dwplc): FP -- The specific specialization of this templated function is selected by enable_if
    1035 // coverity[autosar_cpp14_a2_10_5_violation]
    1036 constexpr std::size_t parameterSize()
    1037{
    1038 return constructorArgumentParameterSize<NodeT, ConstructorArgumentIndex>() + parameterSize<NodeT, ConstructorArgumentIndex + 1>();
    1039}
    1040
    1041} // namespace detail
    1042
    1044// TODO(dwplc): FP -- The other parameterSize() functions are defined in a namespace
    1045// coverity[autosar_cpp14_a2_10_5_violation]
    1046template <typename NodeT>
    1047constexpr std::size_t parameterSize()
    1048{
    1049 return detail::parameterSize<NodeT, 0>();
    1050}
    1051
    1052} // namespace framework
    1053} // namespace dw
    1054
    1055#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: Buffer.hpp:40
    人人超碰97caoporen国产