libvisual  0.5.0
Public Member Functions | Static Public Member Functions | Friends | List of all members
LV::Buffer Class Reference

Reference-counted memory block. More...

#include <libvisual/lv_buffer.h>

Public Member Functions

 Buffer (Buffer const &)=delete
 
Bufferoperator= (Buffer const &)=delete
 
void destroy_content ()
 Destroys the buffer content.
 
void set (void *data, std::size_t size)
 Sets the data pair (data and its size). More...
 
void set_size (std::size_t size)
 Sets the size of the data. More...
 
void set_data (void *data)
 Sets the pointer to a memory block to manage. More...
 
void allocate (std::size_t size)
 Allocates the data for a Buffer. More...
 
void * get_data () const
 Return the pointer to the managed memory block. More...
 
void * get_data (std::size_t offset) const
 Returns the pointer to the managed memory block, starting at a given offset. More...
 
std::size_t get_size () const
 Gets the size in bytes of a Buffer. More...
 
bool is_allocated () const
 Returns true if memory block is allocated and managed by the Buffer. More...
 
void copy (BufferConstPtr const &src)
 Clones the content of another Buffer. More...
 
void copy_to (BufferPtr const &dest)
 Copies all data to a given Buffer. More...
 
void copy_to (void *dest, std::size_t size)
 Copies all data to a given memory location. More...
 
void put (BufferConstPtr const &src, std::size_t offset)
 Copies data from another Buffer. More...
 
void put (void const *data, std::size_t size, std::size_t offset)
 Copies data from a memory location. More...
 
void fill (uint8_t value)
 Fills the buffer with a byte value. More...
 
void fill_with_pattern (void const *data, std::size_t size)
 Fills the buffer with a data pattern drawn from a memory location. More...
 

Static Public Member Functions

static BufferPtr create ()
 Constructs a new empty Buffer.
 
static BufferPtr wrap (void *data, std::size_t size, bool own=true)
 Constructs a new Buffer with an externally allocated block. More...
 
static BufferPtr create (std::size_t size)
 Constructs a new Buffer of a given size. More...
 

Friends

void intrusive_ptr_add_ref (Buffer const *buffer)
 
void intrusive_ptr_release (Buffer const *buffer)
 

Detailed Description

Reference-counted memory block.

Definition at line 50 of file lv_buffer.h.

Member Function Documentation

void LV::Buffer::allocate ( std::size_t  size)

Allocates the data for a Buffer.

Parameters
sizeSize of memory block
Note
This is obsolete and reserved for internal use.
Todo:
Remove this.

Definition at line 137 of file lv_buffer.cpp.

void LV::Buffer::copy ( BufferConstPtr const &  src)

Clones the content of another Buffer.

Parameters
srcsource Buffer to clone data from

Definition at line 162 of file lv_buffer.cpp.

void LV::Buffer::copy_to ( BufferPtr const &  dest)

Copies all data to a given Buffer.

Parameters
destBuffer to copy to

Definition at line 175 of file lv_buffer.cpp.

void LV::Buffer::copy_to ( void *  dest,
std::size_t  size 
)

Copies all data to a given memory location.

Parameters
destpointer to memory location
sizenumber of bytes to copy

Definition at line 168 of file lv_buffer.cpp.

BufferPtr LV::Buffer::create ( std::size_t  size)
static

Constructs a new Buffer of a given size.

Parameters
sizesize in bytes

Definition at line 103 of file lv_buffer.cpp.

void LV::Buffer::fill ( uint8_t  value)

Fills the buffer with a byte value.

Parameters
valuefill value

Definition at line 195 of file lv_buffer.cpp.

void LV::Buffer::fill_with_pattern ( void const *  data,
std::size_t  size 
)

Fills the buffer with a data pattern drawn from a memory location.

Parameters
datapointer to memory block to source pattern from
sizenumber of bytes to fill

Definition at line 200 of file lv_buffer.cpp.

void * LV::Buffer::get_data ( ) const

Return the pointer to the managed memory block.

Returns
Pointer to memory block

Definition at line 142 of file lv_buffer.cpp.

void * LV::Buffer::get_data ( std::size_t  offset) const

Returns the pointer to the managed memory block, starting at a given offset.

Parameters
offsetoffset in bytes
Returns
Pointer to memory block

Definition at line 147 of file lv_buffer.cpp.

std::size_t LV::Buffer::get_size ( ) const

Gets the size in bytes of a Buffer.

Returns
size in bytes

Definition at line 152 of file lv_buffer.cpp.

bool LV::Buffer::is_allocated ( ) const

Returns true if memory block is allocated and managed by the Buffer.

Returns
true if memory block is allocated and managed, false otherwise

Definition at line 157 of file lv_buffer.cpp.

void LV::Buffer::put ( BufferConstPtr const &  src,
std::size_t  offset 
)

Copies data from another Buffer.

Parameters
srcsource Buffer
offsetoffset to copy first byte to

Definition at line 180 of file lv_buffer.cpp.

Referenced by fill_with_pattern().

void LV::Buffer::put ( void const *  data,
std::size_t  size,
std::size_t  offset 
)

Copies data from a memory location.

Parameters
datapointer to memory location
sizenumber of bytes to copy
offsetoffset to copy first byte to

Definition at line 185 of file lv_buffer.cpp.

void LV::Buffer::set ( void *  data,
std::size_t  size 
)

Sets the data pair (data and its size).

Parameters
dataPointer to memory block
sizeSize of memory block
Todo:
remove this.

Definition at line 122 of file lv_buffer.cpp.

void LV::Buffer::set_data ( void *  data)

Sets the pointer to a memory block to manage.

Parameters
dataPointer to the data.
Note
This is obsolete and reserved for internal use.
Todo:
Remove this.

Definition at line 132 of file lv_buffer.cpp.

void LV::Buffer::set_size ( std::size_t  size)

Sets the size of the data.

Parameters
sizeSize in bytes of the data.
Note
This is obsolete and reserved for internal use.
Todo:
Remove this.

Definition at line 127 of file lv_buffer.cpp.

BufferPtr LV::Buffer::wrap ( void *  data,
std::size_t  size,
bool  own = true 
)
static

Constructs a new Buffer with an externally allocated block.

Note
Use this to wrap and optionally manage memory blocks allocated by C functions.
Parameters
datapointer to memory block
sizesize of memory block in bytes
ownindicates whether to take ownership

Definition at line 94 of file lv_buffer.cpp.


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