AssetRepositoryInterface Class Reference

#include <assets.h>

Inheritance diagram for AssetRepositoryInterface:

Detailed Description

An AssetRepositoryInterface manages a set of assets:

  • Assets can be looked up using their identifier and version.
  • New assets or new asset versions can be stored.
  • Each asset can have associated meta data which can be read and written.
  • Observers for changes to the repository can be added.

An asset repository can have several base repositories which are used for the lookup after lookup in the repository itself has finished. Cycles aren't allowed, so asset repositories form a directed acyclic graph.

A repository which has another repository as (direct or indirect) base is said to be /derived/ from that repository. Whenever an observable of a repository is triggered, this is done for all derived repositories too.

The methods of AssetRepositoryInterface are thread-safe. This allows for concurrent modifications and queries.

Public Types

using LatestAssetMap = HashMap< Id, AssetDescription >
 

Public Member Functions

MAXON_METHOD const IdGetId () const
 
MAXON_METHOD Array< AssetRepositoryRef > GetBases () const
 
MAXON_METHOD Result< BoolGetDerived (const ValueReceiver< const AssetRepositoryRef & > &receiver) const
 
MAXON_METHOD Result< void > InitBases (const Block< const AssetRepositoryRef > &bases)
 
MAXON_METHOD Result< void > AddBase (const AssetRepositoryRef &base)
 
MAXON_METHOD Result< void > RemoveBase (const AssetRepositoryRef &base)
 
MAXON_METHOD AssetRepositoryRef FindRepository (const Id &repoId) const
 
MAXON_FUNCTION Bool IsBasedOnOrSame (const AssetRepositoryRef &other) const
 
MAXON_FUNCTION Bool IsBasedOnOrSame (const Id &other) const
 
MAXON_METHOD Bool IsWritable () const
 
MAXON_METHOD Result< BoolPrivateFindAssets (const Block< const Id > &types, const Id &aid, const Id &version, ASSET_FIND_MODE findMode, const ValueReceiver< const AssetDescription & > &assets, HashSet< const AssetRepositoryInterface * > &visited, LatestAssetMap &latestMap) const
 
MAXON_METHOD Result< void > PrivatePrefetchMetaData (const InternedId &metaId, AssetMetaDataInterface::KIND kind, ASSET_FIND_MODE findMode, HashSet< const AssetRepositoryInterface * > &visited)
 
MAXON_FUNCTION Result< BoolFindAssets (const Id &type, const Id &aid, const Id &version, ASSET_FIND_MODE findMode, const ValueReceiver< const AssetDescription & > &receiver) const
 
MAXON_FUNCTION Result< BoolFindAssets (const AssetType &type, const Id &aid, const Id &version, ASSET_FIND_MODE findMode, const ValueReceiver< const AssetDescription & > &receiver) const
 
MAXON_METHOD Result< BoolFindAssets (const Block< const Id > &types, const Id &aid, const Id &version, ASSET_FIND_MODE findMode, const ValueReceiver< const AssetDescription & > &receiver) const
 
MAXON_METHOD Result< AssetDescription > FindLatestAsset (const Id &type, const Id &aid, const Id &version, ASSET_FIND_MODE findMode=ASSET_FIND_MODE::NONE) const
 
MAXON_FUNCTION Result< AssetDescription > FindLatestAsset (const AssetType &type, const Id &aid, const Id &version, ASSET_FIND_MODE findMode=ASSET_FIND_MODE::NONE) const
 
MAXON_METHOD Result< AssetDescription > GetDescription (const Asset &asset) const
 
MAXON_METHOD COMPARERESULT CompareVersions (const AssetBase &first, const AssetBase &second) const
 
MAXON_METHOD Result< AssetDescription > StoreAsset (const Id &aid, Asset &asset, const AssetMetaData &metaData=GetZeroRef< AssetMetaData >())
 
template<typename ASSET , typename = typename std::enable_if<maxon::HasBaseDetector<typename ASSET::ReferencedType, AssetInterface>::value>::type>
MAXON_FUNCTION Result< AssetDescription > StoreAsset (const Id &aid, ASSET &asset, const AssetMetaData &metaData=GetZeroRef< AssetMetaData >())
 
MAXON_METHOD Result< AssetDescription > OverwriteAsset (const Id &aid, Asset &asset, const AssetMetaData &metaData=GetZeroRef< AssetMetaData >())
 
