// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #include "TraceServices/AnalysisService.h" // Insights #include "Insights/Table/ViewModels/BaseTreeNode.h" #include "Insights/Table/ViewModels/TableCellValue.h" namespace Insights { class FTable; struct FTableRowId { static constexpr int32 InvalidRowIndex = -1; FTableRowId(int32 InRowIndex): RowIndex(InRowIndex), Flags(0) {} bool HasValidIndex() const { return RowIndex >= 0; } int32 RowIndex; uint32 Flags; }; //////////////////////////////////////////////////////////////////////////////////////////////////// class FTableTreeNode; /** Type definition for shared pointers to instances of FTableTreeNode. */ typedef TSharedPtr FTableTreeNodePtr; /** Type definition for shared references to instances of FTableTreeNode. */ typedef TSharedRef FTableTreeNodeRef; /** Type definition for shared references to const instances of FTableTreeNode. */ typedef TSharedRef FTableTreeNodeRefConst; /** Type definition for weak references to instances of FTableTreeNode. */ typedef TWeakPtr FTableTreeNodeWeak; //////////////////////////////////////////////////////////////////////////////////////////////////// /** * Table Tree Node View Model. * Class used to store information about a generic table tree node (used in STableTreeView). */ class FTableTreeNode: public FBaseTreeNode { public: static const FName TypeName; public: /** Initialization constructor for a table record node. */ FTableTreeNode(const FName InName, TWeakPtr InParentTable, int32 InRowIndex) : FBaseTreeNode(InName, false), ParentTable(InParentTable), RowId(InRowIndex) { } /** Initialization constructor for a group node. */ FTableTreeNode(const FName InGroupName, TWeakPtr InParentTable) : FBaseTreeNode(InGroupName, true), ParentTable(InParentTable), RowId(FTableRowId::InvalidRowIndex) { } virtual const FName& GetTypeName() const override { return TypeName; } TWeakPtr GetParentTable() { return ParentTable; } FTableRowId GetRowId() const { return RowId; } int32 GetRowIndex() const { return RowId.RowIndex; } void ResetAggregatedValues() { AggregatedValues.Reset(); } bool HasAggregatedValue(const FName& ColumnId) const { return AggregatedValues.Contains(ColumnId); } const FTableCellValue* FindAggregatedValue(const FName& ColumnId) const { return AggregatedValues.Find(ColumnId); } const FTableCellValue& GetAggregatedValue(const FName& ColumnId) const { return AggregatedValues.FindChecked(ColumnId); } void AddAggregatedValue(const FName& ColumnId, const FTableCellValue& Value) { AggregatedValues.Add(ColumnId, Value); } void SetAggregatedValue(const FName& ColumnId, const FTableCellValue& Value) { AggregatedValues[ColumnId] = Value; } protected: TWeakPtr ParentTable; FTableRowId RowId; TMap AggregatedValues; }; //////////////////////////////////////////////////////////////////////////////////////////////////// } // namespace Insights