Blender V5.3
AS_asset_representation.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
13
14#pragma once
15
16#include <memory>
17#include <optional>
18#include <string>
19#include <variant>
20
21#include "BLI_string_ref.hh"
22#include "BLI_utility_mixins.hh"
23
24#include "DNA_ID_enums.h"
25#include "DNA_asset_types.h"
26
28
29namespace blender {
30
31struct AssetMetaData;
32struct bContext;
33struct ID;
34struct PreviewImage;
35struct ReportList;
36
37namespace asset_system {
38
39class AssetLibrary;
40struct OnlineAssetInfo;
41struct OnlineAssetFile;
42struct URLWithHash;
43
46 AssetLibrary &owner_asset_library_;
51 /* Mutable to allow lazy updating on name changes in #library_relative_identifier(). */
52 mutable std::string relative_identifier_;
53
54 struct ExternalAsset {
55 std::string name;
56 int id_type = 0;
57 std::unique_ptr<AssetMetaData> metadata_ = nullptr;
58 PreviewImage *preview_ = nullptr;
59
69
79 std::unique_ptr<OnlineAssetInfo> online_info_;
80 };
81 std::variant<ExternalAsset, ID *> asset_;
82
83 friend class AssetLibrary;
84
85 public:
92 AssetRepresentation(StringRef relative_asset_path,
93 StringRef name,
94 int id_type,
95 std::unique_ptr<AssetMetaData> metadata,
100 AssetRepresentation(StringRef relative_asset_path,
101 StringRef name,
102 int id_type,
103 std::unique_ptr<AssetMetaData> metadata,
105 OnlineAssetInfo online_info);
112
119
130 void ensure_previewable(const bContext &C, ReportList *reports = nullptr);
137 PreviewImage *get_preview() const;
138
139 StringRefNull get_name() const;
140 ID_Type get_id_type() const;
142
144 std::string full_path() const;
145
159 std::string full_library_path() const;
160
170 std::optional<int64_t> online_asset_files_combined_size_in_bytes() const;
177 std::optional<StringRefNull> online_asset_preview_url() const;
183 std::optional<StringRefNull> online_asset_preview_hash() const;
184
192
198 std::optional<eAssetImportMethod> get_import_method() const;
204 bool may_override_import_method() const;
205 bool get_use_relative_path() const;
210 ID *local_id() const;
212 bool is_local_id() const;
222 bool is_online_only() const;
237
252
259 bool needs_download() const;
260
262};
263
264} // namespace asset_system
265
266} // namespace blender
Enumerations for DNA_ID.h.
#define C
Definition RandGen.cpp:29
AssetRepresentation(StringRef relative_asset_path, StringRef name, int id_type, std::unique_ptr< AssetMetaData > metadata, AssetLibrary &owner_asset_library)
std::optional< StringRefNull > online_asset_preview_url() const
void ensure_previewable(const bContext &C, ReportList *reports=nullptr)
Span< OnlineAssetFile > online_asset_files() const
std::optional< eAssetImportMethod > get_import_method() const
void remote_file_status_set(RemoteAssetFileStatus status)
std::optional< StringRefNull > online_asset_preview_hash() const
std::optional< int64_t > online_asset_files_combined_size_in_bytes() const
NonCopyable(const NonCopyable &other)=delete
NonMovable(NonMovable &&other)=delete
BMesh Iterators.
The meta-data of an asset. By creating and giving this for a data-block (ID.asset_data),...