#include <assets.h>
An Asset represents digital content which can be managed by an asset repository. The management includes versioning, meta data and automatic updates.
Public Member Functions | |
MAXON_METHOD void | SetId (const IdAndVersion &aid, Int update, const AssetRepositoryRef &repository, const Url &url=GetPtrSizedZeroRef< Url >()) |
MAXON_METHOD const AssetType & | GetType () const |
MAXON_METHOD Result< AssetDescription > | GetDescription () const |
MAXON_METHOD Result< Bool > | GetReferencedAssets (Bool onlyUpdatable, const ValueReceiver< const AssetReference & > &receiver) const |
MAXON_METHOD Result< Bool > | GetPendingUpdates (const Block< const AssetBase > &updatedAssets, const ValueReceiver< const AssetReference &, const AssetBase & > &receiver) const |
MAXON_METHOD void | SetMetaData (const AssetMetaData &data) |
MAXON_METHOD AssetMetaData | GetMetaData () const |
Static Public Member Functions | |
static MAXON_METHOD const AssetRepositoryRef & | GetBuiltinRepository () |
static MAXON_METHOD const AssetRepositoryRef & | GetApplicationRepository () |
static MAXON_METHOD const UpdatableAssetRepositoryRef & | GetUserPrefsRepository () |
static MAXON_METHOD Result< UpdatableAssetRepositoryRef > | CreateRepositoryFromUrl (const Id &rid, const Class< AssetRepositoryRef > &repoType, const Block< const AssetRepositoryRef > &bases, const Url &url, Bool writable, Bool derivedInPrefs, Bool tempRepository, const BackgroundEntryTuple &backgroundJob={}) |
static MAXON_METHOD Result< Id > | MakeUuid (const Char *prefix, Bool compact) |
static MAXON_METHOD Result< Url > | AddRepositoryScope (const Url &url, const AssetRepositoryRef &repository) |
static MAXON_METHOD Result< InternedId > | GetLanguageMetaDataId (const Id &languageId) |
static MAXON_METHOD Result< String > | GetVersionString (const AssetDescription &asset) |
static MAXON_METHOD Result< String > | GetVersionString (const Asset &asset) |
static MAXON_METHOD Result< AssetDescription > | ResolveAsset (const Url &url, const AssetRepositoryRef &repository) |
static MAXON_METHOD Result< Url > | GetAssetUrl (const AssetDescription &asset, Bool isLatest) |
static MAXON_METHOD Result< Bool > | IsAssetValid (const AssetDescription &asset) |
static MAXON_METHOD Result< Bool > | IsAssetVisible (const AssetDescription &asset) |
static MAXON_METHOD Result< AssetVersionValidityData > | IsAssetVersionValid (const AssetDescription &asset) |
static MAXON_METHOD Result< AssetLicenseValidityData > | IsAssetLicenseValid (const AssetDescription &asset) |
static MAXON_METHOD Result< void > | ResolveAssetsWithMissingAssets (const AssetRepositoryRef &searchRepository, const Id &typeId, const IdAndVersion &idVersion, const UniversalDateTime &assetCreationDate, HashSet< IdAndVersion > &checked, const Delegate< Result< void >(const AssetDescription &, HashSet< IdAndVersion > &checked)> &callbackFound, const Delegate< Result< void >(Bool outdated)> &callbackMissing) |
Private Member Functions | |
MAXON_INTERFACE (AssetInterface, MAXON_REFERENCE_COPY_ON_WRITE, "net.maxon.interface.asset") | |
|
private |
|
static |
Returns the built-in repository. This contains the built-in assets which are defined by program code (i.e., not by a data format to read them from a data stream).
|
static |
Returns the application repository. The application repository uses the built-in repository as base and adds the assets found in the resources of the asset.module.
|
static |
Returns the asset repository in the user preferences folder. This repository is writable for the user.
|
static |
Creates an asset repository for the given Url. If there already is a directory structure in the expected format it is read as far as needed to initialize the repository with the found assets, otherwise such a directory structure is created.
[in] | rid | The repository identifier. There mustn't be a base with the same identifier. |
[in] | repoType | See AssetRepositoryTypes registry. |
[in] | bases | The base repositories for the new repository. |
[in] | url | The root directory to use for the repository. |
[in] | writable | True if the repository shall be writable. |
[in] | derivedInPrefs | True if derived meta data shall be stored in the user preferences folder. This is mandatory if #url is a read-only Url. |
[in] | tempRepository | True if the repository should not be registered as a description database. |
[in] | backgroundJob | Optional background job to report errors, warnings, progress, cancellation. |
|
static |
Creates a UUID (universally unique identifier). If prefix is given, the returned identifier starts with prefix, followed by an @ sign, followed by the UUID such as {base@5e75b5e319f64055ac5387490d7355c0}, otherwise it is a UUID only. If prefix already contains an @ sign, only the part before that sign is used.
If compact is true, a Base64-encoding with $ and _ as last characters is used for the UUID instead of the default Hex encoding, and it's ensured that the resulting characters of the encoding don't start with a digit. This results in shorter UUIDs like {FR4pAc$UFR_jXb16rXadEB}. In compact mode and when there are dot characters in prefix, only the part of prefix after the last dot is used.
[in] | prefix | The prefix for the identifier, may be nullptr. Only the characters up to the first @ sign are used. |
[in] | compact | True if the shorter Base64-encoding shall be used, false for Hex encoding. |
|
static |
AddRepositoryScope resolves the asset url and caching the assetdescription in the url.
[in] | url | Url to investigate. |
[in] | repository | Repository to search. |
|
static |
GetLanguageMetaDataId returns the standardized InternedId for the given languageid.
[in] | languageId | Language id. |
|
static |
GetVersionString returns the version string for the given asset.
[in] | asset | Asset to look at. |
|
static |
GetVersionString returns the version string for the given asset.
[in] | asset | Asset to look at. |
MAXON_METHOD void SetId | ( | const IdAndVersion & | aid, |
Int | update, | ||
const AssetRepositoryRef & | repository, | ||
const Url & | url = GetPtrSizedZeroRef< Url >() |
||
) |
Sets identifier, version and repository of this asset. This method should only be called by the owning asset repository when it stores an asset to establish the link between asset and repository.
[in] | aid | Identifier and version identifier of the asset. |
[in] | update | Update counter, see AssetBaseWithUpdateInterface::GetUpdate. |
[in] | repository | The repository which stored the asset. |
[in] | url | An optional Url where the repository stored the asset. @MAXON_ANNOTATION{returnsThis} |
MAXON_METHOD const AssetType& GetType | ( | ) | const |
Returns the AssetType of this asset.
MAXON_METHOD Result<AssetDescription> GetDescription | ( | ) | const |
GetDescription returns the AssetDescription of the given Asset.
MAXON_METHOD Result<Bool> GetReferencedAssets | ( | Bool | onlyUpdatable, |
const ValueReceiver< const AssetReference & > & | receiver | ||
) | const |
Yields all direct references which this asset makes to other assets. The AssetReference objects are used later for the update mechanism: The method UpdatableAssetInterface::Update gets a block of tuples (AssetReference, AssetBase) as input, and each tuple indicates to which asset an AssetReference shall be updated. So for example if an asset has two links to the same asset this has to be reported as two AssetReference objects, and when only the first one is passed to UpdatableAssetInterface::Update only the first link has to be updated, while the second has to remain unchanged.
[in] | onlyUpdatable | If true only references which use updatable links shall be reported (update policy different from ASSET_UPDATE_POLICY::NEVER), otherwise all references. |
[in] | receiver | Receiver to which references are reported. |
MAXON_METHOD Result<Bool> GetPendingUpdates | ( | const Block< const AssetBase > & | updatedAssets, |
const ValueReceiver< const AssetReference &, const AssetBase & > & | receiver | ||
) | const |
Yields all possible AssetReference updates for this asset due to #updatedAssets to #receiver. This method finds all direct references which this asset makes to other assets, and checks if they are affected by the list of #updatedAssets. This check takes into account the update policy of the AssetLink used for the reference. Whenever there is an updatable AssetLink and #updatedAssets contains a newer version for that link, this is reported by a call to #receiver with the reference as first argument and the newer asset from #updatedAssets as second argument.
[in] | updatedAssets | A block of assets with (potentially) newer versions. |
[in] | receiver | Receiver to which all pending updates due to #updatedAssets are reported. |
MAXON_METHOD void SetMetaData | ( | const AssetMetaData & | data | ) |
Sets the meta data object to use for this asset. This method should only be called by the owning asset repository.
[in] | data | The meta data of the asset. |
MAXON_METHOD AssetMetaData GetMetaData | ( | ) | const |
Returns the meta data of this asset.
|
static |
Returns the asset description from a given url with the URLSCHEME_ASSET.
[in] | url | Url to search. |
[in] | repository | Lookup repository. |
|
static |
Returns the url to access the asset data. e.g. asset:///file_634545662344
[in] | asset | asset to convert. |
[in] | isLatest | True if the asset is the latest asset. In that case the version will not be added to the url. |
|
static |
Checks if the asset is valid for the current license and program version.
[in] | asset | Asset to check |
|
static |
Checks if the asset is visible for the current license and program version.
[in] | asset | Asset to check |
|
static |
Checks if the asset is valid for the current program version.
[in] | asset | Asset to check |
|
static |
Checks if the asset is valid for the current license.
[in] | asset | Asset to check |
|
static |
Checks if the asset idVersion can be found in the given searchRepository to resolve missing assets
[in] | searchRepository | Repository to search for the asset |
[in] | typeId | Type of the asset |
[in] | idVersion | Id and version of the asset |
[in] | assetCreationDate | [optional] Argument with the creation date of the asset. Pass UniversalDateTime() when unknown. |
[in] | checked | HashSet to prevent stackoverflow. |
[in] | callbackFound | [optional] Callback that is called if the asset could be found. It might happen that the passed asset is the renamed/updated version of the searched one. |
[in] | callbackMissing | [optional] Callback that is called if the asset could not be found. |