template<typename ASSET , typename = typename std::enable_if<maxon::HasBaseDetector<typename ASSET::ReferencedType, AssetInterface>::value>::type>
MAXON_FUNCTION Result< AssetDescription > OverwriteAsset (const Id &aid, ASSET &asset, const AssetMetaData &metaData=GetZeroRef< AssetMetaData >())
 
MAXON_METHOD Result< AssetDescription > DeleteAsset (const Id &aid)
 
MAXON_METHOD Result< void > EraseAsset (const AssetDescription &asset)
 
MAXON_METHOD Result< AssetDescription > CopyAsset (const Id &aid, const AssetDescription &source, Bool addEncryption=false, Bool overwrite=false)
 
MAXON_METHOD Result< void > StoreMetaData (const AssetDescription &asset, const InternedId &metaId, ForwardingDataPtr &&data, AssetMetaDataInterface::KIND kind)
 
MAXON_METHOD Result< void > StoreUrlMetaData (const AssetDescription &asset, const InternedId &metaId, const Url &source, AssetMetaDataInterface::KIND kind)
 
 MAXON_OBSERVABLE (void, ObservableBaseChanged,(const AssetRepositoryRef &base, Bool added), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableAssetStored,(const AssetDescription &asset), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableAssetErased,(const AssetDescription &asset), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableAssetUpdated,(const Asset &asset), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableMetaDataStored,(const AssetDescription &asset, const InternedId &metaId, AssetMetaDataInterface::KIND kind, const Data &prevData, const Data &newData), ObservableCombinerRunAllComponent)
 
 MAXON_OBSERVABLE (void, ObservableDownloadStateChanged,(const AssetRepositoryRef &repository, Bool finished), ObservableCombinerRunAllComponent)
 
MAXON_METHOD Result< const GenericData & > GetCachedData (MoveDataPtr &&key, const Delegate< Result< GenericData >()> &callback)
 
MAXON_METHOD Result< IdGetDescriptionDatabaseId () const
 
MAXON_METHOD Result< DataDescription > LoadDescription (const Id &category, const LanguageRef &language, const AssetDescription &asset)
 
MAXON_METHOD Result< DataDescription > LoadDescription (const Id &category, const LanguageRef &language, const IdAndVersion &dataType)
 
MAXON_FUNCTION Result< DataDescription > LoadDescription (const Id &category, const LanguageRef &language, const Id &dataType)
 
MAXON_METHOD Result< DataDescriptionDefinition > LoadDescriptionDefinition (LOADDESCRIPTIONMODE mode, const Id &category, const LanguageRef &language, const AssetDescription &asset)
 
MAXON_METHOD Result< StringGetRepositoryName (const LanguageRef &language, Bool addDetails) const
 
MAXON_METHOD Result< void > SetRepositoryName (const String &name, const LanguageRef &language)
 
MAXON_METHOD Result< const DerivedAssetRepositoryDataRef & > GetCachedData (MoveDataPtr &&key, const Delegate< Result< DerivedAssetRepositoryDataRef >()> &callback)
 
MAXON_METHOD void HandleDownloadStateChanged (const AssetRepositoryRef &repository, Bool finished)
 
MAXON_METHOD void RequestUnloadRepository ()
 
template<typename ASSET , typename >
Result< AssetDescription > StoreAsset (const Id &aid, ASSET &asset, const AssetMetaData &metaData)
 
template<typename ASSET , typename >
Result< AssetDescription > OverwriteAsset (const Id &aid, ASSET &asset, const AssetMetaData &metaData)
 

Protected Member Functions

MAXON_METHOD void HandleBaseChanged (const AssetRepositoryRef &base, Bool added)
 
MAXON_METHOD void HandleAssetStored (const AssetDescription &asset)
 
MAXON_METHOD void HandleAssetErased (const AssetDescription &asset)
 
MAXON_METHOD void HandleAssetUpdated (const Asset &asset)
 
MAXON_METHOD void HandleMetaDataStored (const AssetDescription &asset, const InternedId &metaId, AssetMetaDataInterface::KIND kind, const Data &prevData, const Data &newData)
 

Private Member Functions

 MAXON_INTERFACE (AssetRepositoryInterface, MAXON_REFERENCE_NORMAL, "net.maxon.interface.assetrepository", MAXON_IMPLEMENTATION_MODULE("net.maxon.asset"))
 
