## Public API Reference

- Main Page
- Modules
- Namespaces
- Classes
- Files
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# csRenderBufferLock< T, TbufferKeeper > Class Template Reference

Helper class for convenient locking/unlocking of an iRenderBuffer. More...

`#include <cstool/rbuflock.h>`

List of all members.

## Public Member Functions

| csRenderBufferLock (iRenderBuffer *buf, csRenderBufferLockType lock=CS_BUF_LOCK_NORMAL)
| Construct the helper.
T & | Get (size_t n)
| Retrieve an item in the render buffer.
size_t | GetSize () const
| Retrieve number of items in buffer.
bool | IsValid () const
| Returns whether the buffer is valid (ie not null).
T * | Lock ()
| Lock the renderbuffer.
T & | operator * ()
| Get current element.
| operator T * ()
| Retrieve a pointer to the contained data.
void | operator++ ()
| Set current element to the next.
T & | operator[] (size_t n)
| Retrieve an item in the render buffer.
void | Unlock ()
| Unlock the renderbuffer.
| ~csRenderBufferLock ()
| Destruct the helper.

## Detailed Description

### template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
class csRenderBufferLock< T, TbufferKeeper >

Helper class for convenient locking/unlocking of an iRenderBuffer.

The contents can be accessed either directly, array-style or iterator-style in a typed way.

Remarks:
  The TbufferKeeper template argument can be used to have the lock store the buffer in a simple iRenderBuffer* (instead a csRef<>) to avoid an IncRef() and DecRef() if it is known that the buffer will not be destroyed as long as the lock exists.

Definition at line 40 of file rbuflock.h.

## Constructor & Destructor Documentation

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
csRenderBufferLock< T, TbufferKeeper >::csRenderBufferLock | ( | iRenderBuffer * | buf,
|  | csRenderBufferLockType | lock = `CS_BUF_LOCK_NORMAL`
| ) | `[inline]`

| Construct the helper. Definition at line 71 of file rbuflock.h. References iRenderBuffer::GetElementCount().

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
csRenderBufferLock< T, TbufferKeeper >::~csRenderBufferLock | ( |  | ) | `[inline]`

| Destruct the helper. Automatically unlocks the buffer if it was locked. Definition at line 85 of file rbuflock.h. References csRenderBufferLock< T, TbufferKeeper >::Unlock().

## Member Function Documentation

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
T& csRenderBufferLock< T, TbufferKeeper >::Get | ( | size_t | n | ) | `[inline]`

| Retrieve an item in the render buffer. Definition at line 145 of file rbuflock.h. References CS_ASSERT, and csRenderBufferLock< T, TbufferKeeper >::Lock(). Referenced by csRenderBufferLock< T, TbufferKeeper >::operator *(), and csRenderBufferLock< T, TbufferKeeper >::operator[]().

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
size_t csRenderBufferLock< T, TbufferKeeper >::GetSize | ( |  | ) | const`[inline]`

| Retrieve number of items in buffer. Definition at line 152 of file rbuflock.h.

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
bool csRenderBufferLock< T, TbufferKeeper >::IsValid | ( |  | ) | const`[inline]`

| Returns whether the buffer is valid (ie not null). Definition at line 158 of file rbuflock.h.

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
T* csRenderBufferLock< T, TbufferKeeper >::Lock | ( |  | ) | `[inline]`

Lock the renderbuffer.

Returns a pointer to the contained data.

Remarks:
  Watch the stride of the buffer.

Definition at line 94 of file rbuflock.h.

References CS_ASSERT.

Referenced by csRenderBufferLock< T, TbufferKeeper >::Get(), and csRenderBufferLock< T, TbufferKeeper >::operator T *().

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
T& csRenderBufferLock< T, TbufferKeeper >::operator * | ( |  | ) | `[inline]`

| Get current element. Definition at line 126 of file rbuflock.h. References csRenderBufferLock< T, TbufferKeeper >::Get().

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
csRenderBufferLock< T, TbufferKeeper >::operator T * | ( |  | ) | `[inline]`

Retrieve a pointer to the contained data.

Remarks:
  Watch the stride of the buffer.

Definition at line 120 of file rbuflock.h.

References csRenderBufferLock< T, TbufferKeeper >::Lock().

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
void csRenderBufferLock< T, TbufferKeeper >::operator++ | ( |  | ) | `[inline]`

| Set current element to the next. Definition at line 132 of file rbuflock.h. References CS_ASSERT.

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
T& csRenderBufferLock< T, TbufferKeeper >::operator[] | ( | size_t | n | ) | `[inline]`

| Retrieve an item in the render buffer. Definition at line 139 of file rbuflock.h. References csRenderBufferLock< T, TbufferKeeper >::Get().

template<class T, class TbufferKeeper = csRef<iRenderBuffer>>
void csRenderBufferLock< T, TbufferKeeper >::Unlock | ( |  | ) | `[inline]`

| Unlock the renderbuffer. Definition at line 107 of file rbuflock.h. Referenced by csRenderBufferLock< T, TbufferKeeper >::~csRenderBufferLock().

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

- cstool/rbuflock.h