HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ArAsset Class Referenceabstract

#include <asset.h>

+ Inheritance diagram for ArAsset:

Public Member Functions

virtual AR_API ~ArAsset ()
 
 ArAsset (const ArAsset &)=delete
 
ArAssetoperator= (const ArAsset &)=delete
 
virtual AR_API size_t GetSize () const =0
 Returns size of the asset. More...
 
virtual AR_API std::shared_ptr
< const char > 
GetBuffer () const =0
 
virtual AR_API size_t Read (void *buffer, size_t count, size_t offset) const =0
 
virtual AR_API std::pair< FILE
*, size_t > 
GetFileUnsafe () const =0
 
virtual AR_API std::shared_ptr
< ArAsset
GetDetachedAsset () const
 

Protected Member Functions

AR_API ArAsset ()
 

Detailed Description

Interface for accessing the contents of an asset.

See Also
ArResolver::OpenAsset for how to retrieve instances of this object.

Definition at line 44 of file asset.h.

Constructor & Destructor Documentation

virtual AR_API ArAsset::~ArAsset ( )
virtual
ArAsset::ArAsset ( const ArAsset )
delete
AR_API ArAsset::ArAsset ( )
protected

Member Function Documentation

virtual AR_API std::shared_ptr<const char> ArAsset::GetBuffer ( ) const
pure virtual

Returns a pointer to a buffer with the contents of the asset, with size given by GetSize(). Returns an invalid std::shared_ptr if the contents could not be retrieved.

The data in the returned buffer must remain valid while there are outstanding copies of the returned std::shared_ptr. Note that the deleter stored in the std::shared_ptr may contain additional data needed to maintain the buffer's validity.

Implemented in ArInMemoryAsset, and ArFilesystemAsset.

virtual AR_API std::shared_ptr<ArAsset> ArAsset::GetDetachedAsset ( ) const
virtual

Returns an ArAsset with the contents of this asset detached from from this asset's serialized data. External changes to the serialized data must not have any effect on the ArAsset returned by this function.

The default implementation returns a new instance of an ArInMemoryAsset that reads the entire contents of this asset into a heap-allocated buffer.

Reimplemented in ArInMemoryAsset.

virtual AR_API std::pair<FILE*, size_t> ArAsset::GetFileUnsafe ( ) const
pure virtual

Returns a read-only FILE* handle and offset for this asset if available, or (nullptr, 0) otherwise.

The returned handle must remain valid for the lifetime of this ArAsset object. The returned offset is the offset from the beginning of the FILE* where the asset's contents begins.

This function is marked unsafe because the handle may wind up being used in multiple threads depending on the underlying resolver implementation. For instance, a resolver may cache and return ArAsset objects with the same FILE* to multiple threads.

Clients MUST NOT use this handle with functions that cannot be called concurrently on the same file descriptor, e.g. read, fread, fseek, etc. See ArchPRead for a function that can be used to read data from this handle safely.

Implemented in ArFilesystemAsset, and ArInMemoryAsset.

virtual AR_API size_t ArAsset::GetSize ( ) const
pure virtual

Returns size of the asset.

Implemented in ArInMemoryAsset, and ArFilesystemAsset.

ArAsset& ArAsset::operator= ( const ArAsset )
delete
virtual AR_API size_t ArAsset::Read ( void buffer,
size_t  count,
size_t  offset 
) const
pure virtual

Read count bytes at offset from the beginning of the asset into buffer. Returns number of bytes read, or 0 on error.

Implementers should range-check calls and return zero for out-of-bounds reads.

Implemented in ArInMemoryAsset, and ArFilesystemAsset.


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