33 std::unique_ptr<AssetMetaData>
metadata,
36 relative_identifier_(relative_asset_path),
44 std::unique_ptr<AssetMetaData>
metadata,
48 relative_identifier_(relative_asset_path),
63 throw std::invalid_argument(
"Passed ID is not an asset");
69 if (
const ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
70 extern_asset && extern_asset->preview_)
89 ExternalAsset &extern_asset = std::get<ExternalAsset>(asset_);
91 if (extern_asset.preview_ && extern_asset.preview_->
runtime->
icon_id) {
98 const bool count_preview_users =
true;
103 if (!extern_asset.online_info_->preview_url) {
110 this->
full_path().c_str(), preview_path.c_str(),
false, count_preview_users);
115 const std::string
full_path = this->full_path();
131 return std::get<ExternalAsset>(asset_).preview_;
139 return std::get<ExternalAsset>(asset_).name;
147 return ID_Type(std::get<ExternalAsset>(asset_).id_type);
153 return *
id->asset_data;
155 return *std::get<ExternalAsset>(asset_).metadata_;
168 return relative_identifier_;
176 owner_asset_library_.root_path().c_str(),
185 char blend_path[ 1282];
195 const ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
196 if (!extern_asset || !extern_asset->online_info_) {
199 return extern_asset->online_info_->files;
204 const ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
205 if (!extern_asset || !extern_asset->online_info_) {
210 size += file.size_in_bytes;
220 std::optional<URLWithHash> &url_with_hash =
221 std::get<ExternalAsset>(asset_).online_info_->preview_url;
222 if (!url_with_hash) {
225 return url_with_hash->url;
233 std::optional<URLWithHash> &url_with_hash =
234 std::get<ExternalAsset>(asset_).online_info_->preview_url;
235 if (!url_with_hash) {
238 return url_with_hash->hash;
243 ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
257 return metadata.preferred_import_method;
259 return owner_asset_library_.import_method();
264 if (!owner_asset_library_.import_method()) {
267 return owner_asset_library_.may_override_import_method_;
272 return owner_asset_library_.use_relative_paths();
277 return this->
is_local_id() ? std::get<ID *>(asset_) :
nullptr;
282 return std::holds_alternative<ID *>(asset_);
287 const ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
288 if (!extern_asset || !extern_asset->online_info_) {
298 return ELEM(extern_asset->remote_file_status_,
315 const ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
319 return extern_asset->remote_file_status_;
324 ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
328 extern_asset->online_info_ = std::make_unique<OnlineAssetInfo>(std::move(info));
333 ExternalAsset *extern_asset = std::get_if<ExternalAsset>(&asset_);
337 extern_asset->remote_file_status_ = status;
347 return owner_asset_library_;
Main runtime representation of an asset.
#define BLENDER_ASSET_FILE_SUFFIX
#define BLI_path_join(...)
ID and Library types, which are fundamental for SDNA.
AssetRepresentation(StringRef relative_asset_path, StringRef name, int id_type, std::unique_ptr< AssetMetaData > metadata, AssetLibrary &owner_asset_library)
PreviewImage * get_preview() const
std::string full_path() const
bool needs_download() const
AssetLibrary & owner_asset_library() const
bool is_potentially_editable_asset_blend() const
friend class AssetLibrary
AssetMetaData & get_metadata() const
std::optional< StringRefNull > online_asset_preview_url() const
bool is_online_only() const
void online_info_set(OnlineAssetInfo info)
ID_Type get_id_type() const
RemoteAssetFileStatus remote_file_status() const
void ensure_previewable(const bContext &C, ReportList *reports=nullptr)
StringRefNull library_relative_identifier() const
AssetWeakReference make_weak_reference() const
Span< OnlineAssetFile > online_asset_files() const
std::string full_library_path() const
bool get_use_relative_path() const
std::optional< eAssetImportMethod > get_import_method() const
StringRefNull get_name() const
void remote_file_status_set(RemoteAssetFileStatus status)
bool may_override_import_method() const
std::optional< StringRefNull > online_asset_preview_hash() const
void online_asset_mark_downloaded()
std::optional< int64_t > online_asset_files_combined_size_in_bytes() const
constexpr bool endswith(StringRef suffix) const
void remote_library_request_preview_download(const bContext &C, const AssetRepresentation &asset, const StringRef dst_filepath, ReportList *reports)
std::string remote_library_asset_preview_path(const AssetRepresentation &asset)
const char * BKE_idtype_idcode_to_name(short idcode)
PreviewImage * BKE_previewimg_cached_thumbnail_read(const char *name, const char *filepath, int source, bool force_update, bool count_users=false)
bool BKE_blendfile_library_path_explode(const char *path, char *r_dir, char **r_group, char **r_name)
PreviewImage * BKE_previewimg_online_thumbnail_read(const char *name, const char *dst_filepath, bool force_update, bool count_users=false)
const char * BKE_id_name(const ID &id)
int BKE_icon_preview_ensure(ID *id, PreviewImage *preview)
@ ASSETDATA_USE_OWN_IMPORT_METHOD
PreviewImage * BKE_previewimg_id_get(const ID *id)
ID_Type GS(const char *name)
void BKE_previewimg_cached_release(const char *name)
bke::PreviewImageRuntime * runtime