Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'source/blender/editors/asset/asset_list.cc')
-rw-r--r--source/blender/editors/asset/asset_list.cc53
1 files changed, 6 insertions, 47 deletions
diff --git a/source/blender/editors/asset/asset_list.cc b/source/blender/editors/asset/asset_list.cc
index dd1c5f360a0..d9c1c6d862e 100644
--- a/source/blender/editors/asset/asset_list.cc
+++ b/source/blender/editors/asset/asset_list.cc
@@ -26,12 +26,8 @@
#include <optional>
#include <string>
-#include "BKE_asset.h"
#include "BKE_context.h"
-#include "BKE_screen.h"
-#include "BLI_function_ref.hh"
-#include "BLI_hash.hh"
#include "BLI_map.hh"
#include "BLI_path_util.h"
#include "BLI_utility_mixins.hh"
@@ -43,7 +39,6 @@
#include "ED_asset.h"
#include "ED_fileselect.h"
-#include "ED_screen.h"
#include "WM_api.h"
#include "WM_types.h"
@@ -51,48 +46,9 @@
/* XXX uses private header of file-space. */
#include "../space_file/filelist.h"
-using namespace blender;
+#include "intern/asset_library_reference.hh"
-/**
- * Wrapper to add logic to the AssetLibraryReference DNA struct.
- */
-class AssetLibraryReferenceWrapper {
- const AssetLibraryReference reference_;
-
- public:
- /* Intentionally not `explicit`, allow implicit conversion for convenience. Might have to be
- * NOLINT */
- AssetLibraryReferenceWrapper(const AssetLibraryReference &reference);
- ~AssetLibraryReferenceWrapper() = default;
-
- friend bool operator==(const AssetLibraryReferenceWrapper &a,
- const AssetLibraryReferenceWrapper &b);
- uint64_t hash() const;
-};
-
-AssetLibraryReferenceWrapper::AssetLibraryReferenceWrapper(const AssetLibraryReference &reference)
- : reference_(reference)
-{
-}
-
-bool operator==(const AssetLibraryReferenceWrapper &a, const AssetLibraryReferenceWrapper &b)
-{
- return (a.reference_.type == b.reference_.type) && (a.reference_.type == ASSET_LIBRARY_CUSTOM) ?
- (a.reference_.custom_library_index == b.reference_.custom_library_index) :
- true;
-}
-
-uint64_t AssetLibraryReferenceWrapper::hash() const
-{
- uint64_t hash1 = DefaultHash<decltype(reference_.type)>{}(reference_.type);
- if (reference_.type != ASSET_LIBRARY_CUSTOM) {
- return hash1;
- }
-
- uint64_t hash2 = DefaultHash<decltype(reference_.custom_library_index)>{}(
- reference_.custom_library_index);
- return hash1 ^ (hash2 * 33); /* Copied from DefaultHash for std::pair. */
-}
+namespace blender::ed::asset {
/* -------------------------------------------------------------------- */
/** \name Asset list API
@@ -469,10 +425,14 @@ AssetListStorage::AssetListMap &AssetListStorage::global_storage()
/** \} */
+} // namespace blender::ed::asset
+
/* -------------------------------------------------------------------- */
/** \name C-API
* \{ */
+using namespace blender::ed::asset;
+
/**
* Invoke asset list reading, potentially in a parallel job. Won't wait until the job is done,
* and may return earlier.
@@ -506,7 +466,6 @@ bool ED_assetlist_storage_has_list_for_library(const AssetLibraryReference *libr
return AssetListStorage::lookup_list(*library_reference) != nullptr;
}
-/* TODO expose AssetList with an iterator? */
void ED_assetlist_iterate(const AssetLibraryReference *library_reference, AssetListIterFn fn)
{
AssetList *list = AssetListStorage::lookup_list(*library_reference);