Plasma Engine  2.0
Loading...
Searching...
No Matches
AssetDocumentManager.h
1#pragma once
2
3#include <EditorFramework/Assets/AssetDocumentInfo.h>
4#include <EditorFramework/Assets/Declarations.h>
5#include <EditorFramework/EditorFrameworkDLL.h>
6#include <Foundation/Types/Status.h>
7#include <ToolsFoundation/Document/DocumentManager.h>
8
9struct plSubAsset;
11
12class PL_EDITORFRAMEWORK_DLL plAssetDocumentManager : public plDocumentManager
13{
14 PL_ADD_DYNAMIC_REFLECTION(plAssetDocumentManager, plDocumentManager);
15
16public:
19
21 virtual plStatus ReadAssetDocumentInfo(plUniquePtr<plAssetDocumentInfo>& out_pInfo, plStreamReader& inout_stream) const;
22 virtual void FillOutSubAssetList(const plAssetDocumentInfo& assetInfo, plDynamicArray<plSubAssetData>& out_subAssets) const {}
23
26 virtual plStatus GetAdditionalOutputs(plDynamicArray<plString>& ref_files) { return plStatus(PL_SUCCESS); }
27
28 // plDocumentManager overrides:
29public:
30 virtual plStatus CloneDocument(plStringView sPath, plStringView sClonePath, plUuid& inout_cloneGuid) override;
31
34public:
36 void ComputeAssetProfileHash(const plPlatformProfile* pAssetProfile);
37
39 PL_ALWAYS_INLINE plUInt64 GetAssetProfileHash() const { return m_uiAssetProfileHash; }
40
42 static const plPlatformProfile* DetermineFinalTargetProfile(const plPlatformProfile* pAssetProfile);
43
44private:
45 virtual plUInt64 ComputeAssetProfileHashImpl(const plPlatformProfile* pAssetProfile) const;
46
47 // The hash that is combined with the asset document hash to determine whether the document output is up to date.
48 // This hash needs to be computed in ComputeAssetProfileHash() and should reflect all important settings from the givne asset profile that
49 // affect the asset output for this manager.
50 // However, if GeneratesProfileSpecificAssets() return false, the hash must be zero, as then all outputs must be identical in all
51 // profiles.
52 plUInt64 m_uiAssetProfileHash = 0;
53
57public:
59 virtual plString GenerateResourceThumbnailPath(plStringView sDocumentPath, plStringView sSubAssetName = plStringView());
60 virtual bool IsThumbnailUpToDate(plStringView sDocumentPath, plStringView sSubAssetName, plUInt64 uiThumbnailHash, plUInt32 uiTypeVersion);
61
65
66 virtual void AddEntriesToAssetTable(plStringView sDataDirectory, const plPlatformProfile* pAssetProfile, plDelegate<void(plStringView sGuid, plStringView sPath, plStringView sType)> addEntry) const;
67 virtual plString GetAssetTableEntry(const plSubAsset* pSubAsset, plStringView sDataDirectory, const plPlatformProfile* pAssetProfile) const;
68
70 plString GetAbsoluteOutputFileName(const plAssetDocumentTypeDescriptor* pTypeDesc, plStringView sDocumentPath, plStringView sOutputTag, const plPlatformProfile* pAssetProfile = nullptr) const;
71
73 virtual plString GetRelativeOutputFileName(const plAssetDocumentTypeDescriptor* pTypeDesc, plStringView sDataDirectory, plStringView sDocumentPath, plStringView sOutputTag, const plPlatformProfile* pAssetProfile = nullptr) const;
74 virtual bool GeneratesProfileSpecificAssets() const = 0;
75
76 bool IsOutputUpToDate(plStringView sDocumentPath, const plDynamicArray<plString>& outputs, plUInt64 uiHash, const plAssetDocumentTypeDescriptor* pTypeDescriptor);
77 virtual bool IsOutputUpToDate(plStringView sDocumentPath, plStringView sOutputTag, plUInt64 uiHash, const plAssetDocumentTypeDescriptor* pTypeDescriptor);
78
83 enum OutputReliability : plUInt8
84 {
85 Unknown = 0,
86 Good = 1,
87 Perfect = 2,
88 };
89
91 virtual OutputReliability GetAssetTypeOutputReliability() const { return OutputReliability::Unknown; }
92
94
95
97 virtual plResult OpenPickedDocument(const plDocumentObject* pPickedComponent, plUInt32 uiPartIndex) { return PL_FAILURE; }
98
99 plResult TryOpenAssetDocument(const char* szPathOrGuid);
100
106
107protected:
108 static bool IsResourceUpToDate(const char* szResourceFile, plUInt64 uiHash, plUInt16 uiTypeVersion);
109 static void GenerateOutputFilename(plStringBuilder& inout_sRelativeDocumentPath, const plPlatformProfile* pAssetProfile, const char* szExtension, bool bPlatformSpecific);
110};
Definition AssetDocumentInfo.h:7
Definition AssetDocumentManager.h:13
PL_ALWAYS_INLINE plUInt64 GetAssetProfileHash() const
Returns the hash that was previously computed through ComputeAssetProfileHash().
Definition AssetDocumentManager.h:39
OutputReliability
Definition AssetDocumentManager.h:84
virtual OutputReliability GetAssetTypeOutputReliability() const
Definition AssetDocumentManager.h:91
virtual void GetAssetTypesRequiringTransformForSceneExport(plSet< plTempHashedString > &inout_assetTypes)
Definition AssetDocumentManager.h:105
virtual plStatus GetAdditionalOutputs(plDynamicArray< plString > &ref_files)
Definition AssetDocumentManager.h:26
virtual plResult OpenPickedDocument(const plDocumentObject *pPickedComponent, plUInt32 uiPartIndex)
Called by the editor to try to open a document for the matching picking result.
Definition AssetDocumentManager.h:97
Definition DocumentManager.h:8
Definition DocumentObjectBase.h:11
Definition DynamicArray.h:81
Definition PlatformProfile.h:25
Definition Set.h:238
Interface for binary in (read) streams.
Definition Stream.h:22
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A Unique ptr manages an object and destroys that object when it goes out of scope....
Definition UniquePtr.h:10
This data type is the abstraction for 128-bit Uuid (also known as GUID) instances.
Definition Uuid.h:11
Definition Declarations.h:89
A generic delegate class which supports static functions and member functions.
Definition Delegate.h:76
Default enum for returning failure or success, instead of using a bool.
Definition Types.h:54
An plResult with an additional message for the reason of failure.
Definition Status.h:12
Information about an asset or sub-asset.
Definition AssetCurator.h:107