- Private Member Functions inherited from DataDictionaryObjectInterface
MAXON_METHOD Result< void > SetData (ForwardingDataPtr &&key, Data &&data)
 
MAXON_FUNCTION Result< void > SetData (ForwardingDataPtr &&key, const Data &data)
 
MAXON_METHOD Result< DataGetData (const ConstDataPtr &key) const
 
template<typename KEY >
MAXON_FUNCTION Bool Contains (KEY &&key) const
 
MAXON_METHOD Result< void > EraseData (const ConstDataPtr &key)
 
MAXON_METHOD void Reset ()
 
MAXON_METHOD Bool IsEmpty () const
 
MAXON_FUNCTION Bool IsPopulated () const
 
template<typename REFCLASS , typename T = void, typename KEY >
MAXON_FUNCTION Result< typename std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::typeGet (KEY &&key) const
 
template<typename REFCLASS , typename T , typename KEY >
MAXON_FUNCTION std::conditional< IsFidClass< KEY >::value &&GetCollectionKind< T >::value !=COLLECTION_KIND::ARRAY, typename IsFidClass< KEY >::type, T >::type Get (KEY &&key, const T &defaultValue) const
 
template<typename REFCLASS , typename T , typename KEY >
MAXON_FUNCTION std::conditional< IsFidClass< KEY >::value &&GetCollectionKind< T >::value !=COLLECTION_KIND::ARRAY, typename IsFidClass< KEY >::type, T >::type Get (KEY &&key, T &&defaultValue) const
 
template<typename T = void, typename KEY >
MAXON_FUNCTION std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::type GetOrDefault (KEY &&key) const
 
template<typename REFCLASS , typename T , typename KEY >
MAXON_FUNCTION Result< void > Set (KEY &&key, T &&data)
 
template<typename REFCLASS , typename KEY >
MAXON_FUNCTION Result< void > Erase (KEY &&key)
 
MAXON_METHOD void InitIterator (DataDictionaryIteratorInterface *iterator, Bool end) const
 
MAXON_FUNCTION ConstIterator Begin () const
 
MAXON_FUNCTION ConstIterator End () const
 
template<typename T , typename KEY >
std::conditional< std::is_void< T >::value, typename IsFidClass< KEY >::type, T >::type GetOrDefault (KEY &&key) const
 

Additional Inherited Members

- Private Types inherited from DataDictionaryObjectInterface
using Iterator = DataDictionaryIterator
 
using ConstIterator = DataDictionaryIterator
 

Member Typedef Documentation

◆ LatestAssetMap

using LatestAssetMap = HashMap<Id, AssetDescription>

Member Function Documentation

◆ MAXON_INTERFACE()

MAXON_INTERFACE ( AssetRepositoryInterface  ,
MAXON_REFERENCE_NORMAL  ,
"net.maxon.interface.assetrepository"  ,
MAXON_IMPLEMENTATION_MODULE("net.maxon.asset")   
)
private

◆ GetId()

MAXON_METHOD const Id& GetId ( ) const

Returns the identifier of this repository. Repository identifiers needn't be unique, but a repository must not have the same identifier as one of its (direct or indirect) bases.

Returns
The identifier of this repository.

◆ GetBases()

MAXON_METHOD Array<AssetRepositoryRef> GetBases ( ) const

Returns an array holding all current base repositories of this repository. but a repository must not have the same identifier as one of its (direct or indirect) bases.

Returns
The identifier of this repository.

◆ GetDerived()

MAXON_METHOD Result<Bool> GetDerived ( const ValueReceiver< const AssetRepositoryRef & > &  receiver) const

Yields all derived repositories of this repository to #receiver (those which have this repository as direct base).

Parameters
[in]receiverThe receiver for derived repositories.
Returns
false if the receiver cancelled further evaluation, true otherwise.

◆ InitBases()

MAXON_METHOD Result<void> InitBases ( const Block< const AssetRepositoryRef > &  bases)

Initializes the base repositories of this repository. This function may only be called once right after the AssetRepositoryInterface instance has been created. It doesn't inform any observers.

Parameters
[in]basesThe bases of this repository.

◆ AddBase()

MAXON_METHOD Result<void> AddBase ( const AssetRepositoryRef &  base)

Adds base to the list of base repositories of this repository. The observers for ObservableBaseChanged of this repository and its derived repositories are informed.

Parameters
[in]baseThe base repository to add.

