Changeset View
Changeset View
Standalone View
Standalone View
source/blender/asset_system/intern/asset_representation.cc
- This file was moved from source/blender/blenkernel/intern/asset_representation.cc.
| /* SPDX-License-Identifier: GPL-2.0-or-later */ | /* SPDX-License-Identifier: GPL-2.0-or-later */ | ||||
| /** \file | /** \file | ||||
| * \ingroup bke | * \ingroup asset_system | ||||
| */ | */ | ||||
| #include <stdexcept> | #include <stdexcept> | ||||
| #include "DNA_ID.h" | #include "DNA_ID.h" | ||||
| #include "DNA_asset_types.h" | #include "DNA_asset_types.h" | ||||
| #include "AS_asset_representation.h" | |||||
| #include "AS_asset_representation.hh" | |||||
| #include "BKE_asset.h" | #include "BKE_asset.h" | ||||
| #include "BKE_asset_representation.hh" | |||||
| namespace blender::bke { | namespace blender::asset_system { | ||||
| AssetRepresentation::AssetRepresentation(StringRef name, std::unique_ptr<AssetMetaData> metadata) | AssetRepresentation::AssetRepresentation(StringRef name, std::unique_ptr<AssetMetaData> metadata) | ||||
| : is_local_id_(false), external_asset_() | : is_local_id_(false), external_asset_() | ||||
| { | { | ||||
| external_asset_.name = name; | external_asset_.name = name; | ||||
| external_asset_.metadata_ = std::move(metadata); | external_asset_.metadata_ = std::move(metadata); | ||||
| } | } | ||||
| Show All 37 Lines | AssetMetaData &AssetRepresentation::get_metadata() const | ||||
| return is_local_id_ ? *local_asset_id_->asset_data : *external_asset_.metadata_; | return is_local_id_ ? *local_asset_id_->asset_data : *external_asset_.metadata_; | ||||
| } | } | ||||
| bool AssetRepresentation::is_local_id() const | bool AssetRepresentation::is_local_id() const | ||||
| { | { | ||||
| return is_local_id_; | return is_local_id_; | ||||
| } | } | ||||
| } // namespace blender::bke | } // namespace blender::asset_system | ||||
| /* ---------------------------------------------------------------------- */ | /* ---------------------------------------------------------------------- */ | ||||
| /** \name C-API | /** \name C-API | ||||
| * \{ */ | * \{ */ | ||||
| using namespace blender; | using namespace blender; | ||||
| const char *BKE_asset_representation_name_get(const AssetRepresentation *asset_handle) | const char *AS_asset_representation_name_get(const AssetRepresentation *asset_handle) | ||||
| { | { | ||||
| const bke::AssetRepresentation *asset = reinterpret_cast<const bke::AssetRepresentation *>( | const asset_system::AssetRepresentation *asset = | ||||
| asset_handle); | reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle); | ||||
| return asset->get_name().c_str(); | return asset->get_name().c_str(); | ||||
| } | } | ||||
| AssetMetaData *BKE_asset_representation_metadata_get(const AssetRepresentation *asset_handle) | AssetMetaData *AS_asset_representation_metadata_get(const AssetRepresentation *asset_handle) | ||||
| { | { | ||||
| const bke::AssetRepresentation *asset = reinterpret_cast<const bke::AssetRepresentation *>( | const asset_system::AssetRepresentation *asset = | ||||
| asset_handle); | reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle); | ||||
| return &asset->get_metadata(); | return &asset->get_metadata(); | ||||
| } | } | ||||
| bool BKE_asset_representation_is_local_id(const AssetRepresentation *asset_handle) | bool AS_asset_representation_is_local_id(const AssetRepresentation *asset_handle) | ||||
| { | { | ||||
| const bke::AssetRepresentation *asset = reinterpret_cast<const bke::AssetRepresentation *>( | const asset_system::AssetRepresentation *asset = | ||||
| asset_handle); | reinterpret_cast<const asset_system::AssetRepresentation *>(asset_handle); | ||||
| return asset->is_local_id(); | return asset->is_local_id(); | ||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||