AssetDescriptionInterface Class Reference

#include <assets.h>

Inheritance diagram for AssetDescriptionInterface:

Detailed Description

An AssetDescription represents all meta information about an asset, namely its identifer and version, the AssetMetaData and some further information. AssetRepositoryInterface::FindAssets yields the found assets not as Asset, but as AssetDescription to avoid unnecessary loading of the assets. When you really need the asset itself you have to call Load on the description.

Public Member Functions

MAXON_METHOD Result< const Url & > GetUrl () const
 
MAXON_METHOD Result< AssetLoad (Bool *updateLinks) const
 
MAXON_FUNCTION Result< AssetLoad () const
 
MAXON_METHOD const AssetMetaData & GetMetaData () const
 
MAXON_METHOD Bool IsDeleted () const
 
MAXON_FUNCTION Result< void > StoreMetaData (const InternedId &attr, ForwardingDataPtr &&data, AssetMetaDataInterface::KIND kind) const
 
template<typename ATTR >
MAXON_FUNCTION Result< void > StoreMetaData (const ATTR &attr, typename ATTR::ValueType &&data, AssetMetaDataInterface::KIND kind) const
 
template<typename ATTR >
MAXON_FUNCTION Result< void > StoreMetaData (const ATTR &attr, const typename ATTR::ValueType &data, AssetMetaDataInterface::KIND kind) const
 
template<typename ATTR >
MAXON_FUNCTION Result< void > EraseMetaData (const ATTR &attr, AssetMetaDataInterface::KIND kind) const
 
MAXON_FUNCTION Result< void > StoreUrlMetaData (const InternedId &metaId, const Url &source, AssetMetaDataInterface::KIND kind) const
 
MAXON_METHOD Result< StringGetMetaString (const InternedId &key, const LanguageRef &languageRef=GetPtrSizedZeroRef< LanguageRef >(), const String &fallback=GetPtrSizedZeroRef< String >()) const
 
MAXON_METHOD Result< void > StoreMetaString (const InternedId &key, const String &value, const LanguageRef &languageRef) const
 

Private Member Functions

 MAXON_INTERFACE (AssetDescriptionInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.assetdescription", MAXON_IMPLEMENTATION_MODULE("net.maxon.asset"))
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( AssetDescriptionInterface  ,
MAXON_REFERENCE_COPY_ON_WRITE  ,
"net.maxon.interface.assetdescription"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.asset")   
)
private

◆ GetUrl()

MAXON_METHOD Result<const Url&> GetUrl ( ) const

Returns the Url where the asset is stored.

Returns
The Url of this asset, may be empty if the asset isn't accessible through a Url.

◆ Load() [1/2]

MAXON_METHOD Result<Asset> Load ( Bool updateLinks) const

Loads the asset. The implementation may use caching to avoid repeated loading of the same asset.

Parameters
[in,out]updateLinksnullptr if the asset shall be loaded as is, or a pointer to a Bool if asset links which use ASSET_UPDATE_POLICY::IMPLICIT shall be resolved to the latest version. The Bool is set to true by this method whenever there is a link where the resolved version differs from the original version.
Returns
The loaded asset.

◆ Load() [2/2]

MAXON_FUNCTION Result<Asset> Load ( ) const

Loads the asset, thereby updating asset links which use ASSET_UPDATE_POLICY::IMPLICIT to the latest version. The implementation may use caching to avoid repeated loading of the same asset.

Returns
The loaded asset.

◆ GetMetaData()

MAXON_METHOD const AssetMetaData& GetMetaData ( ) const

Returns the meta data of this asset.

Returns
The meta data of this asset.

◆ IsDeleted()

MAXON_METHOD Bool IsDeleted ( ) const

Returns true if this asset description is a delete marker. Delete markers are stored in repositories upon call of AssetRepositoryInterface::DeleteAsset to indicate a deleted asset, but previous asset versions still exist in the repository.

Returns
True if this description represents a delete marker, false otherwise.

◆ StoreMetaData() [1/3]

MAXON_FUNCTION Result<void> StoreMetaData ( const InternedId attr,
ForwardingDataPtr &&  data,
AssetMetaDataInterface::KIND  kind 
) const

Stores #data for the meta data attribute #attr of this asset. Observers of AssetRepositoryInterface::ObservableMetaDataStored of the repository of the asset and its derived repositories are informed.

Parameters
[in]attrThe meta data attribute.
[in]dataThe value to set.
[in]kindThe kind of the meta data.

◆ StoreMetaData() [2/3]

MAXON_FUNCTION Result<void> StoreMetaData ( const ATTR &  attr,
typename ATTR::ValueType &&  data,
AssetMetaDataInterface::KIND  kind 
) const

Stores #data for the meta data attribute #attr of this asset. Observers of AssetRepositoryInterface::ObservableMetaDataStored of the repository of the asset and its derived repositories are informed.

Parameters
[in]attrThe meta data attribute.
[in]dataThe value to set.
[in]kindThe kind of the meta data.

◆ StoreMetaData() [3/3]

MAXON_FUNCTION Result<void> StoreMetaData ( const ATTR &  attr,
const typename ATTR::ValueType &  data,
AssetMetaDataInterface::KIND  kind 
) const

Stores #data for the meta data attribute #attr of this asset. Observers of AssetRepositoryInterface::ObservableMetaDataStored of the repository of the asset and its derived repositories are informed.

Parameters
[in]attrThe meta data attribute.
[in]dataThe value to set.
[in]kindThe kind of the meta data.

◆ EraseMetaData()

MAXON_FUNCTION Result<void> EraseMetaData ( const ATTR &  attr,
AssetMetaDataInterface::KIND  kind 
) const

EraseMetaData removes meta data from the asset.

Parameters
[in]attrThe meta data attribute.
[in]kindThe kind of the meta data.
Returns
OK on success.

◆ StoreUrlMetaData()

MAXON_FUNCTION Result<void> StoreUrlMetaData ( const InternedId metaId,
const Url source,
AssetMetaDataInterface::KIND  kind 
) const

Copies the file or directory source as meta data for the meta data attribute #metaId of this #asset. The value of the meta data attribute will be a Url which points to the local copy within the asset (i.e., not to source) of the form {meta:///assetid/metaid.kind.extension}, so the file name extension of source gets preserved. Observers of ObservableMetaDataStored of this repository and its derived repositories are informed.

Parameters
[in]metaIdThe identifier of the meta data attribute.
[in]sourceThe source which shall be copied as meta data to #asset. Pass empty Url to erase meta data.
[in]kindThe kind of the meta data.

◆ GetMetaString()

MAXON_METHOD Result<String> GetMetaString ( const InternedId key,
const LanguageRef &  languageRef = GetPtrSizedZeroRef< LanguageRef >(),
const String fallback = GetPtrSizedZeroRef< String >() 
) const

GetMetaString returns the translated string from a asset.

Parameters
[in]keyAttribute id to load. e.g. OBJECT::BASE:NAME.
[in]languageRefOptional language. By default the function uses the current language.
[in]fallbackFallback string if the asset has no name.
Returns
String on success.

◆ StoreMetaString()

MAXON_METHOD Result<void> StoreMetaString ( const InternedId key,
const String value,
const LanguageRef &  languageRef 
) const

StoreMetaString stores the name of an asset for a language.

Parameters
[in]keyAttribute id to save. e.g. OBJECT::BASE:NAME.
[in]valueNew string.
[in]languageRefOptional language. By default the function uses the current language.
Returns
OK on success.