UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
TypedElementQueryStorageInterfaces.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
10#include "UObject/Class.h"
12#include "Templates/Function.h"
13
14class UClass;
15class UObject;
16class UScriptStruct;
17
19{
20 struct FQueryDescription;
21 struct ISubqueryContext;
22
25
30 {
31 virtual ~ICommonQueryContext() = default;
32
34 virtual uint32 GetRowCount() const = 0;
40
42 virtual const void* GetColumn(const UScriptStruct* ColumnType) const = 0;
44 template<TDataColumnType Column>
45 const Column* GetColumn() const;
46 template<TDynamicColumnTemplate TemplateType>
47 const TemplateType* GetColumn(const FName& Identifier) const;
49 virtual void* GetMutableColumn(const UScriptStruct* ColumnType) = 0;
51 template<typename Column>
53 template<TDynamicColumnTemplate TemplateType>
54 TemplateType* GetMutableColumn(const FName& Identifier);
55
67 virtual void GetColumnsUnguarded(int32 TypeCount, char** RetrievedAddresses, const TWeakObjectPtr<const UScriptStruct>* ColumnTypes,
68 const EQueryAccessType* AccessTypes) = 0;
69 /*
70 * Returns whether a column matches the requested type or not. This version only applies to the table that's currently set in
71 * the context. This version is faster of checking in the current row or table, but the version using a row is needed to check
72 * arbitrary rows.
73 */
74 virtual bool HasColumn(const UScriptStruct* ColumnType) const = 0;
75 /*
76 * Returns whether a column matches the requested type or not. This version only applies to the table that's currently set in
77 * the context. This version is faster of checking in the current row or table, but the version using a row is needed to check
78 * arbitrary rows.
79 */
80 template<typename Column>
81 bool HasColumn() const;
82 /*
83 * Return whether a column matches the requested type or not. This can be used for arbitrary rows. If the row is in the
84 * table that's set in the context, for instance because it's the current row, then the version that doesn't take a row
85 * as an argument is recommended.
86 */
87 virtual bool HasColumn(RowHandle Row, const UScriptStruct* ColumnType) const = 0;
88 /*
89 * Return whether a column matches the requested type or not. This can be used for arbitrary rows. If the row is in the
90 * table that's set in the context, for instance because it's the current row, then the version that doesn't take a row
91 * as an argument is recommended.
92 */
93 template<typename Column>
94 bool HasColumn(RowHandle Row) const;
95
96 template<TDynamicColumnTemplate DynamicColumnTemplate>
97 bool HasColumn(RowHandle Row, const FName& Identifier) const;
98
103 virtual const UScriptStruct* FindDynamicColumnType(const FDynamicColumnDescription& Description) const = 0;
104 template<TDynamicColumnTemplate TemplateType>
106
107 // Sets the Target's Parent if the query has a configured Hierarchy
108 virtual void SetParentRow(
109 RowHandle Target,
110 RowHandle Parent) = 0;
111
118 RowHandle Target,
120 FName MappingDomain) = 0;
121
122 // Gets the Target's Parent if the query has a configured Hierarchy
124 RowHandle Target) const = 0;
125
127 virtual float GetDeltaTimeSeconds() const = 0;
128
146 template<typename T>
148
149 virtual void PushCommand(void (*CommandFunction)(void* /*CommandData*/), void* InCommandData) = 0;
150 protected:
152 {
154 size_t Alignment;
155 void (*Construct)(void*, void*);
156 void(*Destroy)(void*);
158 };
159 // Required as the interface doesn't have direct access to any temporary handling of memory in the backend.
160 virtual void* EmplaceObjectInScratch(const FEmplaceObjectParams& Params) = 0;
161 };
162
164 {
165 using ObjectCopyOrMove = void (*)(const UScriptStruct& TypeInfo, void* Destination, void* Source);
166
170
178 template<typename DynamicColumnTemplate>
179 const DynamicColumnTemplate* GetColumn(const FName& Identifier) const;
180
188 template<typename DynamicColumnTemplate>
189 DynamicColumnTemplate* GetMutableColumn(const FName& Identifier);
190
191 /*
192 * Helper template to return whether a row has a given dynamic column.
193 */
194 template<typename DynamicColumnTemplate>
195 bool HasColumn(const FName& Identifier) const;
196
197 /*
198 * Helper template to return whether a row has a given dynamic column.
199 */
200 template<typename DynamicColumnTemplate>
201 bool HasColumn(RowHandle Row, const FName& Identifier) const;
202
208 virtual uint64 GetUpdateCycleId() const = 0;
209
211 virtual bool IsRowAvailable(RowHandle Row) const = 0;
213 virtual bool IsRowAssigned(RowHandle Row) const = 0;
214
220 virtual void ActivateQueries(FName ActivationName) = 0;
221
226
231 virtual void RemoveRow(RowHandle Row) = 0;
237
244 template<typename ColumnType>
245 ColumnType& AddColumn(RowHandle Row, ColumnType&& Column);
253 template<typename ColumnTypeTemplate>
262 template<typename ColumnTypeTemplate>
268 template<typename... Columns>
269 void AddColumns(RowHandle Row);
274 template<typename... Columns>
286
296 virtual void* AddColumnUninitialized(RowHandle Row, const UScriptStruct* ColumnType) = 0;
305 virtual void* AddColumnUninitialized(RowHandle Row, const UScriptStruct* ObjectType, ObjectCopyOrMove Relocator) = 0;
306
309
310
315 template<typename... Columns>
316 void RemoveColumns(RowHandle Row);
321 template<typename... Columns>
333 };
334
336 {
337 Default = 0, //< No settings, use the default behavior.
338 ParallelizeChunks = 1 << 0, //< If set, each chunk is processed on a separate thread.
339 /*
340 * Requires ParallelizeChunks to be set.
341 * If set together with ParallelizeChunks, each chunk will be scheduled individually. This allows work to be better
342 * distributed among threads, but comes at additional scheduling cost. Add this flag if the processing time per chunk varies.
343 */
345 IgnoreActiveState = 1 << 2, //< If set, a direct call will not check activatable queries if they're set.
346 AllowBoundQueries = 1 << 3, //< Stops checking if queries are bound when set, otherwise bound queries will assert.
347
348 IgnoreActivationCount UE_DEPRECATED("5.7", "Activation counts are no longer supported.") = IgnoreActiveState,
349 };
351
352 // For now this is an exact mirror of EDirectQueryExecutionFlags (except deprecated flags) in order to separate the old and the new
353 // query callbacks/context. Please keep both in sync until the old query callbacks/context has been fully deprecated.
355 {
356 Default = 0, //< No settings, use the default behavior.
357 ParallelizeChunks = 1 << 0, //< If set, each chunk is processed on a separate thread.
358 /*
359 * Requires ParallelizeChunks to be set.
360 * If set together with ParallelizeChunks, each chunk will be scheduled individually. This allows work to be better
361 * distributed among threads, but comes at additional scheduling cost. Add this flag if the processing time per chunk varies.
362 */
364 IgnoreActiveState = 1 << 2, //< If set, a direct call will not check activatable queries if they're set.
365 AllowBoundQueries = 1 << 3, //< Stops checking if queries are bound when set, otherwise bound queries will assert.
366 };
368
373 {
374 virtual ~IDirectQueryContext() = default;
375 };
376
381 {
382 virtual ~ISubqueryContext() = default;
383 };
384
390 {
391 virtual ~IQueryContext() = default;
392
394 virtual const UObject* GetDependency(const UClass* DependencyClass) = 0;
397
404
406 virtual RowHandle LookupMappedRow(const FName& Domain, const FMapKeyView& Index) const = 0;
407
431
432 /*UE_DEPRECATED(5.6, "Use 'LookUpMappedRow' instead and use the new FMapKey(View) instead of the explicit 'GenerateIndexHash'-functions.")
433 inline RowHandle FindIndexedRow(IndexHash Index) const;
434 UE_DEPRECATED(5.7, "Use the version of this 'LookupMappedRow' that uses a domain.")
435 inline RowHandle LookupMappedRow(const FMapKeyView& Index) const;*/
436
437
438 };
439} // namespace UE::Editor::DataStorage
440
441
442
443
444//
445// Implementations
446//
447
449{
450 //
451 // ICommonQueryContext
452 //
453
454 template<TDataColumnType Column>
455 const Column* ICommonQueryContext::GetColumn() const
456 {
457 return reinterpret_cast<const Column*>(GetColumn(Column::StaticStruct()));
458 }
459
460 template <TDynamicColumnTemplate TemplateType>
461 const TemplateType* ICommonQueryContext::GetColumn(const FName& Identifier) const
462 {
464 return static_cast<const TemplateType*>(GetColumn(DynamicColumnType));
465 }
466
467 template<typename Column>
469 {
470 return reinterpret_cast<Column*>(GetMutableColumn(Column::StaticStruct()));
471 }
472
473 template <TDynamicColumnTemplate TemplateType>
479
480 template <typename Column>
482 {
483 return HasColumn(Column::StaticStruct());
484 }
485
486 template <typename Column>
488 {
489 return HasColumn(Row, Column::StaticStruct());
490 }
491
492 template <TDynamicColumnTemplate DynamicColumnTemplate>
501
502 template <TDynamicColumnTemplate TemplateType>
504 {
506 {
507 .TemplateType = TemplateType::StaticStruct(),
508 .Identifier = Identifier
509 });
510 }
511
512 template <typename DynamicColumnTemplate>
513 const DynamicColumnTemplate* ICommonQueryWithEnvironmentContext::GetColumn(const FName& Identifier) const
514 {
515 using namespace UE::Editor::DataStorage;
516 const FDynamicColumnDescription Description
517 {
518 .TemplateType = DynamicColumnTemplate::StaticStruct(),
519 .Identifier = Identifier
520 };
521 const UScriptStruct* StructInfo = FindDynamicColumnType(Description);
522 if (StructInfo)
523 {
524 const void* ColumnData = GetColumn(StructInfo);
525 return static_cast<const DynamicColumnTemplate*>(ColumnData);
526 }
527 return nullptr;
528 }
529
530 template <typename DynamicColumnTemplate>
532 {
533 using namespace UE::Editor::DataStorage;
534 const FDynamicColumnDescription Description
535 {
536 .TemplateType = DynamicColumnTemplate::StaticStruct(),
537 .Identifier = Identifier
538 };
539 const UScriptStruct* StructInfo = FindDynamicColumnType(Description);
540 if (StructInfo)
541 {
542 const void* ColumnData = GetMutableColumn(StructInfo);
543 return static_cast<const DynamicColumnTemplate*>(ColumnData);
544 }
545 return nullptr;
546 }
547
548 template <typename DynamicColumnTemplate>
550 {
551 using namespace UE::Editor::DataStorage;
552 const FDynamicColumnDescription Description
553 {
554 .TemplateType = DynamicColumnTemplate::StaticStruct(),
555 .Identifier = Identifier
556 };
557 const UScriptStruct* StructInfo = FindDynamicColumnType(Description);
558 if (StructInfo)
559 {
560 return ICommonQueryContext::HasColumn(StructInfo);
561 }
562 return false;
563 }
564
565 template <typename DynamicColumnTemplate>
567 {
568 using namespace UE::Editor::DataStorage;
569 const FDynamicColumnDescription Description
570 {
571 .TemplateType = DynamicColumnTemplate::StaticStruct(),
572 .Identifier = Identifier
573 };
574 const UScriptStruct* StructInfo = FindDynamicColumnType(Description);
575 if (StructInfo)
576 {
577 return ICommonQueryContext::HasColumn(Row, StructInfo);
578 }
579 return false;
580 }
581
582 //
583 // ICommonQueryWithEnvironmentContext
584 //
585
586 template<typename ColumnType>
587 ColumnType& ICommonQueryWithEnvironmentContext::AddColumn(RowHandle Row, ColumnType&& Column)
588 {
589 const UScriptStruct* TypeInfo = ColumnType::StaticStruct();
590
591 if constexpr (std::is_move_constructible_v<ColumnType>)
592 {
593 void* Address = AddColumnUninitialized(Row, TypeInfo,
594 [](const UScriptStruct&, void* Destination, void* Source)
595 {
596 *reinterpret_cast<ColumnType*>(Destination) = MoveTemp(*reinterpret_cast<ColumnType*>(Source));
597 });
598 return *(new(Address) ColumnType(Forward<ColumnType>(Column)));
599 }
600 else
601 {
602 void* Address = AddColumnUninitialized(Row, TypeInfo);
603 TypeInfo->CopyScriptStruct(Address, &Column);
604 return *reinterpret_cast<ColumnType*>(Address);
605 }
606 }
607
608 template <typename ColumnTypeTemplate>
610 {
611 const UScriptStruct* TemplateType = ColumnTypeTemplate::StaticStruct();
612 const FDynamicColumnDescription Description
613 {
614 .TemplateType = TemplateType,
615 .Identifier = Identifier
616 };
617
619 {
622 return ColumnData;
623 }
625 {
626 AddColumns({Row}, {Description});
627 return nullptr;
628 }
629
630 return nullptr;
631 }
632
633 template <typename ColumnTypeTemplate>
635 {
636 const UScriptStruct* TemplateType = ColumnTypeTemplate::StaticStruct();
637 const FDynamicColumnDescription Description
638 {
639 .TemplateType = TemplateType,
640 .Identifier = Identifier
641 };
642
643 if constexpr (std::is_move_constructible_v<ColumnTypeTemplate>)
644 {
645 void* Address = AddColumnUninitialized(Row, Description,
646 [](const UScriptStruct&, void* Destination, void* Source)
647 {
648 *static_cast<ColumnTypeTemplate*>(Destination) = MoveTemp(*static_cast<ColumnTypeTemplate*>(Source));
649 });
650 return *(new(Address) ColumnTypeTemplate(Forward<ColumnTypeTemplate>(Column)));
651 }
652 else
653 {
654 void* Address = AddColumnUninitialized(Row, Description);
655 new (Address) ColumnTypeTemplate(Forward<ColumnTypeTemplate>(Column));
656 return *static_cast<ColumnTypeTemplate*>(Address);
657 }
658 }
659
660 template<typename... Columns>
662 {
663 AddColumns(Row, { Columns::StaticStruct()... });
664 }
665
666 template<typename... Columns>
668 {
669 AddColumns(Rows, { Columns::StaticStruct()... });
670 }
671
672 template<typename... Columns>
674 {
675 RemoveColumns(Row, { Columns::StaticStruct()... });
676 }
677
678 template<typename... Columns>
680 {
681 RemoveColumns(Rows, { Columns::StaticStruct()... });
682 }
683
684 template <typename T>
686 {
687 if constexpr(std::is_empty_v<T>)
688 {
689 // The command object doesn't hold any arguments so use a cheaper path that only stores the callback.
691 [](void*)
692 {
693 T Instance;
694 Instance->operator()();
695 }, nullptr);
696 }
697 else
698 {
699 // Wrapper lambda to store the type and call operator().
700 auto CommandFunction = [](void* InInstanceOfT)
701 {
702 T* Instance = static_cast<T*>(InInstanceOfT);
703 Instance->operator()();
704 };
705
707
708 Params.ObjectSize = sizeof(T);
709 Params.Alignment = alignof(T);
710 Params.Construct = [](void* Destination, void* SourceCommandContext)
711 {
712 T& SourceCommand = *static_cast<T*>(SourceCommandContext);
713 new (Destination) T(MoveTemp(SourceCommand));
714 };
715 if (std::is_trivially_destructible_v<T>)
716 {
717 Params.Destroy = nullptr;
718 }
719 else
720 {
721 Params.Destroy = [](void* EmplacedObject)
722 {
723 static_cast<T*>(EmplacedObject)->~T();
724 };
725 }
726
727 Params.SourceObject = &CommandContext;
728
730 PushCommand(CommandFunction, EmplacedCommandContext);
731 }
732 }
733
734
735
736 //
737 // IQueryContext
738 //
739
740 /*RowHandle IQueryContext::FindIndexedRow(IndexHash Index) const
741 {
742 return LookupMappedRow(NAME_None, FMapKeyView(Index));
743 }
744
745 RowHandle IQueryContext::LookupMappedRow(const FMapKeyView& Index) const
746 {
747 return LookupMappedRow(NAME_None, FMapKeyView(Index));
748 }*/
749
750} // namespace UE::Editor::DataStorage
OODEFFUNC typedef void(OODLE_CALLBACK t_fp_OodleCore_Plugin_Free)(void *ptr)
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
FPlatformTypes::uint64 uint64
A 64-bit unsigned integer.
Definition Platform.h:1117
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define ENUM_CLASS_FLAGS(Enum)
Definition EnumClassFlags.h:6
Columns EContextCapabilityFlags::SupportsBatch TConstArrayView< RowHandle >
Definition TypedElementQueryCapabilities.inl:40
TConstArrayView< const UScriptStruct * > TConstArrayView< const UScriptStruct * >
Definition TypedElementQueryCapabilities.inl:16
UE_INTRINSIC_CAST UE_REWRITE constexpr std::remove_reference_t< T > && MoveTemp(T &&Obj) noexcept
Definition UnrealTemplate.h:520
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition NameTypes.h:617
Definition ArrayView.h:139
Definition AssetRegistryState.h:50
Definition AndroidPlatformMisc.h:14
Definition Class.h:3793
Definition MapKey.h:19
Definition Object.h:95
Definition Class.h:1720
COREUOBJECT_API void CopyScriptStruct(void *Dest, void const *Src, int32 ArrayDim=1) const
Definition Class.cpp:3730
Definition CommonTypes.h:95
Definition CommonTypes.h:98
Definition CommonTypes.cpp:10
EDirectQueryExecutionFlags
Definition TypedElementQueryStorageInterfaces.h:336
uint64 TableHandle
Definition Handles.h:12
ERunQueryFlags
Definition TypedElementQueryStorageInterfaces.h:355
uint64 QueryHandle
Definition Handles.h:18
uint64 RowHandle
Definition Handles.h:15
EQueryAccessType
Definition Types.h:91
U16 Index
Definition radfft.cpp:71
Definition WeakObjectPtrTemplates.h:25
const UScriptStruct * TemplateType
Definition CommonTypes.h:73
Definition TypedElementQueryStorageInterfaces.h:152
void * SourceObject
Definition TypedElementQueryStorageInterfaces.h:157
size_t ObjectSize
Definition TypedElementQueryStorageInterfaces.h:153
size_t Alignment
Definition TypedElementQueryStorageInterfaces.h:154
void(* Destroy)(void *)
Definition TypedElementQueryStorageInterfaces.h:156
void(* Construct)(void *, void *)
Definition TypedElementQueryStorageInterfaces.h:155
Definition TypedElementQueryStorageInterfaces.h:30
Column * GetMutableColumn()
Definition TypedElementQueryStorageInterfaces.h:468
virtual const void * GetColumn(const UScriptStruct *ColumnType) const =0
const Column * GetColumn() const
Definition TypedElementQueryStorageInterfaces.h:455
virtual const UScriptStruct * FindDynamicColumnType(const FDynamicColumnDescription &Description) const =0
virtual void * EmplaceObjectInScratch(const FEmplaceObjectParams &Params)=0
void PushCommand(T CommandContext)
Definition TypedElementQueryStorageInterfaces.h:685
virtual void * GetMutableColumn(const UScriptStruct *ColumnType)=0
virtual void GetColumnsUnguarded(int32 TypeCount, char **RetrievedAddresses, const TWeakObjectPtr< const UScriptStruct > *ColumnTypes, const EQueryAccessType *AccessTypes)=0
virtual void SetParentRow(RowHandle Target, RowHandle Parent)=0
virtual void PushCommand(void(*CommandFunction)(void *), void *InCommandData)=0
virtual TConstArrayView< RowHandle > GetRowHandles() const =0
virtual void GetColumns(TArrayView< char * > RetrievedAddresses, TConstArrayView< TWeakObjectPtr< const UScriptStruct > > ColumnTypes, TConstArrayView< EQueryAccessType > AccessTypes)=0
virtual float GetDeltaTimeSeconds() const =0
virtual RowHandle GetParentRow(RowHandle Target) const =0
virtual void SetUnresolvedParent(RowHandle Target, FMapKey ParentId, FName MappingDomain)=0
virtual bool HasColumn(RowHandle Row, const UScriptStruct *ColumnType) const =0
virtual bool HasColumn(const UScriptStruct *ColumnType) const =0
bool HasColumn() const
Definition TypedElementQueryStorageInterfaces.h:481
Definition TypedElementQueryStorageInterfaces.h:164
void RemoveColumns(RowHandle Row)
Definition TypedElementQueryStorageInterfaces.h:673
Column * GetMutableColumn()
Definition TypedElementQueryStorageInterfaces.h:468
const Column * GetColumn() const
Definition TypedElementQueryStorageInterfaces.h:455
virtual void * AddColumnUninitialized(RowHandle Row, const FDynamicColumnDescription &DynamicColumnDescription, ObjectCopyOrMove Relocator)=0
ColumnType & AddColumn(RowHandle Row, ColumnType &&Column)
Definition TypedElementQueryStorageInterfaces.h:587
virtual void AddColumns(RowHandle Row, TConstArrayView< const UScriptStruct * > ColumnTypes)=0
virtual void AddColumns(TConstArrayView< RowHandle > Rows, TConstArrayView< FDynamicColumnDescription > DynamicColumnDescriptions)=0
virtual void * AddColumnUninitialized(RowHandle Row, const UScriptStruct *ColumnType)=0
virtual void * AddColumnUninitialized(RowHandle Row, const FDynamicColumnDescription &DynamicColumnDescription)=0
virtual void RemoveRows(TConstArrayView< RowHandle > Rows)=0
virtual void ActivateQueries(FName ActivationName)=0
virtual void AddColumns(TConstArrayView< RowHandle > Rows, TConstArrayView< const UScriptStruct * > ColumnTypes)=0
virtual bool IsRowAssigned(RowHandle Row) const =0
virtual void * AddColumnUninitialized(RowHandle Row, const UScriptStruct *ObjectType, ObjectCopyOrMove Relocator)=0
virtual void RemoveColumns(RowHandle Row, TConstArrayView< const UScriptStruct * > ColumnTypes)=0
virtual bool IsRowAvailable(RowHandle Row) const =0
void(*)(const UScriptStruct &TypeInfo, void *Destination, void *Source) ObjectCopyOrMove
Definition TypedElementQueryStorageInterfaces.h:165
void AddColumns(RowHandle Row)
Definition TypedElementQueryStorageInterfaces.h:661
virtual RowHandle AddRow(TableHandle Table)=0
virtual void RemoveColumns(TConstArrayView< RowHandle > Rows, TConstArrayView< const UScriptStruct * > ColumnTypes)=0
bool HasColumn() const
Definition TypedElementQueryStorageInterfaces.h:481
Definition TypedElementQueryStorageInterfaces.h:373
Definition TypedElementQueryStorageInterfaces.h:390
virtual FQueryResult RunQuery(QueryHandle Query)=0
virtual const UObject * GetDependency(const UClass *DependencyClass)=0
virtual FQueryResult RunSubquery(int32 SubqueryIndex, SubqueryCallbackRef Callback)=0
virtual RowHandle LookupMappedRow(const FName &Domain, const FMapKeyView &Index) const =0
virtual UObject * GetMutableDependency(const UClass *DependencyClass)=0
virtual FQueryResult RunSubquery(int32 SubqueryIndex)=0
virtual void GetDependencies(TArrayView< UObject * > RetrievedAddresses, TConstArrayView< TWeakObjectPtr< const UClass > > DependencyTypes, TConstArrayView< EQueryAccessType > AccessTypes)=0
virtual FQueryResult RunSubquery(int32 SubqueryIndex, RowHandle Row, SubqueryCallbackRef Callback)=0
Definition TypedElementQueryStorageInterfaces.h:381