UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TypedElementQueryFunctionArguments.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include <type_traits>
10#include "Misc/EnumClassFlags.h"
11#include "Templates/Tuple.h"
12
13class UScriptStruct;
14
16{
17 template<typename T>
18 using UnreferencedType = std::remove_reference_t<std::remove_pointer_t<T>>;
19 template<typename T>
20 using FoundationalType = std::remove_cv_t<UnreferencedType<T>>;
21 template<typename T> concept ContextType = std::is_base_of_v<FQueryContext, T>;
22
23 enum class EArgumentFlags
24 {
25 IsConst = 1 << 0, // Indicates the data is immutable.
26 IsMutable = 1 << 1, // Indicates that the data can change.
27 SingleArgument = 1 << 2, // The argument can be used when a single row is being processed.
28 BatchArgument = 1 << 3, // The argument can be used when a batch of rows is being processed.
29
30 Type_Result = 1 << 4, // The argument is used to pass back results.
31 Type_Context = 1 << 5, // The argument contains contextual information about the current row or batch.
32 Type_RowHandle = 1 << 6, // The argument stores a row handle.
33 Type_Column = 1 << 7, // The argument stores a column, including data columns and tag columns.
34 Type_FlowControl = 1 << 8, // The argument can be used to control the next iteration step, including stopping work.
35 };
37
38 // Wrapper around a pointer to act as a reference.
39 template<typename T>
41 {
42 TPointerForwarder() = default;
45
46 operator T& () const { return *Value; }
47 void Increment() { Value++; }
48
49 T* Value = nullptr;
50 };
51
52 // Base descriptor for query callback function arguments. Not directly usable and requires specializations.
53 template<typename T>
54 struct TArgument
55 {
56 static_assert(!std::is_same_v<T, void>, "Unsupported argument type for query callback.");
57 };
58
59 // Void type (used as a placeholder)
60 template<>
62 {
63 constexpr static EArgumentFlags Flags = EArgumentFlags(0);
64 using BaseType = void;
68 };
69
70 // Result type
71 template<typename T>
73 {
74 static constexpr bool bIsValid = false;
75 using BaseType = void;
76 };
77 template<typename T>
79 {
80 static constexpr bool bIsValid = true;
81 using BaseType = T;
82 };
83
84 template<typename T> requires ResultTypeInfo<FoundationalType<T>>::bIsValid
85 struct TArgument<T>
86 {
87 static_assert(std::is_reference_v<T>, "Results can only be accessed by reference.");
88 static_assert(!std::is_const_v<T>, "Results requires write access to function.");
89
90 constexpr static EArgumentFlags Flags =
92 using BaseType = typename ResultTypeInfo<FoundationalType<T>>::BaseType;
95 using PointerCastType = void*;
96 };
97
98 // Context type
99 template<typename T> requires ContextType<FoundationalType<T>>
100 struct TArgument<T>
101 {
102 static_assert(!std::is_reference_v<T> && !std::is_pointer_v<T>, "The contexts can only be passed in by value.");
103
105 using ContextCapabilities = BaseType::Capabilities;
106
107 constexpr static EArgumentFlags Flags =
108 (ContextCapabilities::bIsSingle ? EArgumentFlags::SingleArgument : EArgumentFlags(0)) |
109 (ContextCapabilities::bIsBatch ? EArgumentFlags::BatchArgument : EArgumentFlags(0)) |
112 using ArgumentType = BaseType; // Take by value because the context is a forwarder that only stores a single pointer.
114 using PointerCastType = void*;
115 };
116
117 // Column reference types
118 template<typename T> requires TColumnType<FoundationalType<T>>
119 struct TArgument<T>
120 {
121 static_assert(!std::is_pointer_v<T>, "Pointers to columns to work with batches are no longer supported. Use TBatch instead.");
122 static_assert(std::is_reference_v<T>, "Columns can only be accessed by reference.");
123
124 static constexpr bool bIsConst = std::is_const_v<UnreferencedType<T>>;
125
126 constexpr static EArgumentFlags Flags =
133 using PointerCastType = std::conditional_t<bIsConst, const BaseType*, BaseType*>;
134 };
135
136 // Column batch types
137 template<typename T> requires TColumnType<T>
138 struct TArgument<TBatch<T>>
139 {
140 static constexpr bool bIsConst = std::is_const_v<UnreferencedType<T>>;
141
142 constexpr static EArgumentFlags Flags =
146 using BaseType = T;
149 using PointerCastType = std::conditional_t<bIsConst, const BaseType*, BaseType*>;
150 };
151
152 // Flow control
153 template<typename T> requires std::is_same_v<FoundationalType<T>, EFlowControl>
154 struct TArgument<T>
155 {
156 static_assert(std::is_reference_v<T>, "Flow control can only be accessed by reference.");
157 static_assert(!std::is_const_v<T>, "Flow control requires write access to function.");
158
159 constexpr static EArgumentFlags Flags =
165 };
166
167 template<int32 Index, typename... Args>
169
170 template<int32 Index, typename Front, typename... Args>
172 {
173 using Type =
174 std::conditional_t<Index < 0, TArgument<void>,
175 std::conditional_t<Index == 0, TArgument<Front>,
176 typename TIndexToArgInfoImpl<Index - 1, Args...>::Type>>;
177 };
178
179 template<int32 Index>
180 struct TIndexToArgInfoImpl<Index> // Empty argument list.
181 {
183 };
184
185 template<int32 Index, typename... Args>
187
188 template<typename... Args>
190 {
191 private:
192 template<EArgumentFlags TypeFlag>
193 constexpr static int32 FirstIndexOfType();
194
195 template<EArgumentFlags Flags>
196 constexpr static int32 CountFlags();
197
198 template<EArgumentFlags Flags>
199 static TConstArrayView<const UScriptStruct*> ListColumns();
200
201 public:
204
205 static_assert(bIsSingle || bIsBatch, "One or more query callback arguments for single or batch processing were mixed.");
206
208
210 using ResultType = typename TIndexToArgInfo<ResultIndex, Args...>::BaseType;
211 template<typename T>
212 static void SetResult(ArgumentList& Arguments, TResult<T>& Result);
213 constexpr static int32 CountResults();
214
216 using ContextType = typename TIndexToArgInfo<ContextIndex, Args...>::BaseType;
217 static void SetContext(ArgumentList& Arguments, IContextContract& Contract);
218 constexpr static int32 CountContexts();
219
221 static void SetFlowControl(ArgumentList& Arguments, EFlowControl& FlowControl);
222 constexpr static int32 CountFlowControls();
223
224 constexpr static int32 CountConstColumns();
225 constexpr static int32 CountMutableColumns();
228 static void SetConstColumns(ArgumentList& Arguments, TConstArrayView<const void*> Columns);
229 static void SetMutableColumns(ArgumentList& Arguments, TConstArrayView<void*> Columns);
230 static void IncrementColumns(ArgumentList& Arguments);
231
232 private:
233 template<int32 Index, typename T>
234 static void SetResultUnguarded(ArgumentList& Arguments, TResult<T>& Result);
235 template<int32 Index>
236 static void SetContextUnguarded(ArgumentList& Arguments, IContextContract& Contract);
237 template<int32 Index>
238 static void SetFlowControlUnguarded(ArgumentList& Arguments, EFlowControl& FlowControl);
239 template<typename ArgumentType>
240 static void IncrementColumnUnguarded(ArgumentList& Arguments);
241 };
242} // namespace UE::Editor::DataStorage::Queries::Private
243
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
constexpr bool EnumHasAnyFlags(Enum Flags, Enum Contains)
Definition EnumClassFlags.h:35
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
TConstArrayView< const UScriptStruct * > TConstArrayView< const UScriptStruct * >
Definition TypedElementQueryCapabilities.inl:16
Definition TypedElementQueryFunctionArgumentTypes.h:59
Definition Class.h:1720
Definition TypedElementQueryFunctionArguments.h:21
Definition CommonTypes.h:101
Definition TypedElementQueryBuilder.cpp:566
std::remove_cv_t< UnreferencedType< T > > FoundationalType
Definition TypedElementQueryFunctionArguments.h:20
std::remove_reference_t< std::remove_pointer_t< T > > UnreferencedType
Definition TypedElementQueryFunctionArguments.h:18
typename TIndexToArgInfoImpl< Index, Args... >::Type TIndexToArgInfo
Definition TypedElementQueryFunctionArguments.h:186
EArgumentFlags
Definition TypedElementQueryFunctionArguments.h:24
const UScriptStruct * Type(FTopLevelAssetPath Name)
Definition TypedElementQueryBuilder.cpp:15
EFlowControl
Definition TypedElementQueryFunctionArgumentTypes.h:32
U16 Index
Definition radfft.cpp:71
Definition Tuple.h:652
Definition TypedElementQueryContract.h:113
T BaseType
Definition TypedElementQueryFunctionArguments.h:81
Definition TypedElementQueryFunctionArguments.h:73
void BaseType
Definition TypedElementQueryFunctionArguments.h:75
static constexpr bool bIsValid
Definition TypedElementQueryFunctionArguments.h:74
Definition TypedElementQueryFunctionArguments.h:190
static void SetContext(ArgumentList &Arguments, IContextContract &Contract)
Definition TypedElementQueryFunctionArguments.inl:65
static void SetConstColumns(ArgumentList &Arguments, TConstArrayView< const void * > Columns)
Definition TypedElementQueryFunctionArguments.inl:151
typename TIndexToArgInfo< ResultIndex, Args... >::BaseType ResultType
Definition TypedElementQueryFunctionArguments.h:210
static void IncrementColumns(ArgumentList &Arguments)
Definition TypedElementQueryFunctionArguments.inl:177
static constexpr bool bIsBatch
Definition TypedElementQueryFunctionArguments.h:203
static void SetMutableColumns(ArgumentList &Arguments, TConstArrayView< void * > Columns)
Definition TypedElementQueryFunctionArguments.inl:164
static TConstArrayView< const UScriptStruct * > ListMutableColumns()
Definition TypedElementQueryFunctionArguments.inl:145
static constexpr int32 FlowIndex
Definition TypedElementQueryFunctionArguments.h:220
static constexpr bool bIsSingle
Definition TypedElementQueryFunctionArguments.h:202
static void SetResult(ArgumentList &Arguments, TResult< T > &Result)
Definition TypedElementQueryFunctionArguments.inl:50
static TConstArrayView< const UScriptStruct * > ListConstColumns()
Definition TypedElementQueryFunctionArguments.inl:139
static constexpr int32 CountMutableColumns()
Definition TypedElementQueryFunctionArguments.inl:101
static constexpr int32 ContextIndex
Definition TypedElementQueryFunctionArguments.h:215
static void SetFlowControl(ArgumentList &Arguments, EFlowControl &FlowControl)
Definition TypedElementQueryFunctionArguments.inl:80
static constexpr int32 CountFlowControls()
Definition TypedElementQueryFunctionArguments.inl:89
static constexpr int32 CountConstColumns()
Definition TypedElementQueryFunctionArguments.inl:95
static constexpr int32 CountResults()
Definition TypedElementQueryFunctionArguments.inl:59
static constexpr int32 CountContexts()
Definition TypedElementQueryFunctionArguments.inl:74
static constexpr int32 ResultIndex
Definition TypedElementQueryFunctionArguments.h:209
T BaseType
Definition TypedElementQueryFunctionArguments.h:146
std::conditional_t< bIsConst, const BaseType *, BaseType * > PointerCastType
Definition TypedElementQueryFunctionArguments.h:149
BaseType ColumnType
Definition TypedElementQueryFunctionArguments.h:148
void * PointerCastType
Definition TypedElementQueryFunctionArguments.h:95
BaseType::Capabilities ContextCapabilities
Definition TypedElementQueryFunctionArguments.h:105
void ColumnType
Definition TypedElementQueryFunctionArguments.h:94
typename ResultTypeInfo< FoundationalType< T > >::BaseType BaseType
Definition TypedElementQueryFunctionArguments.h:92
Definition TypedElementQueryFunctionArguments.h:62
void ColumnType
Definition TypedElementQueryFunctionArguments.h:66
void ArgumentType
Definition TypedElementQueryFunctionArguments.h:65
void PointerCastType
Definition TypedElementQueryFunctionArguments.h:67
void BaseType
Definition TypedElementQueryFunctionArguments.h:64
Definition TypedElementQueryFunctionArguments.h:55
std::conditional_t< Index< 0, TArgument< void >, std::conditional_t< Index==0, TArgument< Front >, typename TIndexToArgInfoImpl< Index - 1, Args... >::Type > > Type
Definition TypedElementQueryFunctionArguments.h:176
Definition TypedElementQueryFunctionArguments.h:168
Definition TypedElementQueryFunctionArguments.h:41
T * Value
Definition TypedElementQueryFunctionArguments.h:49
TPointerForwarder(T *Value)
Definition TypedElementQueryFunctionArguments.h:43
void Increment()
Definition TypedElementQueryFunctionArguments.h:47
TPointerForwarder & operator=(T *InValue)
Definition TypedElementQueryFunctionArguments.h:44
Definition TypedElementQueryFunctionArgumentTypes.h:46