◆ RemoveBase()

MAXON_METHOD Result<void> RemoveBase ( const AssetRepositoryRef &  base)

Removes base from the list of base repositories of this repository. The observers for ObservableBaseChanged of this repository and its derived repositories are informed. Nothing happens if this repository doesn't have base as one of its bases.

Parameters
[in]baseThe base repository to remove.

◆ FindRepository()

MAXON_METHOD AssetRepositoryRef FindRepository ( const Id repoId) const

Finds the repository with the given identifier among this repository and its direct and indirect bases. If no such repository exists, a null reference is returned.

Parameters
[in]repoIdThe identifier of the repository to find.
Returns
The found repository, or a null reference.

◆ IsBasedOnOrSame() [1/2]

MAXON_FUNCTION Bool IsBasedOnOrSame ( const AssetRepositoryRef &  other) const

Returns true if this repository is based on other or other itself, false otherwise.

Parameters
[in]otherA repository.
Returns
True if other is a direct or indirect base of this repository or this repository itself.

◆ IsBasedOnOrSame() [2/2]

MAXON_FUNCTION Bool IsBasedOnOrSame ( const Id other) const

Returns true if this repository is based a repository with identifier other or has that identifier itself, false otherwise.

Parameters
[in]otherA repository identifier.
Returns
True if other denotes a direct or indirect base of this repository or this repository itself.

◆ IsWritable()

MAXON_METHOD Bool IsWritable ( ) const

Tells if this repository is writable or not.

Returns
True if this repository is writable, false otherwise.

◆ PrivateFindAssets()

MAXON_METHOD Result<Bool> PrivateFindAssets ( const Block< const Id > &  types,
const Id aid,
const Id version,
ASSET_FIND_MODE  findMode,
const ValueReceiver< const AssetDescription & > &  assets,
HashSet< const AssetRepositoryInterface * > &  visited,
LatestAssetMap latestMap 
) const

◆ PrivatePrefetchMetaData()

MAXON_METHOD Result<void> PrivatePrefetchMetaData ( const InternedId metaId,
AssetMetaDataInterface::KIND  kind,
ASSET_FIND_MODE  findMode,
HashSet< const AssetRepositoryInterface * > &  visited 
)

PrivatePrefetchMetaData prefetches all meta data of the given type.

Parameters
[in]metaIdMetaData id to prefetch.
[in]findModesee ASSET_FIND_MODE.
[in]visitedtemp Hashmap.
Returns
OK on success.

◆ FindAssets() [1/3]

MAXON_FUNCTION Result<Bool> FindAssets ( const Id type,
const Id aid,
const Id version,
ASSET_FIND_MODE  findMode,
const ValueReceiver< const AssetDescription & > &  receiver 
) const

Finds all assets matching the parameters:

  • If aid is set, only assets with that identifier are found (or which have the aid as prefix when ASSET_FIND_MODE::PREFIX is set), otherwise all assets.
  • If version is set, only assets with that version are found, otherwise
  • If ASSET_FIND_MODE::WITHOUT_BASES is set in findMode, then base repositories aren't taken into account. Otherwise they are considered after this repository.
  • If ASSET_FIND_MODE::WITH_DELETED is set in findMode, then also deleted assets are reported.

When version is given or ASSET_FIND_MODE::LATEST is used and a matching asset is found in a repository, assets in base repositories thereof aren't reported even if they are newer. So then an asset in a repository hides assets with the same identifier in base repositories. Assets with another identifier are still reported.

Parameters
[in]typeThe allowed asset type.
[in]aidThe asset identifier to lookup, use an empty identifier to find all assets.
[in]versionThe version identifier to find, use an empty identifier to find all versions.
[in]findModeFlags for the lookup.
[in]receiverAll found assets are reported to this receiver.
Returns
false if the receiver cancelled further evaluation, true otherwise.

◆ FindAssets() [2/3]

Result< Bool > FindAssets ( const AssetType &  type,
const Id aid,
const Id version,
ASSET_FIND_MODE  findMode,
const ValueReceiver< const AssetDescription & > &  receiver 
) const

Finds all assets matching the parameters:

  • If aid is set, only assets with that identifier are found (or which have the aid as prefix when ASSET_FIND_MODE::PREFIX is set), otherwise all assets.
  • If version is set, only assets with that version are found, otherwise
  • If ASSET_FIND_MODE::WITHOUT_BASES is set in findMode, then base repositories aren't taken into account. Otherwise they are considered after this repository.
  • If ASSET_FIND_MODE::WITH_DELETED is set in findMode, then also deleted assets are reported.

