AssetLinkInterface Class Reference

#include <assets.h>

Inheritance diagram for AssetLinkInterface:

Detailed Description

An AssetLink is a symbolic link to an asset identified by its id and version. The asset's origin data can also be included in the link to allow tracking and debugging of missing assets. Also an ASSET_UPDATE_POLICY is stored to control the behavior of the link when newer versions of the linked asset exists.

Alternatively an AssetLink can also just wrap a Url from which an asset can be loaded directly.

Public Member Functions

 MAXON_ATTRIBUTE_CLASS (String, NAME, "net.maxon.assetlink.origin.name")
 
 MAXON_ATTRIBUTE_CLASS (decltype(maxon::ASSETMETADATA::ASSET_VERSIONTAG)::ValueType, VERSIONTAG, "net.maxon.assetlink.origin.versiontag")
 
 MAXON_ATTRIBUTE_CLASS (Id, Category, "net.maxon.assetlink.origin.category")
 
 MAXON_ATTRIBUTE_CLASS (String, REPOSITORYNAME, "net.maxon.assetlink.origin.reponame")
 
 MAXON_ATTRIBUTE_CLASS (Id, REPOSITORYID, "net.maxon.assetlink.origin.repoid")
 
 MAXON_ATTRIBUTE_CLASS (Data, INSTANCEDATA, "net.maxon.assetlink.origin.instancedata")
 
MAXON_METHOD const UrlGetUrl () const
 
MAXON_METHOD Result< AssetDescription > Resolve (const AssetRepositoryRef &context) const
 
MAXON_METHOD ASSET_UPDATE_POLICY GetUpdatePolicy () const
 
MAXON_METHOD void SetUpdatePolicy (ASSET_UPDATE_POLICY up)
 
MAXON_METHOD Result< void > SetUrl (const Url &url)
 
MAXON_METHOD Result< void > SetIdAndVersion (const IdAndVersion &aid)
 
MAXON_METHOD Result< DataDictionary > GetOriginData () const
 
MAXON_METHOD Result< void > SetOriginData (const DataDictionary &originData)
 

Static Public Member Functions

static MAXON_METHOD Result< AssetLink > Create (const AssetDescription &asset, ASSET_UPDATE_POLICY up)
 
static MAXON_METHOD Result< AssetLink > Create (const Id &type, const IdAndVersion &aid, ASSET_UPDATE_POLICY up)
 
static MAXON_METHOD Result< AssetLink > Create (const Id &type, const Url &url)
 

Static Public Attributes

static constexpr ASSET_UPDATE_POLICY DEFAULT_LINK_POLICY
 

