AssetTypeInterface Class Reference

#include <assets.h>

Inheritance diagram for AssetTypeInterface:

Detailed Description

An AssetType provides the methods needed by an asset repository to handle a specific type of assets. For example there is one asset type for node systems which knows how to load and store node systems and their description resources, one for pure files and so on. Asset types are registered at the AssetTypes registry.

Public Types

using RESTRICT_DICTIONARY_PROPS = ASSETTYPEPROPERTIES::RESTRICT
 

Public Member Functions

MAXON_METHOD const IdGetId () const
 
MAXON_METHOD const DataTypeGetAssetDataType () const
 
MAXON_METHOD Result< StringGetUrlSuffix (const Asset &asset) const
 
MAXON_METHOD Result< UrlGetDefaultIcon (const AssetRepositoryRef &repository, const IdAndVersion &asset, const AssetMetaData &meta) const
 
MAXON_METHOD Result< AssetLoad (const AssetRepositoryRef &repo, const AssetDescription &assetDescription, const Url &url, Bool *updateLinks) const
 
MAXON_METHOD Result< HashMap< InternedId, Data > > Store (const Asset &asset, const Url &url, const OutputStreamDecoratorFactory &hashStream) const
 
MAXON_METHOD Result< void > CopyWithEncryption (const AssetDescription &source, const Url &from, const Url &to) const
 
MAXON_METHOD Result< DataDescriptionDefinition > LoadDescriptionDefinition (const AssetDescription &asset, LOADDESCRIPTIONMODE mode, const Id &category, const LanguageRef &language) const
 
MAXON_METHOD Result< AssetDescription > StoreDescriptionDefinition (const AssetDescription &asset, const Id &category, const LanguageRef &language, const DataDescriptionDefinition &overwrittenDescription, const AssetRepositoryRef &storeRepository) const
 
MAXON_METHOD Result< IdGetRepositoryId (const Id &id, Bool fromTo) const
 
MAXON_METHOD Result< StringGetMetaString (const AssetDescription &asset, const InternedId &key, const LanguageRef &languageRef, const String &fallback) const
 
MAXON_METHOD Result< void > StoreMetaString (const AssetDescription &asset, const InternedId &key, const String &value, const LanguageRef &languageRef) const
 
MAXON_METHOD Result< Tuple< Data, Bool > > ComputeMetaData (const AssetRepositoryRef &repository, const IdAndVersion &asset, const AssetMetaData &meta, const InternedId &metaId) const
 

Private Member Functions

 MAXON_INTERFACE (AssetTypeInterface, MAXON_REFERENCE_CONST, "net.maxon.interface.assettype")
 

Member Typedef Documentation

◆ RESTRICT_DICTIONARY_PROPS

using RESTRICT_DICTIONARY_PROPS = ASSETTYPEPROPERTIES::RESTRICT

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( AssetTypeInterface  ,
MAXON_REFERENCE_CONST  ,
"net.maxon.interface.assettype"   
)
private

◆ GetId()

MAXON_METHOD const Id& GetId ( ) const

Returns the identifier of this asset type. This has to be the same as used for the AssetTypes registry.

Returns
Asset type identifier.

◆ GetAssetDataType()

MAXON_METHOD const DataType& GetAssetDataType ( ) const

Returns the DataType of assets handled by this AssetType. The data type has to be a reference type derived from Asset.

Returns
The data type of assets of this AssetType.

◆ GetUrlSuffix()

MAXON_METHOD Result<String> GetUrlSuffix ( const Asset asset) const

Returns the Url suffix (file name ending without the dot) to use for the given asset.

Parameters
[in]assetAn asset, has to match the expected data type of this AssetType.
Returns
The Url suffix to use, may be empty.

◆ GetDefaultIcon()

MAXON_METHOD Result<Url> GetDefaultIcon ( const AssetRepositoryRef &  repository,
const IdAndVersion asset,
const AssetMetaData &  meta 
) const

GetDefaultIcon returns the default icon of this asset type.

