XII Release 0.1.0
Loading...
Searching...
No Matches
xiiGALMapHelper< DataType > Class Template Reference

Helper class that automates resource mapping and unmapping. More...

#include <MapHelper.h>

Inheritance diagram for xiiGALMapHelper< DataType >:
[legend]

Public Member Functions

 xiiGALMapHelper ()
 Default constructor.
 
 xiiGALMapHelper (xiiSharedPtr< xiiGALCommandList > pCommandList, xiiSharedPtr< xiiGALBuffer > pBuffer, xiiEnum< xiiGALMapType > mapType, xiiBitflags< xiiGALMapFlags > mapFlags)
 Constructs the helper and maps the specified resource.
 
 xiiGALMapHelper (xiiGALMapHelper &&other) noexcept
 Move constructor.
 
 ~xiiGALMapHelper ()
 Destructor, automatically unmaps the resource.
 
xiiGALMapHelper< DataType > & operator= (xiiGALMapHelper &&other) noexcept
 Move assignment operator.
 
xiiResult Map (xiiSharedPtr< xiiGALCommandList > pCommandList, xiiSharedPtr< xiiGALBuffer > pBuffer, xiiEnum< xiiGALMapType > mapType, xiiBitflags< xiiGALMapFlags > mapFlags)
 Maps the specified resource.
 
xiiResult Unmap ()
 Unmaps the specified resource.
 
 operator DataType * ()
 Implicit conversion to DataType pointer.
 
 operator const DataType * () const
 Implicit conversion to const DataType pointer.
 
DataType * operator-> ()
 Provides direct access to the mapped data.
 
const DataType * operator-> () const
 Provides direct access to the mapped data (const version).
 
XII_ALWAYS_INLINE DataType * GetMappedData () const
 Returns a pointer to the mapped buffer data.
 
- Public Member Functions inherited from xiiReflectedClass
virtual const xiiRTTIGetDynamicRTTI () const
 
bool IsInstanceOf (const xiiRTTI *pType) const
 Returns whether the type of this instance is of the given type or derived from it.
 
template<typename T>
XII_ALWAYS_INLINE bool IsInstanceOf () const
 Returns whether the type of this instance is of the given type or derived from it.
 

Additional Inherited Members

- Static Public Member Functions inherited from xiiNoBase
static const xiiRTTIGetStaticRTTI ()
 

Detailed Description

template<typename DataType>
class xiiGALMapHelper< DataType >

Helper class that automates resource mapping and unmapping.

This class simplifies the process of mapping and unmapping resources within a command list. It automatically maps the specified resource upon construction and unmaps it upon destruction.

Template Parameters
DataTypeThe type of data that will be mapped.
Note
This class is designed to streamline manual mapping/unmapping operations.

Usage example:

{
mapHelper->m_uiVar = 1.0f; // Access mapped data
}
xiiGALMapHelper()
Default constructor.
Definition MapHelper_inl.h:3
@ Discard
Definition GraphicsTypes.h:389
@ Read
The resource is mapped for reading.
Definition GraphicsTypes.h:366

Constructor & Destructor Documentation

◆ xiiGALMapHelper() [1/2]

template<typename DataType>
XII_ALWAYS_INLINE xiiGALMapHelper< DataType >::xiiGALMapHelper ( xiiSharedPtr< xiiGALCommandList > pCommandList,
xiiSharedPtr< xiiGALBuffer > pBuffer,
xiiEnum< xiiGALMapType > mapType,
xiiBitflags< xiiGALMapFlags > mapFlags )

Constructs the helper and maps the specified resource.

Parameters
pCommandList- Pointer to the command list.
hBuffer- Handle to the buffer resource.
mapType- Type of mapping operation.
mapFlags- Mapping flags.

◆ xiiGALMapHelper() [2/2]

template<typename DataType>
XII_ALWAYS_INLINE xiiGALMapHelper< DataType >::xiiGALMapHelper ( xiiGALMapHelper< DataType > && other)
noexcept

Move constructor.

Parameters
other- The other helper object to move from.

Member Function Documentation

◆ GetMappedData()

template<typename DataType>
XII_ALWAYS_INLINE DataType * xiiGALMapHelper< DataType >::GetMappedData ( ) const

Returns a pointer to the mapped buffer data.

This function provides direct access to the memory where the buffer is mapped. It is typically used for reading from or writing to GPU buffer memory directly, assuming the buffer has been properly mapped beforehand.

Returns
A raw pointer to the mapped data buffer.

◆ Map()

template<typename DataType>
XII_FORCE_INLINE xiiResult xiiGALMapHelper< DataType >::Map ( xiiSharedPtr< xiiGALCommandList > pCommandList,
xiiSharedPtr< xiiGALBuffer > pBuffer,
xiiEnum< xiiGALMapType > mapType,
xiiBitflags< xiiGALMapFlags > mapFlags )

Maps the specified resource.

Parameters
pCommandList- Pointer to the command list.
hBuffer- Handle to the buffer resource.
mapType- Type of mapping operation.
mapFlags- Mapping flags.
Returns
Result of the operation.

◆ operator->() [1/2]

template<typename DataType>
XII_ALWAYS_INLINE DataType * xiiGALMapHelper< DataType >::operator-> ( )

Provides direct access to the mapped data.

Returns
Pointer to the mapped data.

◆ operator->() [2/2]

template<typename DataType>
XII_ALWAYS_INLINE const DataType * xiiGALMapHelper< DataType >::operator-> ( ) const

Provides direct access to the mapped data (const version).

Returns
Pointer to the mapped data.

◆ operator=()

template<typename DataType>
XII_ALWAYS_INLINE xiiGALMapHelper< DataType > & xiiGALMapHelper< DataType >::operator= ( xiiGALMapHelper< DataType > && other)
noexcept

Move assignment operator.

Parameters
other- The other helper object to move from.
Returns
Reference to this object.

◆ Unmap()

template<typename DataType>
XII_FORCE_INLINE xiiResult xiiGALMapHelper< DataType >::Unmap ( )

Unmaps the specified resource.

Returns
Result of the operation.

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