Private Member Functions

 MAXON_INTERFACE (AssetLinkInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.assetlink", MAXON_IMPLEMENTATION_MODULE("net.maxon.asset"))
 

Private Attributes

 MAXON_INTERFACE_SINGLE_IMPLEMENTATION
 

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( AssetLinkInterface  ,
MAXON_REFERENCE_COPY_ON_WRITE  ,
"net.maxon.interface.assetlink"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.asset")   
)
private

◆ MAXON_ATTRIBUTE_CLASS() [1/6]

MAXON_ATTRIBUTE_CLASS ( String  ,
NAME  ,
"net.maxon.assetlink.origin.name"   
)

Original name of the asset (default language). Won't prevent resolving links if an asset was renamed.

◆ MAXON_ATTRIBUTE_CLASS() [2/6]

MAXON_ATTRIBUTE_CLASS ( decltype(maxon::ASSETMETADATA::ASSET_VERSIONTAG)::ValueType  ,
VERSIONTAG  ,
"net.maxon.assetlink.origin.versiontag"   
)

Original ASSETMETADATA::ASSET_VERSIONTAG (default language).

◆ MAXON_ATTRIBUTE_CLASS() [3/6]

MAXON_ATTRIBUTE_CLASS ( Id  ,
Category  ,
"net.maxon.assetlink.origin.category"   
)

Original category of the asset. Won't prevent resolving links if an asset was changed to a new category.

◆ MAXON_ATTRIBUTE_CLASS() [4/6]

MAXON_ATTRIBUTE_CLASS ( String  ,
REPOSITORYNAME  ,
"net.maxon.assetlink.origin.reponame"   
)

Original repository name of the asset. Won't prevent resolving links if an asset was moved to a different repository, this is just to help handling missing assets.

◆ MAXON_ATTRIBUTE_CLASS() [5/6]

MAXON_ATTRIBUTE_CLASS ( Id  ,
REPOSITORYID  ,
"net.maxon.assetlink.origin.repoid"   
)

Original repository identifier of the asset. Won't prevent resolving links if an asset was moved to a different repository, this is just to help handling missing assets.

◆ MAXON_ATTRIBUTE_CLASS() [6/6]

MAXON_ATTRIBUTE_CLASS ( Data  ,
INSTANCEDATA  ,
"net.maxon.assetlink.origin.instancedata"   
)

Asset instance data. Content varies per asset type. All the data required to reinstate a broken asset link should be included. I.e. any additional data needed to fix a scene that was saved with missing assets.

◆ Create() [1/3]

static MAXON_METHOD Result<AssetLink> Create ( const AssetDescription &  asset,
ASSET_UPDATE_POLICY  up 
)
static

Creates a new link to the given asset with requested update policy.

Parameters
[in]assetThe asset to link to. Asset type, identifier and version will be read from it to create the link.
[in]upThe update policy which the created link shall use.
Returns
A new AssetLink.

◆ Create() [2/3]

static MAXON_METHOD Result<AssetLink> Create ( const Id type,
const IdAndVersion aid,
ASSET_UPDATE_POLICY  up 
)
static

Creates a new link to the given asset with requested update policy.

Parameters
[in]typeThe expected type of the asset.
[in]aidIdentifier and version of the asset.
[in]upThe update policy which the created link shall use.
Returns
A new AssetLink.

◆ Create() [3/3]

static MAXON_METHOD Result<AssetLink> Create ( const Id type,
const Url url 
)
static

Creates a new link for the given Url. This is for assets which aren't stored in a repository, but shall be read directly from a Url such as a local image file. Url links use policy ASSET_UPDATE_POLICY::NEVER.

Parameters
[in]typeThe expected type of the asset.
[in]urlThe Url where the asset can be read from.
Returns
A new AssetLink.

◆ GetUrl()

MAXON_METHOD const Url& GetUrl ( ) const

Returns the Url for a Url-based AssetLink.

Returns
The Url to which this AssetLink points, or a default value when this AssetLink uses an asset identifier instead of a Url.

◆ Resolve()

MAXON_METHOD Result<AssetDescription> Resolve ( const AssetRepositoryRef &  context) const

Resolves this AssetLink to an AssetDescription in the given context. The asset identifier of this link is used to find the asset in context, and if this link uses the policy ASSET_UPDATE_POLICY::IMPLICIT the latest version of the asset is used, otherwise the version recorded in this link.

Parameters
[in]contextThe repository to use for the asset lookup.
Returns
The found AssetDescription or a default value when no asset could be found.

◆ GetUpdatePolicy()

MAXON_METHOD ASSET_UPDATE_POLICY GetUpdatePolicy ( ) const

Returns the update policy which this link uses.

Returns
The update policy of this link.

◆ SetUpdatePolicy()

MAXON_METHOD void SetUpdatePolicy ( ASSET_UPDATE_POLICY  up)

Sets the update policy for this link.

Parameters
[in]upThe new update policy for this link.

◆ SetUrl()

MAXON_METHOD Result<void> SetUrl ( const Url url)

Sets the asset link's url. This will clear the Id and ASSET_UPDATE_POLICY.

Parameters
[in]urlThe Url to which this AssetLink points.
Returns
OK on success.

◆ SetIdAndVersion()

MAXON_METHOD Result<void> SetIdAndVersion ( const IdAndVersion aid)

Sets the asset link's identifier. This will clear the Url. One might want to update the asset link's update policy afterwards.

Parameters
[in]aidThe asset identifier and version.
Returns
OK on success.

◆ GetOriginData()

MAXON_METHOD Result<DataDictionary> GetOriginData ( ) const

Gets the asset link's origin informations.

Returns
Dictionary of of the asset's origin details.

◆ SetOriginData()

MAXON_METHOD Result<void> SetOriginData ( const DataDictionary &  originData)

Sets the asset link's origin data informations.

Parameters
[in]originDataThe new origin informations (will overwrite existing).
Returns
OK on success.

Member Data Documentation

◆ MAXON_INTERFACE_SINGLE_IMPLEMENTATION

MAXON_INTERFACE_SINGLE_IMPLEMENTATION
private

◆ DEFAULT_LINK_POLICY

constexpr ASSET_UPDATE_POLICY DEFAULT_LINK_POLICY
staticconstexpr

Default update policy used in AssetLink.