Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::RPI::AssetCreator< AssetDataT > Class Template Reference

#include <AssetCreator.h>

Public Member Functions

void SetElevateWarnings (bool elevated)
 When true, treat all subsequent warnings as errors. Any warnings already reported will not be elevated.
 
bool GetElevateWarnings () const
 
int GetErrorCount () const
 
int GetWarningCount () const
 
bool IsFailed () const
 
template<typename ... Args>
void ReportError (const char *format, Args... args)
 
template<typename ... Args>
void ReportWarning (const char *format, Args... args)
 

Protected Member Functions

 AZ_DISABLE_COPY_MOVE (AssetCreator)
 
void BeginCommon (const Data::AssetId &assetId)
 
bool EndCommon (Data::Asset< AssetDataT > &result)
 
bool ValidateIsReady ()
 
bool ValidateNotNull (void *pointer, const char *name)
 Reports errors when a pointer is null.
 
bool ValidateNotNull (const AZ::Data::Asset< AZ::Data::AssetData > &pointer, const char *name)
 
template<typename T >
bool ValidateNotNull (const AZStd::intrusive_ptr< T > &pointer, const char *name)
 

Protected Attributes

Data::Asset< AssetDataT > m_asset
 This is the asset that subclass creators will build.
 

Detailed Description

template<typename AssetDataT>
class AZ::RPI::AssetCreator< AssetDataT >

Common base class for asset creators, which are used to create and initialize instances of an immutable asset class.

(Note this generally follows the builder design pattern, but is called a "creator" rather than a "builder" to avoid confusion with the AssetBuilderSDK).

Member Function Documentation

◆ BeginCommon()

template<typename AssetDataT >
void AZ::RPI::AssetCreator< AssetDataT >::BeginCommon ( const Data::AssetId &  assetId)
protected

Utility function that creates the m_asset instance that this asset creator will build. Subclasses should call this at the beginning of their Begin() function.

◆ EndCommon()

template<typename AssetDataT >
bool AZ::RPI::AssetCreator< AssetDataT >::EndCommon ( Data::Asset< AssetDataT > &  result)
protected

Utility function that finalizes and transfers ownership of m_asset to result, if successful. Otherwise returns false and result is left untouched. Subclasses should call this at the end of their End() function, after making any final changes to m_asset.

◆ ReportError()

template<typename AssetDataT >
template<typename ... Args>
void AZ::RPI::AssetCreator< AssetDataT >::ReportError ( const char *  format,
Args...  args 
)

Errors should be reported for any condition that prevents creating a valid asset that can be used at runtime. The output asset data would be corrupt to the point that the runtime would report further errors or even crash. Once an error has been reported, subsequent calls to ValidateIsReady() will return false. (Normally this will be called by subclasses, but it is public so client code may also report errors in the same way; for example, when client code is unable to prepare inputs for the AssetCreator).

◆ ReportWarning()

template<typename AssetDataT >
template<typename ... Args>
void AZ::RPI::AssetCreator< AssetDataT >::ReportWarning ( const char *  format,
Args...  args 
)

Warnings should be reported for any condition that indicates a rendered asset may not appear as the user expects. However, the runtime will not crash or report errors if the output asset is used. (Normally this will be called by subclasses, but it is public so client code may also report warnings in the same way; for example, when client code is unable to prepare inputs for the AssetCreator).

◆ ValidateIsReady()

template<typename AssetDataT >
bool AZ::RPI::AssetCreator< AssetDataT >::ValidateIsReady
protected

Reports common errors, and returns false if processing should not continue due to prior errors.

Subclasses should call this function before attempting any manipulation of the m_asset, and return immediately if it returns false. This alleviates subclasses from having to track custom state; they just need to call ReportError() for any breaking issue.

Returns
false if any errors have been previously reported. Note, it does not return false due to previously reported warnings, because warnings should not invalidate subsequent manipulations of the m_asset.

The documentation for this class was generated from the following file: