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:
-rw-r--r--source/blender/blenkernel/BKE_asset_catalog.hh17
-rw-r--r--source/blender/blenkernel/intern/asset_catalog.cc28
-rw-r--r--source/blender/blenkernel/intern/asset_catalog_test.cc2
-rw-r--r--source/blender/editors/asset/intern/asset_catalog.cc4
4 files changed, 25 insertions, 26 deletions
diff --git a/source/blender/blenkernel/BKE_asset_catalog.hh b/source/blender/blenkernel/BKE_asset_catalog.hh
index c141ce5fca0..9d179011b25 100644
--- a/source/blender/blenkernel/BKE_asset_catalog.hh
+++ b/source/blender/blenkernel/BKE_asset_catalog.hh
@@ -40,7 +40,6 @@
namespace blender::bke {
using CatalogID = bUUID;
-using CatalogPath = AssetCatalogPath;
using CatalogPathComponent = std::string;
/* Would be nice to be able to use `std::filesystem::path` for this, but it's currently not
* available on the minimum macOS target version. */
@@ -99,11 +98,11 @@ class AssetCatalogService {
/** Return first catalog with the given path. Return nullptr if not found. This is not an
* efficient call as it's just a linear search over the catalogs. */
- AssetCatalog *find_catalog_by_path(const CatalogPath &path) const;
+ AssetCatalog *find_catalog_by_path(const AssetCatalogPath &path) const;
/** Create a catalog with some sensible auto-generated catalog ID.
* The catalog will be saved to the default catalog file.*/
- AssetCatalog *create_catalog(const CatalogPath &catalog_path);
+ AssetCatalog *create_catalog(const AssetCatalogPath &catalog_path);
/**
* Soft-delete the catalog, ensuring it actually gets deleted when the catalog definition file is
@@ -113,7 +112,7 @@ class AssetCatalogService {
/**
* Update the catalog path, also updating the catalog path of all sub-catalogs.
*/
- void update_catalog_path(CatalogID catalog_id, const CatalogPath &new_catalog_path);
+ void update_catalog_path(CatalogID catalog_id, const AssetCatalogPath &new_catalog_path);
AssetCatalogTree *get_catalog_tree();
@@ -173,7 +172,7 @@ class AssetCatalogTreeItem {
StringRef get_name() const;
/** Return the full catalog path, defined as the name of this catalog prefixed by the full
* catalog path of its parent and a separator. */
- CatalogPath catalog_path() const;
+ AssetCatalogPath catalog_path() const;
int count_parents() const;
bool has_children() const;
@@ -281,10 +280,10 @@ class AssetCatalogDefinitionFile {
class AssetCatalog {
public:
AssetCatalog() = default;
- AssetCatalog(CatalogID catalog_id, const CatalogPath &path, const std::string &simple_name);
+ AssetCatalog(CatalogID catalog_id, const AssetCatalogPath &path, const std::string &simple_name);
CatalogID catalog_id;
- CatalogPath path;
+ AssetCatalogPath path;
/**
* Simple, human-readable name for the asset catalog. This is stored on assets alongside the
* catalog ID; the catalog ID is a UUID that is not human-readable,
@@ -304,11 +303,11 @@ class AssetCatalog {
* NOTE: the given path will be cleaned up (trailing spaces removed, etc.), so the returned
* `AssetCatalog`'s path differ from the given one.
*/
- static std::unique_ptr<AssetCatalog> from_path(const CatalogPath &path);
+ static std::unique_ptr<AssetCatalog> from_path(const AssetCatalogPath &path);
protected:
/** Generate a sensible catalog ID for the given path. */
- static std::string sensible_simple_name_for_path(const CatalogPath &path);
+ static std::string sensible_simple_name_for_path(const AssetCatalogPath &path);
};
/** Comparator for asset catalogs, ordering by (path, UUID). */
diff --git a/source/blender/blenkernel/intern/asset_catalog.cc b/source/blender/blenkernel/intern/asset_catalog.cc
index 300a15fad6d..bb213877e05 100644
--- a/source/blender/blenkernel/intern/asset_catalog.cc
+++ b/source/blender/blenkernel/intern/asset_catalog.cc
@@ -74,7 +74,7 @@ AssetCatalog *AssetCatalogService::find_catalog(CatalogID catalog_id)
return catalog_uptr_ptr->get();
}
-AssetCatalog *AssetCatalogService::find_catalog_by_path(const CatalogPath &path) const
+AssetCatalog *AssetCatalogService::find_catalog_by_path(const AssetCatalogPath &path) const
{
for (const auto &catalog : catalogs_.values()) {
if (catalog->path == path) {
@@ -107,15 +107,15 @@ void AssetCatalogService::delete_catalog(CatalogID catalog_id)
}
void AssetCatalogService::update_catalog_path(CatalogID catalog_id,
- const CatalogPath &new_catalog_path)
+ const AssetCatalogPath &new_catalog_path)
{
AssetCatalog *renamed_cat = this->find_catalog(catalog_id);
- const CatalogPath old_cat_path = renamed_cat->path;
+ const AssetCatalogPath old_cat_path = renamed_cat->path;
for (auto &catalog_uptr : catalogs_.values()) {
AssetCatalog *cat = catalog_uptr.get();
- const CatalogPath new_path = cat->path.rebase(old_cat_path, new_catalog_path);
+ const AssetCatalogPath new_path = cat->path.rebase(old_cat_path, new_catalog_path);
if (!new_path) {
continue;
}
@@ -125,7 +125,7 @@ void AssetCatalogService::update_catalog_path(CatalogID catalog_id,
this->rebuild_tree();
}
-AssetCatalog *AssetCatalogService::create_catalog(const CatalogPath &catalog_path)
+AssetCatalog *AssetCatalogService::create_catalog(const AssetCatalogPath &catalog_path)
{
std::unique_ptr<AssetCatalog> catalog = AssetCatalog::from_path(catalog_path);
@@ -378,11 +378,11 @@ StringRef AssetCatalogTreeItem::get_name() const
return name_;
}
-CatalogPath AssetCatalogTreeItem::catalog_path() const
+AssetCatalogPath AssetCatalogTreeItem::catalog_path() const
{
- CatalogPath current_path = name_;
+ AssetCatalogPath current_path = name_;
for (const AssetCatalogTreeItem *parent = parent_; parent; parent = parent->parent_) {
- current_path = CatalogPath(parent->name_) / current_path;
+ current_path = AssetCatalogPath(parent->name_) / current_path;
}
return current_path;
}
@@ -580,7 +580,7 @@ std::unique_ptr<AssetCatalog> AssetCatalogDefinitionFile::parse_catalog_line(con
simple_name = path_and_simple_name.substr(second_delim + 1).trim();
}
- CatalogPath catalog_path = path_in_file;
+ AssetCatalogPath catalog_path = path_in_file;
return std::make_unique<AssetCatalog>(catalog_id, catalog_path.cleanup(), simple_name);
}
@@ -687,25 +687,25 @@ bool AssetCatalogDefinitionFile::ensure_directory_exists(
}
AssetCatalog::AssetCatalog(const CatalogID catalog_id,
- const CatalogPath &path,
+ const AssetCatalogPath &path,
const std::string &simple_name)
: catalog_id(catalog_id), path(path), simple_name(simple_name)
{
}
-std::unique_ptr<AssetCatalog> AssetCatalog::from_path(const CatalogPath &path)
+std::unique_ptr<AssetCatalog> AssetCatalog::from_path(const AssetCatalogPath &path)
{
- const CatalogPath clean_path = path.cleanup();
+ const AssetCatalogPath clean_path = path.cleanup();
const CatalogID cat_id = BLI_uuid_generate_random();
const std::string simple_name = sensible_simple_name_for_path(clean_path);
auto catalog = std::make_unique<AssetCatalog>(cat_id, clean_path, simple_name);
return catalog;
}
-std::string AssetCatalog::sensible_simple_name_for_path(const CatalogPath &path)
+std::string AssetCatalog::sensible_simple_name_for_path(const AssetCatalogPath &path)
{
std::string name = path.str();
- std::replace(name.begin(), name.end(), CatalogPath::SEPARATOR, '-');
+ std::replace(name.begin(), name.end(), AssetCatalogPath::SEPARATOR, '-');
if (name.length() < MAX_NAME - 1) {
return name;
}
diff --git a/source/blender/blenkernel/intern/asset_catalog_test.cc b/source/blender/blenkernel/intern/asset_catalog_test.cc
index cde16b97b5d..d7c3e50cbdf 100644
--- a/source/blender/blenkernel/intern/asset_catalog_test.cc
+++ b/source/blender/blenkernel/intern/asset_catalog_test.cc
@@ -718,7 +718,7 @@ TEST_F(AssetCatalogTest, update_catalog_path)
AssetCatalogService::DEFAULT_CATALOG_FILENAME);
const AssetCatalog *orig_cat = service.find_catalog(UUID_POSES_RUZENA);
- const CatalogPath orig_path = orig_cat->path;
+ const AssetCatalogPath orig_path = orig_cat->path;
service.update_catalog_path(UUID_POSES_RUZENA, "charlib/Ružena");
diff --git a/source/blender/editors/asset/intern/asset_catalog.cc b/source/blender/editors/asset/intern/asset_catalog.cc
index c3e5a888796..6e49ca2dd5c 100644
--- a/source/blender/editors/asset/intern/asset_catalog.cc
+++ b/source/blender/editors/asset/intern/asset_catalog.cc
@@ -37,7 +37,7 @@ struct CatalogUniqueNameFnData {
static bool catalog_name_exists_fn(void *arg, const char *name)
{
CatalogUniqueNameFnData &fn_data = *static_cast<CatalogUniqueNameFnData *>(arg);
- CatalogPath fullpath = CatalogPath(fn_data.parent_path) / name;
+ AssetCatalogPath fullpath = AssetCatalogPath(fn_data.parent_path) / name;
return fn_data.catalog_service.find_catalog_by_path(fullpath);
}
@@ -64,7 +64,7 @@ AssetCatalog *ED_asset_catalog_add(::AssetLibrary *library,
}
std::string unique_name = catalog_name_ensure_unique(*catalog_service, name, parent_path);
- CatalogPath fullpath = CatalogPath(parent_path) / unique_name;
+ AssetCatalogPath fullpath = AssetCatalogPath(parent_path) / unique_name;
return catalog_service->create_catalog(fullpath);
}