Files
UnrealEngineUWP/Engine/Source/Developer/LogVisualizer/Private/VisualLoggerDatabase.h
Ben Marsh 4ba423868f Copying //UE4/Dev-Build to //UE4/Dev-Main (Source: //UE4/Dev-Build @ 3209340)
#lockdown Nick.Penwarden
#rb none

==========================
MAJOR FEATURES + CHANGES
==========================

Change 3209340 on 2016/11/23 by Ben.Marsh

	Convert UE4 codebase to an "include what you use" model - where every header just includes the dependencies it needs, rather than every source file including large monolithic headers like Engine.h and UnrealEd.h.

	Measured full rebuild times around 2x faster using XGE on Windows, and improvements of 25% or more for incremental builds and full rebuilds on most other platforms.

	  * Every header now includes everything it needs to compile.
	        * There's a CoreMinimal.h header that gets you a set of ubiquitous types from Core (eg. FString, FName, TArray, FVector, etc...). Most headers now include this first.
	        * There's a CoreTypes.h header that sets up primitive UE4 types and build macros (int32, PLATFORM_WIN64, etc...). All headers in Core include this first, as does CoreMinimal.h.
	  * Every .cpp file includes its matching .h file first.
	        * This helps validate that each header is including everything it needs to compile.
	  * No engine code includes a monolithic header such as Engine.h or UnrealEd.h any more.
	        * You will get a warning if you try to include one of these from the engine. They still exist for compatibility with game projects and do not produce warnings when included there.
	        * There have only been minor changes to our internal games down to accommodate these changes. The intent is for this to be as seamless as possible.
	  * No engine code explicitly includes a precompiled header any more.
	        * We still use PCHs, but they're force-included on the compiler command line by UnrealBuildTool instead. This lets us tune what they contain without breaking any existing include dependencies.
	        * PCHs are generated by a tool to get a statistical amount of coverage for the source files using it, and I've seeded the new shared PCHs to contain any header included by > 15% of source files.

	Tool used to generate this transform is at Engine\Source\Programs\IncludeTool.

[CL 3209342 by Ben Marsh in Main branch]
2016-11-23 15:48:37 -05:00

210 lines
7.7 KiB
C++