Parameters
[in]repositoryRepository to search for.
[in]assetAsset id and version.
[in]metameta data of the asset to store.
Returns
OK on success.

◆ Load()

MAXON_METHOD Result<Asset> Load ( const AssetRepositoryRef &  repo,
const AssetDescription &  assetDescription,
const Url url,
Bool updateLinks 
) const

Loads an asset from a Url.

Parameters
[in]repoThe repository to which the asset belongs.
[in]assetDescriptionThe asset description.
[in]urlThe Url from which the asset shall be loaded.
[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.

◆ Store()

MAXON_METHOD Result<HashMap<InternedId, Data> > Store ( const Asset asset,
const Url url,
const OutputStreamDecoratorFactory hashStream 
) const

Stores an asset at the given Url.

Parameters
[in]assetThe asset to store, has to match the expected data type of this AssetType.
[in]urlThe Url where to store the asset.
[in]hashStreamThe stream decorator to use for each created output stream. This can be used by the caller to compute a hash value of the asset content which is then used as version identifier.
Returns
A map for additional persistent meta data entries which the calling repository has to store for the asset.

◆ CopyWithEncryption()

MAXON_METHOD Result<void> CopyWithEncryption ( const AssetDescription &  source,
const Url from,
const Url to 
) const

CopyWithEncryption copies the asset with encryption to the new url.

Parameters
[in]sourceAsset to copy.
[in]fromsource url.
[in]todestination url.
Returns
OK on success.

◆ LoadDescriptionDefinition()

MAXON_METHOD Result<DataDescriptionDefinition> LoadDescriptionDefinition ( const AssetDescription &  asset,
LOADDESCRIPTIONMODE  mode,
const Id category,
const LanguageRef &  language 
) const

LoadDescriptionDefinition loads the data description of the given asset.

Parameters
[in]assetAsset to load.
[in]modesee LOADDESCRIPTIONMODE.
[in]categoryDATADESCRIPTION_CATEGORY_xxx
[in]languageLanguage id in case of DATADESCRIPTION_CATEGORY_STRING.
Returns
DataDescriptionDefinition on success.

◆ StoreDescriptionDefinition()

MAXON_METHOD Result<AssetDescription> StoreDescriptionDefinition ( const AssetDescription &  asset,
const Id category,
const LanguageRef &  language,
const DataDescriptionDefinition &  overwrittenDescription,
const AssetRepositoryRef &  storeRepository 
) const

StoreDescriptionDefinition description.

Parameters
[in]assetAsset to store.
[in]categoryDATADESCRIPTION_CATEGORY_xxx
[in]languageLanguage id in case of DATADESCRIPTION_CATEGORY_STRING.
[in]overwrittenDescriptionAdditional description with overwritten parameters.
[in]storeRepositoryRepository to store the asset.
Returns
AssetDescription with the new asset on success.

◆ GetRepositoryId()

MAXON_METHOD Result<Id> GetRepositoryId ( const Id id,
Bool  fromTo 
) const

GetRepositoryId returns the default id of the asset.

Parameters
[in]idId of the asset.
[in]fromToTrue to add the full id. False to cut the hash code and append it.
Returns
New id on success.

◆ GetMetaString()

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

GetMetaString returns the translated string from a asset.

Parameters
[in]assetAsset to load.
[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 AssetDescription &  asset,
const InternedId key,
const String value,
const LanguageRef &  languageRef 
) const

StoreMetaString stores the name of an asset for a language.

Parameters
[in]assetAsset to modify.
[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.

◆ ComputeMetaData()

MAXON_METHOD Result<Tuple<Data, Bool> > ComputeMetaData ( const AssetRepositoryRef &  repository,
const IdAndVersion asset,
const AssetMetaData &  meta,
const InternedId metaId 
) const

Overload ComputeMetaData to specialize the loading of meta data.

Parameters
[in]repositoryResository where the asset is stored.
[in]assetAsset id and version.
[in]metaMeta data of the asset.
[in]metaIdMetaId to load.
Returns
Tuple<Data, Bool> on success. Data contains the data. Bool if the value should be cached.