When version is given or ASSET_FIND_MODE::LATEST is used and a matching asset is found in a repository, assets in base repositories thereof aren't reported even if they are newer. So then an asset in a repository hides assets with the same identifier in base repositories. Assets with another identifier are still reported.

Parameters
[in]typeThe allowed asset type.
[in]aidThe asset identifier to lookup, use an empty identifier to find all assets.
[in]versionThe version identifier to find, use an empty identifier to find all versions.
[in]findModeFlags for the lookup.
[in]receiverAll found assets are reported to this receiver.
Returns
false if the receiver cancelled further evaluation, true otherwise.

◆ FindAssets() [3/3]

MAXON_METHOD Result<Bool> FindAssets ( const Block< const Id > &  types,
const Id aid,
const Id version,
ASSET_FIND_MODE  findMode,
const ValueReceiver< const AssetDescription & > &  receiver 
) const

Finds all assets matching the parameters:

  • If aid is set, only assets with that identifier are found (or which have the aid as prefix when ASSET_FIND_MODE::PREFIX is set), otherwise all assets.
  • If version is set, only assets with that version are found, otherwise
  • If ASSET_FIND_MODE::WITHOUT_BASES is set in findMode, then base repositories aren't taken into account. Otherwise they are considered after this repository.
  • If ASSET_FIND_MODE::WITH_DELETED is set in findMode, then also deleted assets are reported.

When version is given or ASSET_FIND_MODE::LATEST is used and a matching asset is found in a repository, assets in base repositories thereof aren't reported even if they are newer. So then an asset in a repository hides assets with the same identifier in base repositories. Assets with another identifier are still reported.

Parameters
[in]typesThe allowed asset types.
[in]aidThe asset identifier to lookup, use an empty identifier to find all assets.
[in]versionThe version identifier to find, use an empty identifier to find all versions.
[in]findModeFlags for the lookup.
[in]receiverAll found assets are reported to this receiver.
Returns
false if the receiver cancelled further evaluation, true otherwise.

◆ FindLatestAsset() [1/2]

MAXON_METHOD Result<AssetDescription> FindLatestAsset ( const Id type,
const Id aid,
const Id version,
ASSET_FIND_MODE  findMode = ASSET_FIND_MODE::NONE 
) const

Finds the asset with the given identifier in this repository and its base repositories. If version is set, this finds the asset with that version, otherwise it finds the latest asset. When a matching asset is found in a repository, assets in base repositories thereof aren't considered even if they are newer.

Parameters
[in]typeThe allowed asset type.
[in]aidThe asset identifier to lookup.
[in]versionThe version identifier to find, use an empty identifier to find the latest version.
[in]findModeFlags for the lookup, only ASSET_FIND_MODE::WITHOUT_BASES and ASSET_FIND_MODE::WITH_DELETED make sense for this method.
Returns
The found asset, or a null reference.

◆ FindLatestAsset() [2/2]

Result< AssetDescription > FindLatestAsset ( const AssetType &  type,
const Id aid,
const Id version,
ASSET_FIND_MODE  findMode = ASSET_FIND_MODE::NONE 
) const

Finds the asset with the given identifier in this repository and its base repositories. If version is set, this finds the asset with that version, otherwise it finds the latest asset. When a matching asset is found in a repository, assets in base repositories thereof aren't considered even if they are newer.

Parameters
[in]typeThe allowed asset type.
[in]aidThe asset identifier to lookup.
[in]versionThe version identifier to find, use an empty identifier to find the latest version.
[in]findModeFlags for the lookup, only ASSET_FIND_MODE::WITHOUT_BASES and ASSET_FIND_MODE::WITH_DELETED make sense for this method.
Returns
The found asset, or a null reference.

◆ GetDescription()

MAXON_METHOD Result<AssetDescription> GetDescription ( const Asset asset) const

GetDescription returns the AssetDescription of the given asset.

Parameters
[in]assetAsset to query.
Returns
AssetDescription on success.

◆ CompareVersions()

MAXON_METHOD COMPARERESULT CompareVersions ( const AssetBase &  first,
const AssetBase &  second 
) const

Compares the versions of assets of this repository:

