Diligent Engine
 
Loading...
Searching...
No Matches
Diligent::MapHelper< DataType, KeepStrongReferences > Class Template Reference

Facilitates resource mapping. More...

#include <MapHelper.hpp>

Public Member Functions

 MapHelper ()
 Initializes the class member with null values.
 
 MapHelper (IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags)
 
 MapHelper (MapHelper &&Helper)
 Move constructor: takes over resource ownership from Helper.
 
MapHelperoperator= (MapHelper &&Helper)
 Move-assignment operator: takes over resource ownership from Helper.
 
void Map (IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, MAP_FLAGS MapFlags)
 Maps the provided resource.
 
void Unmap ()
 Unmaps the resource and resets the object state to default.
 
 operator DataType * ()
 Converts mapped data pointer to DataType*.
 
 operator const DataType * () const
 Converts mapped data pointer to const DataType*.
 
DataType * operator-> ()
 Operator ->
 
const DataType * operator-> () const
 Operator const ->
 
 ~MapHelper ()
 Unmaps the resource.
 

Detailed Description

template<typename DataType, bool KeepStrongReferences = false>
class Diligent::MapHelper< DataType, KeepStrongReferences >

Facilitates resource mapping.

Template Parameters
DataType- type of the mapped data.

This class is designed to automate resource mapping/unmapping process. The class automatically unmaps the resource when the class instance gets out of scope.
Usage example:

{
    MapHelper<float> UniformData{pDeviceContext, pUniformBuff, MAP_WRITE, MAP_FLAG_DISCARD};
    UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1;
} 

Constructor & Destructor Documentation

◆ MapHelper()

template<typename DataType, bool KeepStrongReferences = false>
Diligent::MapHelper< DataType, KeepStrongReferences >::MapHelper ( IDeviceContext * pContext,
IBuffer * pBuffer,
MAP_TYPE MapType,
MAP_FLAGS MapFlags )
inline

Initializes the object and maps the provided resource. See Map() for details.

Member Function Documentation

◆ Map()

template<typename DataType, bool KeepStrongReferences = false>
void Diligent::MapHelper< DataType, KeepStrongReferences >::Map ( IDeviceContext * pContext,
IBuffer * pBuffer,
MAP_TYPE MapType,
MAP_FLAGS MapFlags )
inline

Maps the provided resource.

Parameters
pContext- Pointer to the device context to perform mapping with.
pBuffer- Pointer to the buffer interface to map.
MapType- Type of the map operation, see Diligent::MAP_TYPE for details.
MapFlags- Additional map flags, see Diligent::MAP_FLAGS.