You.i Engine
CYIAssetDecoder Class Referenceabstract

Detailed Description

Base class for all specialized decoders.

Programmers must extend this class for any specific asset file formats. All decoders must be registered through the CYIAssetLoader interface, if they want to be used by the You.i Engine framework.

#include <asset/YiAssetDecoder.h>

Inheritance diagram for CYIAssetDecoder:

Public Member Functions

 CYIAssetDecoder (const CYIRuntimeTypeInfo &assetType)
 
virtual ~CYIAssetDecoder ()
 
virtual bool IsExtensionSupported (const CYIString &extension)
 
virtual bool IsFormatSupported (const uint8_t *pData, uint32_t nDataSize)=0
 
virtual bool SupportsParams (const CYIAssetLoadParams *pDecodeParams)
 
virtual bool SupportsType (const CYIRuntimeTypeInfo &assetType)
 
virtual std::shared_ptr< CYIAssetDecodeAsset (const CYIString &path, const CYIAssetLoadParams *pDecodeParams=nullptr)=0
 
virtual std::shared_ptr< CYIAssetDecodeAsset (const uint8_t *pData, uint32_t nDataSize, const CYIAssetLoadParams *pDecodeParams=nullptr)=0
 
virtual bool DecodeAsset (const std::shared_ptr< CYIAsset > &pAsset)=0
 
virtual bool DecodeAsset (const std::shared_ptr< CYIAsset > &pAsset, const uint8_t *pData, uint32_t uDataSize)=0
 
CYIString GetExtension () const
 
const std::vector< CYIString > & GetExtensions () const
 

Protected Attributes

std::vector< CYIStringm_SupportedExtensions
 
const CYIRuntimeTypeInfom_AssetType
 

Constructor & Destructor Documentation

CYIAssetDecoder::CYIAssetDecoder ( const CYIRuntimeTypeInfo assetType)
virtual CYIAssetDecoder::~CYIAssetDecoder ( )
virtual

Member Function Documentation

virtual std::shared_ptr<CYIAsset> CYIAssetDecoder::DecodeAsset ( const CYIString path,
const CYIAssetLoadParams pDecodeParams = nullptr 
)
pure virtual

Decode an asset at the specified path using the optional decoding parameters pDecodeParams. The pDecodeParams can be nullptr.

Implemented in CYIAssetDecoderJSON, CYIAssetDecoderScript, CYIAssetDecoderTemplate, CYIAssetDecoderTimelineSource, CYIAssetDecoderTranslation, CYIAssetDecoderImage, CYIAssetDecoderBif, CYIAssetDecoderVideo, CYIAssetDecoderShaderObject, and CYIAssetDecoderWAV.

virtual std::shared_ptr<CYIAsset> CYIAssetDecoder::DecodeAsset ( const uint8_t *  pData,
uint32_t  nDataSize,
const CYIAssetLoadParams pDecodeParams = nullptr 
)
pure virtual

Decode an asset using pre-loaded file data pData, nDataSize, and the optional decoding parameters pDecodeParams. The pDecodeParams can be nullptr.

Implemented in CYIAssetDecoderJSON, CYIAssetDecoderScript, CYIAssetDecoderTemplate, CYIAssetDecoderTimelineSource, CYIAssetDecoderTranslation, CYIAssetDecoderImage, CYIAssetDecoderBif, CYIAssetDecoderShaderObject, CYIAssetDecoderVideo, and CYIAssetDecoderWAV.

virtual bool CYIAssetDecoder::DecodeAsset ( const std::shared_ptr< CYIAsset > &  pAsset)
pure virtual

Decode an asset using an existing asset instance. The path must be set through CYIAsset::SetPath, and the optional decoding parameters may be set through CYIAsset::SetLoadParameters. Returns true if the decoding was successful, false otherwise.

See also
CYIAsset::SetPath(const CYIString &path)
CYIAsset::SetLoadParameters(CYIAssetLoadParams *pParams)

Implemented in CYIAssetDecoderJSON, CYIAssetDecoderScript, CYIAssetDecoderTemplate, CYIAssetDecoderTimelineSource, CYIAssetDecoderTranslation, CYIAssetDecoderImage, CYIAssetDecoderBif, CYIAssetDecoderShaderObject, CYIAssetDecoderVideo, and CYIAssetDecoderWAV.

virtual bool CYIAssetDecoder::DecodeAsset ( const std::shared_ptr< CYIAsset > &  pAsset,
const uint8_t *  pData,
uint32_t  uDataSize 
)
pure virtual

Decode an asset using an existing asset instance, and pre-loaded file data pData and uDataSize. The optional decoding parameters may be set through CYIAsset::SetLoadParameters. Returns true if the decoding was successful, false otherwise.

See also
CYIAsset::SetLoadParameters(CYIAssetLoadParams *pParams)

Implemented in CYIAssetDecoderTemplate, CYIAssetDecoderTimelineSource, CYIAssetDecoderJSON, CYIAssetDecoderScript, CYIAssetDecoderImage, CYIAssetDecoderTranslation, CYIAssetDecoderBif, CYIAssetDecoderShaderObject, CYIAssetDecoderWAV, and CYIAssetDecoderVideo.

CYIString CYIAssetDecoder::GetExtension ( ) const

Return the first extension supported by the decoder, or an empty string if no extension is available.

const std::vector<CYIString>& CYIAssetDecoder::GetExtensions ( ) const

Returns all extensions supported by the decoder.

virtual bool CYIAssetDecoder::IsExtensionSupported ( const CYIString extension)
virtual

Returns true if the supplied extension is supported by this decoder. For consistency, supported extensions should be supplied by the decoder in lower case and no leading '.' characters. File names with multiple extensions should be specificed like "a.b".

virtual bool CYIAssetDecoder::IsFormatSupported ( const uint8_t *  pData,
uint32_t  nDataSize 
)
pure virtual

Returns true if the file format is supported. The file contents are supplied through pData and the size of the buffer must be given through nDataSize.

Implemented in CYIAssetDecoderTemplate, CYIAssetDecoderTimelineSource, CYIAssetDecoderBif, CYIAssetDecoderJSON, CYIAssetDecoderScript, CYIAssetDecoderShaderObject, CYIAssetDecoderVideo, CYIAssetDecoderWAV, CYIAssetDecoderTranslation, and CYIAssetDecoderImage.

virtual bool CYIAssetDecoder::SupportsParams ( const CYIAssetLoadParams pDecodeParams)
virtual
virtual bool CYIAssetDecoder::SupportsType ( const CYIRuntimeTypeInfo assetType)
virtual

Returns true if the decoder supports a specialized asset type.

Member Data Documentation

const CYIRuntimeTypeInfo& CYIAssetDecoder::m_AssetType
protected
std::vector<CYIString> CYIAssetDecoder::m_SupportedExtensions
protected

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