Being newer isn't based on the time stamp, but on the order in which assets are stored. It also takes into account the update counter (AssetInterface::GetUpdate) when both assets have the same version identifier.

If both assets have different asset identifiers the method returns COMPARERESULT::INCOMPARABLE. If the assets don't belong to this repository, the result is unspecified.

Parameters
[in]firstThe first asset.
[in]secondThe second asset.
Returns
The result of the comparison of the versions.

◆ StoreAsset() [1/3]

MAXON_METHOD Result<AssetDescription> StoreAsset ( const Id aid,
Asset asset,
const AssetMetaData &  metaData = GetZeroRef< AssetMetaData >() 
)

Stores asset as a new version using the identifier #aid. Identifier, version and repository are set correspondingly at #asset, so #asset may point to a copy of the original object afterwards (Asset is a copy-on-write reference).

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
[in]aidThe asset identifier to use.
[in,out]assetThe asset object to store. This method sets identifier, version and repository of #asset.
[in]metaDataInitial meta data to use for the asset.
Returns
The AssetDescription for the added asset.

◆ StoreAsset() [2/3]

MAXON_FUNCTION Result<AssetDescription> StoreAsset ( const Id aid,
ASSET &  asset,
const AssetMetaData &  metaData = GetZeroRef< AssetMetaData >() 
)

Stores asset as a new version using the identifier #aid. Identifier, version and repository are set correspondingly at #asset, so #asset may point to a copy of the original object afterwards (Asset is a copy-on-write reference).

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
[in]aidThe asset identifier to use.
[in,out]assetThe asset object to store. This method sets identifier, version and repository of #asset.
[in]metaDataInitial meta data to use for the asset.
Returns
The AssetDescription for the added asset.

◆ OverwriteAsset() [1/3]

MAXON_METHOD Result<AssetDescription> OverwriteAsset ( const Id aid,
Asset asset,
const AssetMetaData &  metaData = GetZeroRef< AssetMetaData >() 
)

Stores asset as a new version using the identifier #aid. Identifier, version and repository are set correspondingly at #asset, so #asset may point to a copy of the original object afterwards (Asset is a copy-on-write reference).

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
[in]aidThe asset identifier to use.
[in,out]assetThe asset object to store. This method sets identifier, version and repository of #asset.
[in]metaDataInitial meta data to use for the asset.
Returns
The AssetDescription for the added asset.

◆ OverwriteAsset() [2/3]

MAXON_FUNCTION Result<AssetDescription> OverwriteAsset ( const Id aid,
ASSET &  asset,
const AssetMetaData &  metaData = GetZeroRef< AssetMetaData >() 
)

Stores asset as a new version using the identifier #aid. Identifier, version and repository are set correspondingly at #asset, so #asset may point to a copy of the original object afterwards (Asset is a copy-on-write reference).

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
[in]aidThe asset identifier to use.
[in,out]assetThe asset object to store. This method sets identifier, version and repository of #asset.
[in]metaDataInitial meta data to use for the asset.
Returns
The AssetDescription for the added asset.

◆ DeleteAsset()

MAXON_METHOD Result<AssetDescription> DeleteAsset ( const Id aid)

Deletes the asset given by the identifier #aid. The previous versions still exist in the repository, this method just stores a delete marker so that FindAssets doesn't take those versions into account unless the ASSET_FIND_MODE::WITH_DELETED flag is given. For a complete removal of a specific version use EraseAsset.

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
[in]aidThe asset to delete.
Returns
The AssetDescription which represents the delete marker.

◆ EraseAsset()

MAXON_METHOD Result<void> EraseAsset ( const AssetDescription &  asset)

Permanently erases an asset version. Unlike DeleteAsset which marks an asset as deleted but keeps all previous versions this method completely removes any data of the given asset version.

Observers of ObservableAssetErased of this repository and its derived repositories are informed.

Parameters
[in]assetThe asset version to erase from this repository.

◆ CopyAsset()

MAXON_METHOD Result<AssetDescription> CopyAsset ( const Id aid,
const AssetDescription &  source,
Bool  addEncryption = false,
Bool  overwrite = false 
)

Copies an asset including meta data to this repository using the identifier #aid for the copy. source has to be an asset already stored in some repository. The version identifier of source will be used for the copy even if this repository would normally derive a different identifier from the asset content.

Observers of ObservableAssetStored of this repository and its derived repositories are informed.

Parameters
[in]aidThe asset identifier to use.
[in]sourceThe source asset to copy.
[in]addEncryptionTrue if the copy shall be stored in an encrypted way. The encryption has to be handled by the AssetType.
[in]overwriteTrue to overwrite the existing asset.
Returns
The AssetDescription of the copy.

◆ StoreMetaData()

MAXON_METHOD Result<void> StoreMetaData ( const AssetDescription &  asset,
const InternedId metaId,
ForwardingDataPtr &&  data,
AssetMetaDataInterface::KIND  kind 
)

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

Parameters
[in]assetThe asset for which a meta data value shall be set.
[in]metaIdThe identifier of the meta data attribute.
[in]dataThe value to set.
[in]kindThe kind of the meta data.

◆ StoreUrlMetaData()

MAXON_METHOD Result<void> StoreUrlMetaData ( const AssetDescription &  asset,
const InternedId metaId,
const Url source,
AssetMetaDataInterface::KIND  kind 
)

Copies the file or directory source as meta data for the meta data attribute #metaId of the given #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]assetThe asset for which a meta data value shall be set.
[in]metaIdThe identifier of the meta data attribute.
[in]sourceThe source which shall be copied as meta data to #asset. Pass empty Url to remove the meta data.
[in]kindThe kind of the meta data.

◆ MAXON_OBSERVABLE() [1/6]

MAXON_OBSERVABLE ( void  ,
ObservableBaseChanged  ,
(const AssetRepositoryRef &base, Bool added)  ,
ObservableCombinerRunAllComponent   
)

Informs about the addition or removal of a base repository via AddBase and RemoveBase. The observers are called not only when this happens for this repository itself, but also when it happens for one of its base repositories.

Parameters
[in]baseThe base repository.
[in]addedTrue if base has been added, false if it has been removed.

◆ MAXON_OBSERVABLE() [2/6]

MAXON_OBSERVABLE ( void  ,
ObservableAssetStored  ,
(const AssetDescription &asset)  ,
ObservableCombinerRunAllComponent   
)

Informs about the storage of a new asset version. This includes StoreAsset and CopyAsset, but also the storage of a delete marker via DeleteAsset. The observers are called not only when this happens for this repository itself, but also when it happens for one of its base repositories.

Parameters
[in]assetThe description of the new asset version.

◆ MAXON_OBSERVABLE() [3/6]

MAXON_OBSERVABLE ( void  ,
ObservableAssetErased  ,
(const AssetDescription &asset)  ,
ObservableCombinerRunAllComponent   
)

Informs about the erasure of an asset version, see EraseAsset. The observers are called not only when this happens for this repository itself, but also when it happens for one of its base repositories.

Parameters
[in]assetThe description of the erased asset version.

◆ MAXON_OBSERVABLE() [4/6]

MAXON_OBSERVABLE ( void  ,
ObservableAssetUpdated  ,
(const Asset &asset)  ,
ObservableCombinerRunAllComponent   
)

Informs about the update of an asset. An update happens when the asset uses references to other assets and those references are updated to newer versions of the referenced assets. No new asset version is created. The observers are called not only when this happens for this repository itself, but also when it happens for one of its base repositories.

Parameters
[in]assetThe updated asset.

◆ MAXON_OBSERVABLE() [5/6]

MAXON_OBSERVABLE ( void  ,
ObservableMetaDataStored  ,
(const AssetDescription &asset, const InternedId &metaId, AssetMetaDataInterface::KIND kind, const Data &prevData, const Data &newData)  ,
ObservableCombinerRunAllComponent   
)

Informs about the storage of a meta data attribute value, see StoreMetaData. The observers are called not only when this happens for this repository itself, but also when it happens for one of its base repositories.

Parameters
[in]assetThe asset.
[in]metaIdThe identifier of the stored meta data attribute.
[in]kindThe meta data kind.
[in]prevDataThe previous value of the attribute (may be empty).
[in]newDataThe new value of the attribute.

◆ MAXON_OBSERVABLE() [6/6]

MAXON_OBSERVABLE ( void  ,
ObservableDownloadStateChanged  ,
(const AssetRepositoryRef &repository, Bool finished)  ,
ObservableCombinerRunAllComponent   
)

Informs about the download state change in the repository.

Parameters
[in]repositoryThe repository with the changes assets.

◆ GetCachedData() [1/2]

