// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #pragma once class FCollectionManager : public ICollectionManager { public: FCollectionManager(); virtual ~FCollectionManager(); // ICollectionManager implementation virtual void GetCollectionNames(ECollectionShareType::Type ShareType, TArray& CollectionNames) const override; virtual bool CollectionExists(FName CollectionName, ECollectionShareType::Type ShareType) const override; virtual bool GetAssetsInCollection(FName CollectionName, ECollectionShareType::Type ShareType, TArray& AssetPaths) const override; virtual bool GetObjectsInCollection(FName CollectionName, ECollectionShareType::Type ShareType, TArray& ObjectPaths) const override; virtual bool GetClassesInCollection(FName CollectionName, ECollectionShareType::Type ShareType, TArray& ClassPaths) const override; virtual void GetCollectionsContainingAsset(FName ObjectPath, ECollectionShareType::Type ShareType, TArray& OutCollectionNames) const override; virtual void CreateUniqueCollectionName(const FName& BaseName, ECollectionShareType::Type ShareType, FName& OutCollectionName) const override; virtual bool CreateCollection(FName CollectionName, ECollectionShareType::Type ShareType) override; virtual bool RenameCollection(FName CurrentCollectionName, ECollectionShareType::Type CurrentShareType, FName NewCollectionName, ECollectionShareType::Type NewShareType) override; virtual bool DestroyCollection(FName CollectionName, ECollectionShareType::Type ShareType) override; virtual bool AddToCollection(FName CollectionName, ECollectionShareType::Type ShareType, FName ObjectPath) override; virtual bool AddToCollection(FName CollectionName, ECollectionShareType::Type ShareType, const TArray& ObjectPaths, int32* OutNumAdded = NULL) override; virtual bool RemoveFromCollection(FName CollectionName, ECollectionShareType::Type ShareType, FName ObjectPath) override; virtual bool RemoveFromCollection(FName CollectionName, ECollectionShareType::Type ShareType, const TArray& ObjectPaths, int32* OutNumRemoved = NULL) override; virtual bool EmptyCollection(FName CollectionName, ECollectionShareType::Type ShareType) override; virtual bool IsCollectionEmpty(FName CollectionName, ECollectionShareType::Type ShareType) override; virtual FText GetLastError() const override { return LastError; } /** Event for when collections are created */ DECLARE_DERIVED_EVENT( FCollectionManager, ICollectionManager::FCollectionCreatedEvent, FCollectionCreatedEvent ); virtual FCollectionCreatedEvent& OnCollectionCreated() override { return CollectionCreatedEvent; } /** Event for when collections are destroyed */ DECLARE_DERIVED_EVENT( FCollectionManager, ICollectionManager::FCollectionDestroyedEvent, FCollectionDestroyedEvent ); virtual FCollectionDestroyedEvent& OnCollectionDestroyed() override { return CollectionDestroyedEvent; } /** Event for when assets are added to a collection */ DECLARE_DERIVED_EVENT( FCollectionManager, ICollectionManager::FAssetsAddedEvent, FAssetsAddedEvent ); virtual FAssetsAddedEvent& OnAssetsAdded() override { return AssetsAddedEvent; } /** Event for when assets are removed to a collection */ DECLARE_DERIVED_EVENT( FCollectionManager, ICollectionManager::FAssetsRemovedEvent, FAssetsRemovedEvent ); virtual FAssetsRemovedEvent& OnAssetsRemoved() override { return AssetsRemovedEvent; } /** Event for when collections are renamed */ DECLARE_DERIVED_EVENT( FCollectionManager, ICollectionManager::FCollectionRenamedEvent, FCollectionRenamedEvent ); virtual FCollectionRenamedEvent& OnCollectionRenamed() override { return CollectionRenamedEvent; } private: /** Loads all collection files from disk */ void LoadCollections(); /** Returns true if the specified share type requires source control */ bool ShouldUseSCC(ECollectionShareType::Type ShareType) const; /** Adds a collection to the lookup maps */ class FCollection* AddCollection(const FCollection& Collection, ECollectionShareType::Type ShareType); /** Removes a collection from the lookup maps */ bool RemoveCollection(FCollection* Collection, ECollectionShareType::Type ShareType); private: /** The folders that contain collections */ FString CollectionFolders[ECollectionShareType::CST_All]; /** The extension used for collection files */ FString CollectionExtension; /** A map of collection names to FCollection objects */ TMap CachedCollections[ECollectionShareType::CST_All]; /** A count of the number of collections created so we can be sure they are all destroyed when we shut down */ int32 NumCollections; /** The most recent error that occurred */ FText LastError; /** Event for when assets are added to a collection */ FAssetsAddedEvent AssetsAddedEvent; /** Event for when assets are removed from a collection */ FAssetsRemovedEvent AssetsRemovedEvent; /** Event for when collections are renamed */ FCollectionRenamedEvent CollectionRenamedEvent; /** Event for when collections are created */ FCollectionCreatedEvent CollectionCreatedEvent; /** Event for when collections are destroyed */ FCollectionDestroyedEvent CollectionDestroyedEvent; };