• <xmp id="om0om">
  • <table id="om0om"><noscript id="om0om"></noscript></table>
  • Compute Graph Framework SDK Reference  5.22
    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-2024 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 <dwshared/dwfoundation/dw/core/container/StringView.hpp>
    37#include <dwshared/dwfoundation/dw/core/language/Optional.hpp>
    38#include <dwshared/dwfoundation/dw/core/language/Tuple.hpp>
    39
    40namespace dw
    41{
    42namespace framework
    43{
    44
    45template <typename ConstructorArgumentT, typename ParameterDescriptorsT>
    47{
    48 static_assert(std::is_constructible<ConstructorArgumentT>::value, "ConstructorArgumentT must be constructible");
    49
    50 // coverity[autosar_cpp14_a0_1_6_violation]
    51 // coverity[autosar_cpp14_m3_4_1_violation] RFD Pending: TID-2586
    52 using ConstructorArgumentType = ConstructorArgumentT;
    53 using ParameterDescriptorsType = ParameterDescriptorsT;
    55
    57 : parameterDescriptors(std::move(parameterDescriptors_))
    58 {
    59 }
    60};
    61
    68constexpr std::tuple<> describeConstructorArguments()
    69{
    70 return std::make_tuple();
    71}
    72
    80template <typename Arg1>
    81// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    82constexpr auto describeConstructorArguments(Arg1&& arg1) -> std::tuple<Arg1>
    83{
    84 return std::make_tuple(std::forward<Arg1>(arg1));
    85}
    86
    94template <
    95 typename Arg1, typename... ArgRest,
    96 typename std::enable_if_t<sizeof...(ArgRest) != 0>* = nullptr>
    97// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    98// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    99constexpr auto describeConstructorArguments(Arg1&& arg1, ArgRest&&... argRest)
    100{
    101 return std::tuple_cat(
    102 describeConstructorArguments<Arg1>(std::forward<Arg1>(arg1)),
    103 describeConstructorArguments<ArgRest...>(std::forward<ArgRest>(argRest)...));
    104}
    105
    112template <typename ConstructorArgumentT, typename... Args>
    113// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    114constexpr auto describeConstructorArgument(const Args&&... args) -> ConstructorArgumentDescriptorT<ConstructorArgumentT, dw::core::Tuple<Args...>>
    115{
    116 return ConstructorArgumentDescriptorT<ConstructorArgumentT, dw::core::Tuple<Args...>>(
    117 dw::core::make_tuple<const Args...>(std::forward<const Args>(args)...));
    118}
    119
    120template <typename Type_, typename SemanticType_, bool IsIndex, size_t ArraySize, bool IsAbstract, bool HasDefault, typename... MemberPointers>
    122{
    123 static_assert(std::is_constructible<Type_>::value, "Type_ must be constructible");
    124
    125 dw::core::StringView typeName;
    126 dw::core::StringView parameterName;
    127 // coverity[autosar_cpp14_a0_1_6_violation]
    128 using Type = Type_;
    129 // coverity[autosar_cpp14_a0_1_6_violation]
    130 // coverity[autosar_cpp14_m3_4_1_violation] RFD Pending: TID-2586
    131 using SemanticType = SemanticType_;
    132 static constexpr bool IS_INDEX{IsIndex};
    133 static constexpr size_t ARRAY_SIZE{ArraySize};
    134 static constexpr bool IS_ABSTRACT{IsAbstract};
    135 // coverity[autosar_cpp14_a0_1_1_violation] FP: nvbugs/2813925
    136 // coverity[autosar_cpp14_m0_1_4_violation] FP: nvbugs/2813925
    137 static constexpr bool HAS_DEFAULT{HasDefault};
    138 std::tuple<const MemberPointers...> memberPointers;
    139
    140 constexpr ParameterDescriptorT(dw::core::StringView&& typeName_, dw::core::StringView&& parameterName_, const MemberPointers&&... memberPointers_)
    141 : typeName{std::move(typeName_)}
    142 , parameterName{std::move(parameterName_)}
    143 , memberPointers(std::make_tuple<const MemberPointers...>(std::forward<const MemberPointers>(memberPointers_)...))
    144 {
    145 }
    146};
    147
    148template <typename Type_, typename SemanticType_, bool IsIndex, size_t ArraySize, bool IsAbstract, bool HasDefault, typename... MemberPointers>
    149constexpr bool ParameterDescriptorT<Type_, SemanticType_, IsIndex, ArraySize, IsAbstract, HasDefault, MemberPointers...>::IS_INDEX;
    150
    151template <typename Type_, typename SemanticType_, bool IsIndex, size_t ArraySize, bool IsAbstract, bool HasDefault, typename... MemberPointers>
    152constexpr size_t ParameterDescriptorT<Type_, SemanticType_, IsIndex, ArraySize, IsAbstract, HasDefault, MemberPointers...>::ARRAY_SIZE;
    153
    154template <typename Type_, typename SemanticType_, bool IsIndex, size_t ArraySize, bool IsAbstract, bool HasDefault, typename... MemberPointers>
    155constexpr bool ParameterDescriptorT<Type_, SemanticType_, IsIndex, ArraySize, IsAbstract, HasDefault, MemberPointers...>::HAS_DEFAULT;
    156
    157template <typename Type, typename SemanticType, bool IsIndex, size_t ArraySize, bool IsAbstract, typename DefaultType, typename... MemberPointers>
    158struct ParameterDescriptorWithDefaultT : public ParameterDescriptorT<Type, SemanticType, IsIndex, ArraySize, IsAbstract, true, MemberPointers...>
    159{
    160 static_assert(std::is_trivially_move_constructible<DefaultType>(), "DefaultType must be trivially move constructible");
    161
    162 DefaultType defaultValue;
    163
    164 constexpr ParameterDescriptorWithDefaultT(dw::core::StringView&& typeName_, dw::core::StringView&& parameterName_, DefaultType&& defaultValue_, const MemberPointers&&... memberPointers_)
    165 : ParameterDescriptorT<Type, SemanticType, IsIndex, ArraySize, IsAbstract, true, MemberPointers...>{std::move(typeName_), std::move(parameterName_), std::forward<const MemberPointers>(memberPointers_)...}
    166 , defaultValue{std::move(defaultValue_)}
    167 {
    168 }
    169};
    170
    171} // namespace framework
    172} // namespace dw
    173
    174#define DW_PARAMETER_TYPE_NAME_STRING_VIEW_IMPL(TYPE_NAME_STR) \
    175 dw::core::StringView { TYPE_NAME_STR }
    176#define DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME) DW_PARAMETER_TYPE_NAME_STRING_VIEW_IMPL(#TYPE_NAME)
    177#define DW_DESCRIBE_PARAMETER(TYPE_NAME, args...) dw::framework::describeParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), ##args)
    178#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)
    179
    180namespace dw
    181{
    182namespace framework
    183{
    184
    193template <typename T, typename S, typename... MemberPointers>
    194// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    195constexpr auto describeParameter(
    196 dw::core::StringView&& typeName, dw::core::StringView&& parameterName, const MemberPointers&&... memberPointers) -> ParameterDescriptorT<T, S, false, 0, false, false, MemberPointers...>
    197{
    198 return ParameterDescriptorT<T, S, false, 0, false, false, MemberPointers...>(
    199 std::move(typeName),
    200 std::move(parameterName),
    201 std::forward<const MemberPointers>(memberPointers)...);
    202}
    203
    204} // namespace framework
    205} // namespace dw
    206
    207#define DW_DESCRIBE_ABSTRACT_PARAMETER(TYPE_NAME, args...) dw::framework::describeAbstractParameter<TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), ##args)
    208#define DW_DESCRIBE_ABSTRACT_ARRAY_PARAMETER(TYPE_NAME, PARAM_NAME, ARRAY_SIZE, args...) dw::framework::describeAbstractArrayParameter<TYPE_NAME, ARRAY_SIZE>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), PARAM_NAME, ##args)
    209
    210namespace dw
    211{
    212namespace framework
    213{
    214
    220template <typename T>
    221// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    222// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    224 dw::core::StringView&& typeName, dw::core::StringView&& parameterName)
    225{
    227 std::move(typeName),
    228 std::move(parameterName));
    229}
    230
    236template <typename T, size_t ArraySize>
    238 dw::core::StringView&& typeName, dw::core::StringView&& parameterName)
    239{
    241 std::move(typeName),
    242 std::move(parameterName));
    243}
    244
    245} // namespace framework
    246} // namespace dw
    247
    248#define DW_DESCRIBE_INDEX_PARAMETER(TYPE_NAME, args...) dw::framework::describeIndexParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), ##args)
    249#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)
    250
    251namespace dw
    252{
    253namespace framework
    254{
    255
    262template <typename T, typename S, typename... MemberPointers>
    263// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    264// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    266 dw::core::StringView&& typeName, dw::core::StringView&& parameterName, const MemberPointers&&... memberPointers)
    267{
    268 return ParameterDescriptorT<T, S, true, 0, false, false, MemberPointers...>(
    269 std::move(typeName),
    270 std::move(parameterName),
    271 std::forward<const MemberPointers>(memberPointers)...);
    272}
    273
    274} // namespace framework
    275} // namespace dw
    276
    277#define DW_DESCRIBE_ARRAY_PARAMETER(TYPE_NAME, PARAM_NAME, ARRAY_SIZE, args...) dw::framework::describeArrayParameter<TYPE_NAME, TYPE_NAME, ARRAY_SIZE>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), PARAM_NAME, ##args)
    278#define DW_DESCRIBE_ARRAY_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, PARAM_NAME, ARRAY_SIZE, args...) dw::framework::describeArrayParameter<TYPE_NAME, SEMANTIC_TYPE_NAME, ARRAY_SIZE>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), PARAM_NAME, ##args)
    279
    280namespace dw
    281{
    282namespace framework
    283{
    284
    290template <typename T, typename S, size_t ArraySize, typename... MemberPointers>
    291// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    292// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    294 dw::core::StringView&& typeName, dw::core::StringView&& parameterName, const MemberPointers&&... memberPointers)
    295{
    296 return ParameterDescriptorT<T, S, false, ArraySize, false, false, MemberPointers...>(
    297 std::move(typeName),
    298 std::move(parameterName),
    299 std::forward<const MemberPointers>(memberPointers)...);
    300}
    301
    302} // namespace framework
    303} // namespace dw
    304
    305#define DW_DESCRIBE_UNNAMED_PARAMETER(TYPE_NAME, args...) dw::framework::describeUnnamedParameter<TYPE_NAME, TYPE_NAME>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), ##args)
    306#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)
    307
    308namespace dw
    309{
    310namespace framework
    311{
    312
    319template <typename T, typename S, typename... MemberPointers>
    320// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    322 dw::core::StringView&& typeName, const MemberPointers&&... memberPointers) -> ParameterDescriptorT<T, S, false, 0, false, false, MemberPointers...>
    323{
    324 // coverity[autosar_cpp14_a5_1_1_violation] FP: nvbugs/3364868
    325 // coverity[autosar_cpp14_a5_2_2_violation] FP: nvbugs/3949905
    326 return describeParameter<T, S, MemberPointers...>(
    327 std::move(typeName),
    328 dw::core::StringView{""},
    329 std::forward<const MemberPointers>(memberPointers)...);
    330}
    331
    332} // namespace framework
    333} // namespace dw
    334
    335#define DW_DESCRIBE_UNNAMED_ARRAY_PARAMETER(TYPE_NAME, ARRAY_SIZE, args...) dw::framework::describeUnnamedArrayParameter<TYPE_NAME, TYPE_NAME, ARRAY_SIZE>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), ##args)
    336#define DW_DESCRIBE_UNNAMED_ARRAY_PARAMETER_WITH_SEMANTIC(TYPE_NAME, SEMANTIC_TYPE_NAME, ARRAY_SIZE, args...) dw::framework::describeUnnamedArrayParameter<TYPE_NAME, SEMANTIC_TYPE_NAME, ARRAY_SIZE>(DW_PARAMETER_TYPE_NAME_STRING_VIEW(TYPE_NAME), ##args)
    337
    338namespace dw
    339{
    340namespace framework
    341{
    342
    349template <typename T, typename S, size_t ArraySize, typename... MemberPointers>
    351 dw::core::StringView&& typeName, const MemberPointers&&... memberPointers)
    352{
    353 return describeArrayParameter<T, S, ArraySize>(
    354 std::move(typeName),
    355 ""_sv,
    356 std::forward<const MemberPointers>(memberPointers)...);
    357}
    358
    359} // namespace framework
    360} // namespace dw
    361
    362#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)
    363
    364namespace dw
    365{
    366namespace framework
    367{
    368
    374template <typename T, typename S, typename... MemberPointers>
    375// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    377 dw::core::StringView&& typeName, dw::core::StringView&& parameterName, T&& defaultValue, const MemberPointers&&... memberPointers) -> ParameterDescriptorWithDefaultT<T, S, false, 0, false, T, MemberPointers...>
    378{
    379 return ParameterDescriptorWithDefaultT<T, S, false, 0, false, T, MemberPointers...>(
    380 std::move(typeName),
    381 std::move(parameterName),
    382 std::move(defaultValue),
    383 std::forward<const MemberPointers>(memberPointers)...);
    384}
    385
    386} // namespace framework
    387} // namespace dw
    388
    389#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)
    390
    391namespace dw
    392{
    393namespace framework
    394{
    395
    401template <typename T, typename S, size_t ArraySize, typename... MemberPointers>
    402// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    404 dw::core::StringView&& typeName, dw::core::StringView&& parameterName, std::array<T, ArraySize> defaultValue, const MemberPointers&&... memberPointers) -> ParameterDescriptorWithDefaultT<T, S, false, ArraySize, false, std::array<T, ArraySize>, MemberPointers...>
    405{
    407 std::move(typeName),
    408 std::move(parameterName),
    409 std::move(defaultValue),
    410 std::forward<const MemberPointers>(memberPointers)...);
    411}
    412
    414template <typename NodeT>
    415// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    416// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    418{
    419 return NodeT::describeParameters();
    420}
    421
    422namespace detail
    423{
    424
    426template <
    427 typename Param, typename MemberPtr,
    428 typename std::enable_if_t<!Param::HAS_DEFAULT, void>* = nullptr>
    429// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    430bool populateDefault(const Param& param, MemberPtr& memberPtr)
    431{
    432 static_cast<void>(param);
    433 static_cast<void>(memberPtr);
    434 return false;
    435}
    436
    438template <
    439 typename Param, typename MemberPtr,
    440 typename std::enable_if_t<Param::HAS_DEFAULT, void>* = nullptr>
    441// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    442bool populateDefault(const Param& param, MemberPtr& memberPtr)
    443{
    444 memberPtr = param.defaultValue;
    445 return true;
    446}
    447
    449template <
    450 typename Param, typename MemberPtr,
    451 typename std::enable_if_t<!Param::HAS_DEFAULT, void>* = nullptr>
    452// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    453void populateArrayDefault(const Param& param, MemberPtr& memberPtr, size_t index)
    454{
    455 static_cast<void>(param);
    456 static_cast<void>(memberPtr);
    457 static_cast<void>(index);
    458}
    459
    461template <
    462 typename Param, typename MemberPtr,
    463 typename std::enable_if_t<Param::HAS_DEFAULT, void>* = nullptr>
    464// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    465void populateArrayDefault(const Param& param, MemberPtr& memberPtr, size_t index)
    466{
    467 memberPtr = param.defaultValue.at(index);
    468}
    469
    471template <
    472 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    473 typename std::enable_if_t<std::tuple_size<MemberPtrs>() == 0, void>* = nullptr>
    474// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    475auto getMemberPtr(ArgType& arg, MemberPtrs memberPtrs) -> ArgType&
    476{
    477 static_cast<void>(memberPtrs);
    478 return arg;
    479}
    480
    482template <
    483 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    484 typename std::enable_if_t<MemberIndex + 1 == std::tuple_size<MemberPtrs>(), void>* = nullptr>
    485// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    486// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    487auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    488{
    489 // coverity[autosar_cpp14_a8_5_2_violation] FP: nvbugs/3904083
    490 auto member = std::get<MemberIndex>(memberPtrs);
    491 return arg.*member;
    492}
    493
    495template <
    496 size_t MemberIndex, typename ArgType, typename MemberPtrs,
    497 typename std::enable_if_t<MemberIndex + 1 < std::tuple_size<MemberPtrs>(), void>* = nullptr>
    498// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    499// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    500auto& getMemberPtr(ArgType& arg, MemberPtrs memberPtrs)
    501{
    502 // coverity[autosar_cpp14_a8_5_2_violation] FP: nvbugs/3904083
    503 auto& member = std::get<MemberIndex>(memberPtrs);
    504 // coverity[autosar_cpp14_a8_5_2_violation] FP: nvbugs/3904083
    505 auto& m = arg.*member;
    506 return getMemberPtr<MemberIndex + 1>(m, memberPtrs);
    507}
    508
    510template <typename NodeT, size_t ConstructorParameterIndex>
    511// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    512constexpr size_t constructorArgumentParameterSize()
    513{
    514 using ConstructorArgumentDescriptor = std::tuple_element_t<ConstructorParameterIndex, decltype(describeNodeParameters<NodeT>())>;
    515 return dw::core::tuple_size<typename ConstructorArgumentDescriptor::ParameterDescriptorsType>::value;
    516}
    517
    519template <typename ParamT>
    520// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    521constexpr bool isIndexParameter()
    522{
    523 return ParamT::IS_INDEX;
    524}
    525
    527template <typename ParamT>
    528// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    529constexpr bool isArrayParameter()
    530{
    531 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
    532 return ParamT::ARRAY_SIZE > 0U;
    533}
    534
    536template <typename ParamT>
    537// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    538constexpr bool isAbstractParameter()
    539{
    540 return ParamT::IS_ABSTRACT;
    541}
    542
    544template <
    545 typename ArgType, typename ParamT,
    546 typename std::enable_if_t<isAbstractParameter<ParamT>(), void>* = nullptr>
    547// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    548void populateParameter(const ParameterProvider& provider, ArgType& arg, const ParamT& param)
    549{
    550 static_cast<void>(provider);
    551 static_cast<void>(arg);
    552 static_cast<void>(param);
    553}
    554
    562template <
    563 typename ArgType, typename ParamT,
    564 typename std::enable_if_t<!isAbstractParameter<ParamT>() && !isArrayParameter<ParamT>() && !isIndexParameter<ParamT>(), void>* = nullptr>
    565// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    566void populateParameter(const ParameterProvider& provider, ArgType& arg, const ParamT& param)
    567{
    568 using DataType = typename ParamT::Type;
    569 using SemanticDataType = typename ParamT::SemanticType;
    570 DataType& memberPtr{getMemberPtr<0>(arg, param.memberPointers)};
    571 bool hadParameter{provider.getOptional<SemanticDataType, DataType>(param.parameterName, memberPtr)};
    572 if (!hadParameter)
    573 {
    574 bool setDefault{populateDefault(param, memberPtr)};
    575 if (!setDefault)
    576 {
    577 throw ExceptionWithStatus(DW_FAILURE, "Failed to get required parameter with name '", param.parameterName, "', T=", typeid(DataType).name(), ", S=", typeid(SemanticDataType).name());
    578 }
    579 }
    580}
    581
    589template <
    590 typename ArgType, typename ParamT,
    591 typename std::enable_if_t<!isAbstractParameter<ParamT>() && !isArrayParameter<ParamT>() && isIndexParameter<ParamT>(), void>* = nullptr>
    592// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    593void populateParameter(const ParameterProvider& provider, ArgType& arg, const ParamT& param)
    594{
    595 using DataType = typename ParamT::Type;
    596 using SemanticDataType = typename ParamT::SemanticType;
    597 DataType& memberPtr{getMemberPtr<0>(arg, param.memberPointers)};
    598
    599 size_t index{std::numeric_limits<size_t>::max()};
    600 bool hadParameter{provider.getOptional<size_t, size_t>(param.parameterName, index)};
    601 if (hadParameter)
    602 {
    603 hadParameter = provider.getOptionalWithIndex<SemanticDataType, DataType>("", index, memberPtr);
    604 }
    605 if (!hadParameter)
    606 {
    607 bool setDefault{populateDefault(param, memberPtr)};
    608 if (!setDefault)
    609 {
    610 throw ExceptionWithStatus(DW_FAILURE, "Failed to get required parameter with name '", param.parameterName, "', index=", index, ", T=", typeid(DataType).name(), ", S=", typeid(SemanticDataType).name());
    611 }
    612 }
    613}
    614
    620template <
    621 typename ArgType, typename ParamT,
    622 typename std::enable_if_t<!isAbstractParameter<ParamT>() && isArrayParameter<ParamT>(), void>* = nullptr>
    623// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    624void populateParameter(const ParameterProvider& provider, ArgType& arg, const ParamT& param)
    625{
    626 using DataType = typename ParamT::Type;
    627 using SemanticDataType = typename ParamT::SemanticType;
    628
    629 constexpr size_t arraySize{ParamT::ARRAY_SIZE};
    630
    631 DataType(&memberPtr)[arraySize]{getMemberPtr<0>(arg, param.memberPointers)};
    632 for (size_t i{0U}; i < arraySize; ++i)
    633 {
    634 bool hadParameter{provider.getOptionalWithIndex<SemanticDataType, DataType>(param.parameterName, i, memberPtr[i])};
    635 if (!hadParameter)
    636 {
    637 populateArrayDefault(param, memberPtr[i], i);
    638 }
    639 }
    640}
    641
    642// LCOV_EXCL_START end of template recursion is never reached
    644template <typename ArgType>
    645// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    646void populateParametersRecursion(const ParameterProvider& provider, ArgType& arg, const dw::core::Tuple<>& t)
    647{
    648 static_cast<void>(provider);
    649 static_cast<void>(arg);
    650 static_cast<void>(t);
    651}
    652// LCOV_EXCL_STOP
    653
    655template <typename ArgType, typename THead>
    656// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    657void populateParametersRecursion(const ParameterProvider& provider, ArgType& arg, const dw::core::Tuple<THead>& t)
    658{
    659 populateParameter(provider, arg, t.m_head);
    660}
    661
    663template <
    664 typename ArgType, typename THead, typename... TTail,
    665 typename std::enable_if_t<sizeof...(TTail) != 0>* = nullptr>
    666// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    667void populateParametersRecursion(const ParameterProvider& provider, ArgType& arg, const dw::core::Tuple<THead, TTail...>& t)
    668{
    669 populateParameter(provider, arg, t.m_head);
    670 populateParametersRecursion(provider, arg, t.m_tail);
    671}
    672
    678template <typename NodeT, size_t ConstructorParameterIndex, typename ConstructorArgsType>
    679// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    680void populateParameters(const ParameterProvider& provider, ConstructorArgsType& constructorArguments)
    681{
    682 try
    683 {
    684 // coverity[autosar_cpp14_a8_5_2_violation] FP: nvbugs/3904083
    685 auto& arg = std::get<ConstructorParameterIndex>(constructorArguments);
    686 // coverity[autosar_cpp14_a8_5_2_violation] FP: nvbugs/3904083
    687 constexpr auto params = std::get<ConstructorParameterIndex>(describeNodeParameters<NodeT>()).parameterDescriptors;
    688 // coverity[cert_err59_cpp_violation] RFD Pending: TID-2587
    689 populateParametersRecursion(provider, arg, params);
    690 }
    691 catch (ExceptionWithStatus& e)
    692 {
    693 throw ExceptionWithStatus(e.statusCode(), "Exception while populating parameters of mangled node type ", typeid(NodeT).name(), ": ", e.message());
    694 }
    695}
    696
    697// Return value needed by populateParametersForEachConstructorArgument() for the forEach variable in C++14
    698template <typename NodeT, size_t ConstructorParameterIndex, typename ConstructorArgsType>
    699// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    700void* populateParametersWithNonVoidReturnType(const ParameterProvider& provider, ConstructorArgsType& constructorArguments)
    701{
    702 populateParameters<NodeT, ConstructorParameterIndex>(provider, constructorArguments);
    703 return nullptr;
    704}
    705
    706template <
    707 typename NodeT, typename ConstructorArguments, size_t... Is>
    708// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    709void populateParametersForEachConstructorArgument(const ParameterProvider& provider, ConstructorArguments& constructorArguments, std::integer_sequence<size_t, Is...>)
    710{
    711 void* forEach[]{
    712 populateParametersWithNonVoidReturnType<NodeT, Is>(provider, constructorArguments)...};
    713 static_cast<void>(forEach);
    714}
    715
    716} // namespace detail
    717
    719template <typename NodeT, typename... Ts>
    720// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    721void populateParameters(std::tuple<Ts...>& constructorArguments, const ParameterProvider& provider)
    722{
    723 detail::populateParametersForEachConstructorArgument<NodeT>(provider, constructorArguments, std::make_index_sequence<sizeof...(Ts)>());
    724}
    725
    726namespace detail
    727{
    728
    729// Get the Number of constructor arguments of the passed node.
    730template <typename NodeT>
    731// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    732constexpr std::size_t parameterConstructorArgumentSize()
    733{
    734 return std::tuple_size<decltype(describeNodeParameters<NodeT>())>::value;
    735}
    736
    738template <
    739 typename NodeT, size_t ConstructorArgumentIndex,
    740 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    741// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    742std::tuple<> createConstructorArguments()
    743{
    744 return std::make_tuple();
    745}
    746
    748template <
    749 typename NodeT, size_t ConstructorArgumentIndex,
    750 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    751 // coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    752 // coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    754{
    755 using NodeParams = decltype(describeNodeParameters<NodeT>());
    756
    757 using ConstructorArgumentDescriptor = std::tuple_element_t<ConstructorArgumentIndex, NodeParams>;
    758 typename ConstructorArgumentDescriptor::ConstructorArgumentType arg{};
    759
    760 return std::tuple_cat(std::make_tuple(arg), createConstructorArguments<NodeT, ConstructorArgumentIndex + 1>());
    761}
    762
    763} // namespace detail
    764
    766template <typename NodeT>
    767// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    768// coverity[autosar_cpp14_a7_1_5_violation] RFD Accepted: TID-2201
    770{
    771 return detail::createConstructorArguments<NodeT, 0>();
    772}
    773
    774namespace detail
    775{
    776
    778template <class T, class Tuple, size_t... Is>
    779// coverity[autosar_cpp14_a2_10_5_violation]
    780auto makeUniqueFromTuple(Tuple&& tuple, std::index_sequence<Is...>) -> std::unique_ptr<T>
    781{
    782 return std::make_unique<T>(std::get<Is>(tuple)...);
    783}
    784}
    785
    787template <typename NodeT, class ConstructorArguments>
    788// coverity[autosar_cpp14_a2_10_5_violation]
    789auto makeUniqueFromTuple(ConstructorArguments&& constructorArguments) -> std::unique_ptr<NodeT>
    790{
    791 return detail::makeUniqueFromTuple<NodeT>(
    792 std::move(constructorArguments),
    793 std::make_index_sequence<std::tuple_size<std::decay_t<ConstructorArguments>>::value>{});
    794}
    795
    804template <typename NodeT>
    805// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    806auto createNode(const ParameterProvider& provider) -> std::unique_ptr<NodeT>
    807{
    808 // coverity[autosar_cpp14_a8_5_2_violation] FP: nvbugs/3904083
    809 auto constructorArguments = createConstructorArguments<NodeT>();
    810 populateParameters<NodeT>(constructorArguments, provider);
    811 return makeUniqueFromTuple<NodeT>(std::move(constructorArguments));
    812}
    813
    814// Number of parameters (sum across all constructor arguments)
    815namespace detail
    816{
    817
    819template <
    820 typename NodeT, size_t ConstructorArgumentIndex,
    821 typename std::enable_if_t<ConstructorArgumentIndex == parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    822// coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    823constexpr std::size_t parameterSize()
    824{
    825 // coverity[autosar_cpp14_a5_1_1_violation] RFD Accepted: TID-2056
    826 return 0U;
    827}
    828
    830template <
    831 typename NodeT, size_t ConstructorArgumentIndex,
    832 typename std::enable_if_t<ConstructorArgumentIndex<parameterConstructorArgumentSize<NodeT>(), void>* = nullptr>
    833 // coverity[autosar_cpp14_a2_10_5_violation] FP: nvbugs/3907242
    834 constexpr std::size_t parameterSize()
    835{
    836 return constructorArgumentParameterSize<NodeT, ConstructorArgumentIndex>() + parameterSize<NodeT, ConstructorArgumentIndex + 1>();
    837}
    838
    839} // namespace detail
    840
    842template <typename NodeT>
    843// coverity[autosar_cpp14_a2_10_5_violation]
    844constexpr std::size_t parameterSize()
    845{
    846 return detail::parameterSize<NodeT, 0>();
    847}
    848
    849} // namespace framework
    850} // namespace dw
    851
    852#endif // DW_FRAMEWORK_PARAMETERDESCRIPTOR_HPP_
    The interface to access parameter values identified by name and/or (semantic) type.
    auto makeUniqueFromTuple(ConstructorArguments &&constructorArguments) -> std::unique_ptr< NodeT >
    Instantiate a node using the passed constructor arguments.
    constexpr auto describeUnnamedParameter(dw::core::StringView &&typeName, const MemberPointers &&... memberPointers) -> ParameterDescriptorT< T, S, false, 0, false, false, MemberPointers... >
    constexpr auto describeAbstractArrayParameter(dw::core::StringView &&typeName, dw::core::StringView &&parameterName)
    constexpr std::tuple describeConstructorArguments()
    constexpr auto describeParameter(dw::core::StringView &&typeName, dw::core::StringView &&parameterName, const MemberPointers &&... memberPointers) -> ParameterDescriptorT< T, S, false, 0, false, false, MemberPointers... >
    constexpr auto describeAbstractParameter(dw::core::StringView &&typeName, dw::core::StringView &&parameterName)
    constexpr auto describeUnnamedArrayParameter(dw::core::StringView &&typeName, const MemberPointers &&... memberPointers)
    auto createConstructorArguments()
    Create a tuple of constructor argument needed by the constructor of the passed node.
    std::unique_ptr< Node > createNode(const dw::core::StringView &className, ParameterProvider &provider)
    constexpr auto describeArrayParameterWithDefault(dw::core::StringView &&typeName, dw::core::StringView &&parameterName, std::array< T, ArraySize > defaultValue, const MemberPointers &&... memberPointers) -> ParameterDescriptorWithDefaultT< T, S, false, ArraySize, false, std::array< T, ArraySize >, MemberPointers... >
    constexpr auto describeNodeParameters()
    Get described parameters for the passed node.
    void populateParameters(std::tuple< Ts... > &constructorArguments, const ParameterProvider &provider)
    Populate the constructor arguments using values from the parameter provider.
    constexpr std::size_t parameterSize()
    Get the number of parameters for a given node.
    constexpr auto describeParameterWithDefault(dw::core::StringView &&typeName, dw::core::StringView &&parameterName, T &&defaultValue, const MemberPointers &&... memberPointers) -> ParameterDescriptorWithDefaultT< T, S, false, 0, false, T, MemberPointers... >
    constexpr auto describeConstructorArgument(const Args &&... args) -> ConstructorArgumentDescriptorT< ConstructorArgumentT, dw::core::Tuple< Args... > >
    constexpr auto describeArrayParameter(dw::core::StringView &&typeName, dw::core::StringView &&parameterName, const MemberPointers &&... memberPointers)
    constexpr auto describeIndexParameter(dw::core::StringView &&typeName, dw::core::StringView &&parameterName, const MemberPointers &&... memberPointers)
    Definition: Buffer.hpp:41
    constexpr ConstructorArgumentDescriptorT(ParameterDescriptorsType &&parameterDescriptors_)
    std::tuple< const MemberPointers... > memberPointers
    constexpr ParameterDescriptorT(dw::core::StringView &&typeName_, dw::core::StringView &&parameterName_, const MemberPointers &&... memberPointers_)
    constexpr ParameterDescriptorWithDefaultT(dw::core::StringView &&typeName_, dw::core::StringView &&parameterName_, DefaultType &&defaultValue_, const MemberPointers &&... memberPointers_)
    人人超碰97caoporen国产