2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# pragma once
2015-07-09 14:24:02 -04:00
class FTextFilterExpressionEvaluator ;
2015-06-19 07:33:02 -04:00
struct ECollectionVersion
{
enum Type
{
_ZeroVersion = 0 ,
/** The initial version for collection files */
Initial ,
/**
* Added GUIDs to collections to allow them to be used as a parent of another collection without relying on their name / share - type combo
* Collections that are older than this version must be re - saved before they can be used as a parent for another collection
*/
AddedCollectionGuid ,
/** -----<new versions can be added before this line>------------------------------------------------- */
_AutomaticVersionPlusOne ,
CurrentVersion = _AutomaticVersionPlusOne - 1
} ;
} ;
enum class ECollectionCloneMode : uint8
{
/** Clone this collection exactly as it is now, preserving its existing GUID data */
Exact ,
/** Clone this collection, but make sure it gets unique GUIDs */
Unique ,
} ;
2014-03-14 14:13:41 -04:00
/** A class to represent a collection of assets */
class FCollection
{
public :
2015-07-09 09:59:51 -04:00
FCollection ( const FString & InFilename , bool InUseSCC , ECollectionStorageMode : : Type InStorageMode ) ;
2014-03-14 14:13:41 -04:00
2015-06-19 07:33:02 -04:00
/** Clone this collection to a new location */
TSharedRef < FCollection > Clone ( const FString & InFilename , bool InUseSCC , ECollectionCloneMode InCloneMode ) const ;
/** Loads content from the SourceFilename into this collection. If false, OutError is a human readable warning depicting the error. */
bool Load ( FText & OutError ) ;
2014-03-14 14:13:41 -04:00
/** Saves this collection to SourceFilename. If false, OutError is a human readable warning depicting the error. */
bool Save ( FText & OutError ) ;
2015-07-03 13:54:34 -04:00
/** Updates this collection to ensure it's the latest version from source control. If false, OutError is a human readable warning depicting the error. */
bool Update ( FText & OutError ) ;
2015-07-07 10:31:39 -04:00
/** Merge the contents of NewCollection into this collection. Returns true if there were changes to merge, or false if the collections were identical. */
bool Merge ( const FCollection & NewCollection ) ;
2014-03-14 14:13:41 -04:00
/** Deletes the source file for this collection. If false, OutError is a human readable warning depicting the error. */
bool DeleteSourceFile ( FText & OutError ) ;
2015-07-09 14:24:02 -04:00
/** Empty this collection */
void Empty ( ) ;
2014-03-14 14:13:41 -04:00
2015-06-26 13:13:02 -04:00
/** Adds a single object to the collection. Static collections only. */
bool AddObjectToCollection ( FName ObjectPath ) ;
/** Removes a single object from the collection. Static collections only. */
bool RemoveObjectFromCollection ( FName ObjectPath ) ;
2014-03-14 14:13:41 -04:00
/** Gets a list of assets in the collection. Static collections only. */
void GetAssetsInCollection ( TArray < FName > & Assets ) const ;
/** Gets a list of classes in the collection. Static collections only. */
void GetClassesInCollection ( TArray < FName > & Classes ) const ;
/** Gets a list of objects in the collection. Static collections only. */
void GetObjectsInCollection ( TArray < FName > & Objects ) const ;
2015-05-21 07:43:16 -04:00
/** Returns true when the specified object is in the collection. Static collections only. */
bool IsObjectInCollection ( FName ObjectPath ) const ;
2015-06-26 13:13:02 -04:00
/** Returns true when the specified redirector is in the collection. Static collections only. */
bool IsRedirectorInCollection ( FName ObjectPath ) const ;
2014-03-14 14:13:41 -04:00
2015-07-09 09:59:51 -04:00
/** Set the dynamic query text for this collection. Dynamic collections only. */
bool SetDynamicQueryText ( const FString & InQueryText ) ;
/** Get the dynamic query text for this collection. Dynamic collections only. */
FString GetDynamicQueryText ( ) const ;
2015-07-09 14:24:02 -04:00
/** Tests the dynamic query for against the context provided. Dynamic collections only. */
bool TestDynamicQuery ( const ITextFilterExpressionContext & InContext ) const ;
2015-07-09 09:59:51 -04:00
2015-07-03 13:54:34 -04:00
/** Get the status info for this collection */
FCollectionStatusInfo GetStatusInfo ( ) const ;
/** Does this collection contain unsaved changes? */
bool IsDirty ( ) const ;
2014-03-14 14:13:41 -04:00
/** Whether the collection has any contents */
bool IsEmpty ( ) const ;
/** Logs the contents of the collection */
void PrintCollection ( ) const ;
/** Returns the name of the collection */
FORCEINLINE const FName & GetCollectionName ( ) const { return CollectionName ; }
2015-06-19 07:33:02 -04:00
/** Returns the GUID of the collection */
FORCEINLINE const FGuid & GetCollectionGuid ( ) const { return CollectionGuid ; }
/** Returns the GUID of the collection we are parented under */
FORCEINLINE const FGuid & GetParentCollectionGuid ( ) const { return ParentCollectionGuid ; }
/** Set the GUID of the collection we are parented under */
FORCEINLINE void SetParentCollectionGuid ( const FGuid & NewGuid ) { ParentCollectionGuid = NewGuid ; }
/** Returns the file version of the collection */
FORCEINLINE ECollectionVersion : : Type GetCollectionVersion ( ) const { return FileVersion ; }
2015-07-09 09:59:51 -04:00
/** Get whether this collection is static or dynamic */
ECollectionStorageMode : : Type GetStorageMode ( ) const { return StorageMode ; }
2015-07-07 10:31:39 -04:00
/** Get the source filename of this collection */
FORCEINLINE const FString & GetSourceFilename ( ) const { return SourceFilename ; }
2014-03-14 14:13:41 -04:00
private :
/** Generates the header pairs for the collection file. */
2015-06-19 07:33:02 -04:00
void SaveHeaderPairs ( TMap < FString , FString > & OutHeaderPairs ) const ;
2014-03-14 14:13:41 -04:00
/**
* Processes header pairs from the top of a collection file .
*
* @ param InHeaderPairs The header pairs found at the start of a collection file
* @ return true if the header was valid and loaded properly
*/
bool LoadHeaderPairs ( const TMap < FString , FString > & InHeaderPairs ) ;
/** Merges the assets from the specified collection with this collection */
2015-07-07 10:31:39 -04:00
bool MergeWithCollection ( const FCollection & Other ) ;
/** Gets the object differences between object set A (base) and B (new) */
static void GetObjectDifferences ( const TSet < FName > & BaseSet , const TSet < FName > & NewSet , TArray < FName > & ObjectsAdded , TArray < FName > & ObjectsRemoved ) ;
2015-07-09 09:59:51 -04:00
/** Gets the object differences between what we have in memory, and what we loaded from disk. Static collections only. */
2015-07-03 13:54:34 -04:00
void GetObjectDifferencesFromDisk ( TArray < FName > & ObjectsAdded , TArray < FName > & ObjectsRemoved ) const ;
2014-03-14 14:13:41 -04:00
/** Checks the shared collection out from source control so it may be saved. If false, OutError is a human readable warning depicting the error. */
bool CheckoutCollection ( FText & OutError ) ;
/** Checks the shared collection in to source control after it is saved. If false, OutError is a human readable warning depicting the error. */
bool CheckinCollection ( FText & OutError ) ;
/** Reverts the collection in the event that the save was not successful. If false, OutError is a human readable warning depicting the error.*/
bool RevertCollection ( FText & OutError ) ;
/** Marks the source file for delete in source control. If false, OutError is a human readable warning depicting the error. */
bool DeleteFromSourceControl ( FText & OutError ) ;
private :
2015-06-19 07:33:02 -04:00
/** Snapshot data for a collection. Used to take snapshots and provide a diff message */
struct FCollectionSnapshot
{
void TakeSnapshot ( const FCollection & InCollection )
{
ParentCollectionGuid = InCollection . ParentCollectionGuid ;
ObjectSet = InCollection . ObjectSet ;
2015-07-09 09:59:51 -04:00
DynamicQueryText = InCollection . DynamicQueryText ;
2015-06-19 07:33:02 -04:00
}
/** The GUID of the collection we are parented under */
FGuid ParentCollectionGuid ;
2015-07-09 09:59:51 -04:00
/** The set of objects in the collection. Takes the form PackageName.AssetName. Static collections only. */
2015-06-19 07:33:02 -04:00
TSet < FName > ObjectSet ;
2015-07-09 09:59:51 -04:00
/** The dynamic query string for this collection. Dynamic collections only. */
FString DynamicQueryText ;
2015-06-19 07:33:02 -04:00
} ;
2014-03-14 14:13:41 -04:00
/** The name of the collection */
FName CollectionName ;
2015-06-19 07:33:02 -04:00
/** The GUID of the collection */
FGuid CollectionGuid ;
/** The GUID of the collection we are parented under */
FGuid ParentCollectionGuid ;
2014-03-14 14:13:41 -04:00
/** Source control is used if true */
bool bUseSCC ;
/** The filename used to load this collection. Empty if it is new or never loaded from disk. */
FString SourceFilename ;
2015-07-09 09:59:51 -04:00
/** The set of objects in the collection. Takes the form PackageName.AssetName.Static collections only. */
2015-06-19 07:33:02 -04:00
TSet < FName > ObjectSet ;
2014-03-14 14:13:41 -04:00
2015-07-09 09:59:51 -04:00
/** The dynamic query string for this collection. Dynamic collections only. */
FString DynamicQueryText ;
2015-07-09 14:24:02 -04:00
/** Expression evaluator that can be used test against the compiled DynamicQueryText */
mutable TSharedPtr < FTextFilterExpressionEvaluator > DynamicQueryExpressionEvaluatorPtr ;
2014-03-14 14:13:41 -04:00
/** The file version for this collection */
2015-06-19 07:33:02 -04:00
ECollectionVersion : : Type FileVersion ;
2015-07-09 09:59:51 -04:00
/** How does this collection store its objects? (static or dynamic) */
ECollectionStorageMode : : Type StorageMode ;
2015-06-19 07:33:02 -04:00
/** The state of the collection the last time it was loaded from or saved to disk. */
FCollectionSnapshot DiskSnapshot ;
2015-05-21 07:43:16 -04:00
} ;