MAXON_METHOD Result<const GenericData&> GetCachedData ( MoveDataPtr &&  key,
const Delegate< Result< GenericData >()> &  callback 
)

◆ GetDescriptionDatabaseId()

MAXON_METHOD Result<Id> GetDescriptionDatabaseId ( ) const

◆ LoadDescription() [1/3]

MAXON_METHOD Result<DataDescription> LoadDescription ( const Id category,
const LanguageRef &  language,
const AssetDescription &  asset 
)

◆ LoadDescription() [2/3]

MAXON_METHOD Result<DataDescription> LoadDescription ( const Id category,
const LanguageRef &  language,
const IdAndVersion dataType 
)

◆ LoadDescription() [3/3]

MAXON_FUNCTION Result<DataDescription> LoadDescription ( const Id category,
const LanguageRef &  language,
const Id dataType 
)

◆ LoadDescriptionDefinition()

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

◆ GetRepositoryName()

MAXON_METHOD Result<String> GetRepositoryName ( const LanguageRef &  language,
Bool  addDetails 
) const

GetRepositoryName returns the name of the repository in the requested language.

Parameters
[in]languageLanguage to query.
Returns
Name on success.

◆ SetRepositoryName()

MAXON_METHOD Result<void> SetRepositoryName ( const String name,
const LanguageRef &  language 
)

SetRepositoryName sets the name of the repository in the given language.

Parameters
[in]nameName to set.
[in]languageLanguage.
Returns
OK on success.

◆ GetCachedData() [2/2]

MAXON_METHOD Result<const DerivedAssetRepositoryDataRef&> GetCachedData ( MoveDataPtr &&  key,
const Delegate< Result< DerivedAssetRepositoryDataRef >()> &  callback 
)

◆ HandleBaseChanged()

MAXON_METHOD void HandleBaseChanged ( const AssetRepositoryRef &  base,
Bool  added 
)
protected

Informs all observers of ObservableBaseChanged and calls HandleBaseChanged on all derived repositories.

Parameters
[in]baseThe base repository.
[in]addedTrue if base has been added, false if it has been removed.

◆ HandleAssetStored()

MAXON_METHOD void HandleAssetStored ( const AssetDescription &  asset)
protected

Informs all observers of ObservableAssetStored and calls HandleAssetStored on all derived repositories.

Parameters
[in]assetThe description of the new asset version.

◆ HandleAssetErased()

MAXON_METHOD void HandleAssetErased ( const AssetDescription &  asset)
protected

Informs all observers of ObservableAssetErased and calls HandleAssetErased on all derived repositories.

Parameters
[in]assetThe description of the erased asset version.

◆ HandleAssetUpdated()

MAXON_METHOD void HandleAssetUpdated ( const Asset asset)
protected

Informs all observers of ObservableAssetUpdated and calls HandleAssetUpdated on all derived repositories.

Parameters
[in]assetThe updated asset.

◆ HandleMetaDataStored()

MAXON_METHOD void HandleMetaDataStored ( const AssetDescription &  asset,
const InternedId metaId,
AssetMetaDataInterface::KIND  kind,
const Data prevData,
const Data newData 
)
protected

Informs all observers of ObservableMetaDataStored and calls HandleMetaDataStored on all derived repositories.

Parameters
[in]assetThe asset.
[in]metaIdThe identifier of the stored meta data attribute.
[in]kindThe meta data kind.
[in]prevDataThe previous value of the attribute (may be empty).
[in]newDataThe new value of the attribute.

◆ HandleDownloadStateChanged()

MAXON_METHOD void HandleDownloadStateChanged ( const AssetRepositoryRef &  repository,
Bool  finished 
)

Informs all observers of ObservableDownloadStateChanged and calls HandleDownloadStateChanged on all derived repositories.

Parameters
[in]repositoryThe repository.
[in]finishedTrue if finished

◆ RequestUnloadRepository()

MAXON_METHOD void RequestUnloadRepository ( )

RequestUnloadRepository is called if the user requested to reload or remove the repository. This function should stop all running background threads/jobs to free references to this repo.

◆ StoreAsset() [3/3]

Result<AssetDescription> StoreAsset ( const Id aid,
ASSET &  asset,
const AssetMetaData &  metaData 
)

◆ OverwriteAsset() [3/3]

Result<AssetDescription> OverwriteAsset ( const Id aid,
ASSET &  asset,
const AssetMetaData &  metaData 
)