// Copyright 1998-2016 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "VisualLogger/VisualLoggerTypes.h"
class AActor;
struct FVisualLoggerDBRow;
struct FVisualLoggerDBEvents
{
DECLARE_MULTICAST_DELEGATE_TwoParams(FItemSelectionChangedEvent, const FVisualLoggerDBRow&, int32);
DECLARE_MULTICAST_DELEGATE_TwoParams(FNewItemEvent, const FVisualLoggerDBRow&, int32);
DECLARE_MULTICAST_DELEGATE_OneParam(FNewRowEvent, const FVisualLoggerDBRow&);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnRowSelectionChangedEvent, const TArray<FName>&);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnRowChangedVisibilityEvent, const FName&);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnRowRemovedEvent, const FName&);
DECLARE_MULTICAST_DELEGATE_OneParam(FOnGraphChangedVisibilityEvent, const FName&);
DECLARE_MULTICAST_DELEGATE_TwoParams(FOnGraphAddedEvent, const FName&, const FName&);
DECLARE_MULTICAST_DELEGATE_ThreeParams(FOnGraphDataNameAddedEvent, const FName&, const FName&, const FName&);
FNewItemEvent OnNewItem;
FItemSelectionChangedEvent OnItemSelectionChanged;
FNewRowEvent OnNewRow;
FOnRowSelectionChangedEvent OnRowSelectionChanged;
FOnRowChangedVisibilityEvent OnRowChangedVisibility;
FOnRowRemovedEvent OnRowRemoved;
FOnGraphChangedVisibilityEvent OnGraphChangedVisibilityEvent;
FOnGraphAddedEvent OnGraphAddedEvent;
FOnGraphDataNameAddedEvent OnGraphDataNameAddedEvent;
};
struct FVisualLoggerDBRow
{
public:
FVisualLoggerDBRow(FVisualLoggerDBEvents& InEvents, const FName& InOwnerName, const FName& InOwnerClassName) : DBEvents(InEvents), OwnerName(InOwnerName), OwnerClassName(InOwnerClassName), CurrentItemIndex(INDEX_NONE) {}
const FName& GetOwnerName() const { return OwnerName; }
const FName& GetOwnerClassName() const { return OwnerClassName; }
void AddItem(const FVisualLogDevice::FVisualLogEntryItem& NewItem);
const TArray<FVisualLogDevice::FVisualLogEntryItem>& GetItems() const { return Items; }
void MoveTo(int32 Index);
const FVisualLogDevice::FVisualLogEntryItem& GetCurrentItem() const;
int32 GetCurrentItemIndex() const { return CurrentItemIndex; }
void SetItemVisibility(int32 ItemIndex, bool IsVisible);
bool IsItemVisible(int32 ItemIndex) const { return HiddenItems.Find(ItemIndex) == INDEX_NONE; }
int32 GetNumberOfHiddenItems() const { return HiddenItems.Num(); }
int32 GetClosestItem(float Time) const;
int32 GetClosestItem(float Time, float ScrubTime) const;
protected:
FVisualLoggerDBEvents& DBEvents;
FName OwnerName;
FName OwnerClassName;
int32 CurrentItemIndex;
TArray<FVisualLogDevice::FVisualLogEntryItem> Items;
TArray<int32> HiddenItems;
};
struct FVisualLoggerDatabase
{
typedef TArray<FVisualLoggerDBRow>::TConstIterator FConstRowIterator;
typedef TArray<FVisualLoggerDBRow>::TIterator FRowIterator;
static FVisualLoggerDatabase& Get();
static void Initialize();
static void Shutdown();
void Reset();
FVisualLoggerDBEvents& GetEvents() { return DBEvents; }
int32 NumberOfRows() { return Rows.Num(); }
void AddItem(const FVisualLogDevice::FVisualLogEntryItem& NewItem);
FConstRowIterator GetConstRowIterator() const { return Rows.CreateConstIterator(); }
FRowIterator GetRowIterator() { return Rows.CreateIterator(); }
bool ContainsRowByName(FName InName);
FVisualLoggerDBRow& GetRowByName(FName InName);
void SelectRow(FName InName, bool bDeselectOtherNodes = false);
void DeselectRow(FName InName);
bool IsRowSelected(FName InName) const { return SelectedRows.Find(InName) != INDEX_NONE; }
const TArray<FName>& GetSelectedRows() const;
bool IsRowVisible(FName RowName) const { return HiddenRows.Find(RowName) == INDEX_NONE; }
void SetRowVisibility(FName RowName, bool IsVisible);
void RemoveRow(FName RowName);
protected:
TArray<FVisualLoggerDBRow> Rows;
TMap<FName, int32> RowNameToIndex;
TArray<FName> SelectedRows;
TArray<FName> HiddenRows;
FVisualLoggerDBEvents DBEvents;
private:
static TSharedPtr< struct FVisualLoggerDatabase > StaticInstance;
};
struct FVisualLoggerGraphData
{
FName DataName;
TArray<FVector2D> Samples;
TArray<float> TimeStamps;
FVisualLoggerGraphData(FName InDataName) : DataName(InDataName) {}
};
struct FVisualLoggerGraph
{
typedef TArray<FVisualLoggerGraphData>::TConstIterator FConstDataIterator;
typedef TArray<FVisualLoggerGraphData>::TIterator FDataIterator;
FVisualLoggerGraph(FName InOwnerName) : OwnerName(InOwnerName) {}
FName GetOwnerName() const { return OwnerName; }
FName GetGraphName() const { return GraphName; }
void SetGraphName(FName InGraphName) { GraphName = InGraphName; }
bool IsDataVisible(FName DataName) const;
void SetDataVisibility(FName DataName, bool IsVisible);
bool ContainsDataByName(FName DataName) const { return DataNameToIndex.Contains(DataName); };
FVisualLoggerGraphData& FindOrAddDataByName(FName DataName);
FConstDataIterator GetConstDataIterator() const { return DataGraphs.CreateConstIterator(); }
FDataIterator GetDataIterator() { return DataGraphs.CreateIterator(); }
protected:
FName OwnerName;
FName GraphName;
TArray<FVisualLoggerGraphData> DataGraphs;
TMap<FName, int32> DataNameToIndex;
TArray<FName> HiddenGraphs;
};
struct FVisualLoggerGraphsDatabase //histogram graphs database as separate structure to optimize access and category filters
{
protected:
struct FVisualLoggerGraphHelper
{
TArray<FVisualLoggerGraph> AllGraphs;
TMap<FName, int32> GraphNameToIndex;
};
public:
typedef TArray<FVisualLoggerGraph>::TConstIterator FConstGraphIterator;
typedef TArray<FVisualLoggerGraph>::TIterator FGraphIterator;
typedef TMap<FName, FVisualLoggerGraphHelper>::TConstIterator FConstOwnersIterator;
typedef TMap<FName, FVisualLoggerGraphHelper>::TIterator FOwnersIterator;
static FVisualLoggerGraphsDatabase& Get();
static void Initialize();
static void Shutdown();
void Reset();
void AddItem(const FVisualLogDevice::FVisualLogEntryItem& NewItem);
bool IsGraphVisible(FName OwnerName, FName GraphName);
void SetGraphVisibility(FName OwnerName, FName GraphName, bool IsVisible);
bool ContainsGraphByName(FName OwnerName, FName GraphName);
FVisualLoggerGraph& GetGraphByName(FName OwnerName, FName GraphName);
bool ContainsHistogramGraphs() const { return OwnerNameToGraphs.Num() > 0; }
const TArray<FVisualLoggerGraph>& GetGraphsByOwnerName(FName OwnerName);
FConstGraphIterator GetConstGraphsIterator(FName OwnerName) { return OwnerNameToGraphs.FindOrAdd(OwnerName).AllGraphs.CreateConstIterator(); }
FGraphIterator GetGraphsIterator(FName OwnerName) { return OwnerNameToGraphs.FindOrAdd(OwnerName).AllGraphs.CreateIterator(); }
FConstOwnersIterator GetConstOwnersIterator() { return OwnerNameToGraphs.CreateConstIterator(); }
FOwnersIterator GetOwnersIterator() { return OwnerNameToGraphs.CreateIterator(); }
protected:
TMap<FName, FVisualLoggerGraphHelper> OwnerNameToGraphs;
TArray<FName> HiddenGraphs; //encoded as "OwnerName$GraphName" for simplicity.
private:
static TSharedPtr< struct FVisualLoggerGraphsDatabase > StaticInstance;
};
struct FVisualLoggerEditorInterface : public IVisualLoggerEditorInterface
{
static IVisualLoggerEditorInterface* Get() { static FVisualLoggerEditorInterface EditorInterface; return &EditorInterface; }
const FName& GetRowClassName(FName RowName) const override;
int32 GetSelectedItemIndex(FName RowName) const override;
const TArray<FVisualLogDevice::FVisualLogEntryItem>& GetRowItems(FName RowName) override;
const FVisualLogDevice::FVisualLogEntryItem& GetSelectedItem(FName RowName) const override;
const TArray<FName>& GetSelectedRows() const override;
bool IsRowVisible(FName RowName) const override;
bool IsItemVisible(FName RowName, int32 ItemIndex) const override;
UWorld* GetWorld() const override;
AActor* GetHelperActor(UWorld* InWorld = nullptr) const override;
bool MatchCategoryFilters(const FString& String, ELogVerbosity::Type Verbosity = ELogVerbosity::All) override;
};