Diligent Engine API Reference
Public Member Functions | List of all members
Diligent::MapHelper< DataType, KeepStrongReferences > Class Template Reference

Facilitates resource mapping. More...

Public Member Functions

 MapHelper ()
 Initializes the class member with null values.
 
 MapHelper (IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, Uint32 MapFlags)
 Initializes the object and maps the provided resource. See Map() for details.
 
 MapHelper (MapHelper &&Helper)
 Move constructor: takes over resource ownership from Helper.
 
MapHelperoperator= (MapHelper &&Helper)
 Move-assignement operator: takes over resource ownership from Helper.
 
void Map (IDeviceContext *pContext, IBuffer *pBuffer, MAP_TYPE MapType, Uint32 MapFlags)
 Maps the provided resource. More...
 
void Unmap ()
 Unamps 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 ()
 Unamps 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_DISCARD, 0 );
    UniformData[0] = UniformData[1] = UniformData[2] = UniformData[3] = 1;
} 

Member Function Documentation

template<typename DataType , bool KeepStrongReferences = false>
void Diligent::MapHelper< DataType, KeepStrongReferences >::Map ( IDeviceContext pContext,
IBuffer pBuffer,
MAP_TYPE  MapType,
Uint32  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.