/**************************************************************************** * Copyright (c) 2024 PX4 Development Team. * SPDX-License-Identifier: BSD-3-Clause ****************************************************************************/ #pragma once #include #include #include #include /** * Helper struct to store template parameter packs */ template struct Pack { }; /** * Struct for a template parameter pack with access to the individual types */ template struct TypesArray { template struct TypeHelper { using Type = T; using Next = TypeHelper; }; using Type1 = typename TypeHelper::Type; using Type2 = typename TypeHelper::Next::Type; using Type3 = typename TypeHelper::Next::Next::Type; using Type4 = typename TypeHelper::Next::Next::Next::Type; using Type5 = typename TypeHelper::Next::Next::Next::Next::Type; using Type6 = typename TypeHelper::Next::Next::Next::Next::Next::Type; using args = Pack; }; /** * Helper for call_translation_function() */ template inline void call_translation_function_impl(F f, Pack, Pack, const std::vector>& messages_in, std::vector>& messages_out, std::integer_sequence, std::integer_sequence) { f(*static_cast(messages_in[Is].get())..., *static_cast(messages_out[Os].get())...); } /** * Call a translation function F which takes the arguments (const ArgsIn&..., ArgsOut&...), * by passing messages_in and messages_out as arguments. * Note that sizeof(ArgsIn) == messages_in.length() && sizeof(ArgsOut) == messages_out.length() must hold. */ template inline void call_translation_function(F f, Pack pack_in, Pack pack_out, const std::vector>& messages_in, std::vector>& messages_out) { call_translation_function_impl(f, pack_in, pack_out, messages_in, messages_out, std::index_sequence_for{}, std::index_sequence_for{}); }