Visualization Library 2.0.0-b3

A lightweight C++ OpenGL middleware for 2D/3D graphics

VL     Star     Watch     Fork     Issue

[Download] [Tutorials] [All Classes] [Grouped Classes]
Public Types | Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
vl::Buffer Class Reference

Implements a buffer whose storage is in local memory. More...

#include <Buffer.hpp>

+ Inheritance diagram for vl::Buffer:

Public Types

enum  EAllocationMode { UserAllocatedBuffer, AutoAllocatedBuffer }
 

Public Member Functions

 Buffer ()
 
 Buffer (const Buffer &other)
 
Bufferoperator= (const Buffer &other)
 
void swap (Buffer &other)
 
 ~Buffer ()
 
void clear ()
 
void resize (size_t byte_count, size_t alignment=0)
 
void setUserAllocatedBuffer (void *ptr, size_t bytes)
 Uses a user-allocated buffer as storage. More...
 
void setAllocationMode (EAllocationMode mode)
 
EAllocationMode allocationMode () const
 
size_t bytesUsed () const
 
bool empty () const
 
unsigned char * ptr ()
 
const unsigned char * ptr () const
 
size_t alignment () const
 
- Public Member Functions inherited from vl::Object
 Object ()
 Constructor. More...
 
 Object (const Object &other)
 Copy constructor: copies the name, ref count mutex and user data. More...
 
Objectoperator= (const Object &other)
 Copy operator: copies the object's name, ref count mutex and user data. More...
 
const std::string & objectName () const
 The name of the object, by default set to the object's class name. More...
 
void setObjectName (const char *name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setObjectName (const std::string &name)
 The name of the object, by default set to the object's class name in debug builds. More...
 
void setRefCountMutex (IMutex *mutex)
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
IMutexrefCountMutex ()
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
const IMutexrefCountMutex () const
 The mutex used to protect the reference counting of an Object across multiple threads. More...
 
int referenceCount () const
 Returns the number of references of an object. More...
 
void incReference () const
 Increments the reference count of an object. More...
 
void decReference ()
 Decrements the reference count of an object and deletes it if both automaticDelete() is true the count reaches 0. More...
 
void setAutomaticDelete (bool autodel_on)
 If set to true the Object is deleted when its reference count reaches 0. More...
 
bool automaticDelete () const
 If set to true the Object is deleted when its reference count reaches 0. More...
 
template<class T >
T * as ()
 Casts an Object to the specified class. More...
 
template<class T >
const T * as () const
 Casts an Object to the specified class. More...
 

Static Public Member Functions

static void * alignedMalloc (size_t bytes, size_t alignment)
 
static void alignedFree (void *ptr)
 

Protected Attributes

unsigned char * mPtr
 
size_t mByteCount
 
size_t mAlignment
 
EAllocationMode mAllocationMode
 
- Protected Attributes inherited from vl::Object
std::string mObjectName
 
IMutexmRefCountMutex
 
int mReferenceCount
 
bool mAutomaticDelete
 

Additional Inherited Members

- Protected Member Functions inherited from vl::Object
virtual ~Object ()
 

Detailed Description

Implements a buffer whose storage is in local memory.

Definition at line 46 of file Buffer.hpp.

Member Enumeration Documentation

◆ EAllocationMode

Enumerator
UserAllocatedBuffer 
AutoAllocatedBuffer 

Definition at line 51 of file Buffer.hpp.

Constructor & Destructor Documentation

◆ Buffer() [1/2]

vl::Buffer::Buffer ( )
inline

Definition at line 58 of file Buffer.hpp.

References AutoAllocatedBuffer, mAlignment, mAllocationMode, mByteCount, mPtr, and NULL.

◆ Buffer() [2/2]

vl::Buffer::Buffer ( const Buffer other)
inline

Definition at line 66 of file Buffer.hpp.

References AutoAllocatedBuffer, mAlignment, mAllocationMode, mByteCount, mPtr, and NULL.

◆ ~Buffer()

vl::Buffer::~Buffer ( )
inline

Definition at line 114 of file Buffer.hpp.

References clear().

Member Function Documentation

◆ alignedFree()

static void vl::Buffer::alignedFree ( void *  ptr)
inlinestatic

Definition at line 249 of file Buffer.hpp.

References NULL.

Referenced by clear(), and resize().

◆ alignedMalloc()

static void* vl::Buffer::alignedMalloc ( size_t  bytes,
size_t  alignment 
)
inlinestatic

Definition at line 209 of file Buffer.hpp.

References NULL.

Referenced by resize().

◆ alignment()

size_t vl::Buffer::alignment ( ) const
inline

Definition at line 205 of file Buffer.hpp.

References mAlignment.

Referenced by resize().

◆ allocationMode()

EAllocationMode vl::Buffer::allocationMode ( ) const
inline

Definition at line 195 of file Buffer.hpp.

References mAllocationMode.

◆ bytesUsed()

size_t vl::Buffer::bytesUsed ( ) const
inline

◆ clear()

void vl::Buffer::clear ( )
inline

◆ empty()

bool vl::Buffer::empty ( ) const
inline

Definition at line 199 of file Buffer.hpp.

References mByteCount.

◆ operator=()

Buffer& vl::Buffer::operator= ( const Buffer other)
inline

◆ ptr() [1/2]

unsigned char* vl::Buffer::ptr ( )
inline

◆ ptr() [2/2]

const unsigned char* vl::Buffer::ptr ( ) const
inline

Definition at line 203 of file Buffer.hpp.

References mPtr.

◆ resize()

void vl::Buffer::resize ( size_t  byte_count,
size_t  alignment = 0 
)
inline

◆ setAllocationMode()

void vl::Buffer::setAllocationMode ( EAllocationMode  mode)
inline

Definition at line 182 of file Buffer.hpp.

References clear(), mAlignment, mAllocationMode, mByteCount, and mPtr.

◆ setUserAllocatedBuffer()

void vl::Buffer::setUserAllocatedBuffer ( void *  ptr,
size_t  bytes 
)
inline

Uses a user-allocated buffer as storage.

After calling this function any call to resize() is illegal. Calling this function enables the UserAllocatedBuffer mode. Call setAllocationMode( AutoAllocatedBuffer ) to revert to the default behaviour.

Definition at line 173 of file Buffer.hpp.

References clear(), mAlignment, mAllocationMode, mByteCount, mPtr, and UserAllocatedBuffer.

◆ swap()

void vl::Buffer::swap ( Buffer other)
inline

Definition at line 98 of file Buffer.hpp.

References mAlignment, mByteCount, and mPtr.

Referenced by vl::BufferObject::swap().

Member Data Documentation

◆ mAlignment

size_t vl::Buffer::mAlignment
protected

◆ mAllocationMode

EAllocationMode vl::Buffer::mAllocationMode
protected

◆ mByteCount

size_t vl::Buffer::mByteCount
protected

◆ mPtr

unsigned char* vl::Buffer::mPtr
protected

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