GLIP-Lib
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Public Member Functions | Static Public Member Functions | List of all members
Glip::CoreGL::HdlDynamicTable Class Referenceabstract

Dynamic table allocator for GL types (run-time resolution of type). More...

#include <HdlDynamicData.hpp>

Inherited by Glip::CoreGL::HdlDynamicTableSpecial< T >.

Public Member Functions

const GLenum & getGLType (void) const
 Get the type of the current data as the GL identifier. More...
 
bool isFloatingPointType (void) const
 Test if the data is floatting point. More...
 
bool isIntegerType (void) const
 Test if the data is integer. More...
 
const int & getNumRows (void) const
 Get the number of rows of the data. More...
 
const int & getNumColumns (void) const
 Get the number of columns of the data. More...
 
const int & getNumSlices (void) const
 Get the number of slices of the data. More...
 
int getNumElements (void) const
 Get the number of elements of the table (rows times columns times slices). More...
 
const int & getAlignment (void) const
 Get the data alignment. More...
 
virtual size_t getElementSize (void) const =0
 Get the size of one element, in bytes. More...
 
size_t getSliceSize (void) const
 Get the size of one slice, in bytes. More...
 
size_t getRowSize (void) const
 Get the size of one row, in bytes. More...
 
size_t getSize (void) const
 Get the size of whole table, in bytes. More...
 
bool isProxy (void) const
 Test if the table is actually a proxy. More...
 
bool isNormalized (void) const
 Test if the table is normalized. More...
 
bool isInside (const int &j, const int &i, const int &d) const
 Test if the coordinates are for a valid element inside the table. More...
 
int getIndex (const int &j, const int &i, const int &d) const
 Get the linear index corresponding to these coordinates. More...
 
size_t getOffset (const int &j, const int &i, const int &d) const
 Get the distance in memory, from the beginning of the table to the targeted element. More...
 
size_t getRowOffset (const int &i) const
 Get the offset for the beginning of a row. More...
 
virtual float getf (const int &j=0, const int &i=0, const int &d=0) const =0
 Get the value at coordinates (j, i, d) casted to float. More...
 
virtual void setf (const float &value, const int &j=0, const int &i=0, const int &d=0)=0
 Set the value at coordinates (j, i, d) from a float value. More...
 
virtual double getd (const int &j=0, const int &i=0, const int &d=0) const =0
 Get the value at coordinates (j, i, d) casted to double. More...
 
virtual void setd (const double &value, const int &j=0, const int &i=0, const int &d=0)=0
 Set the value at coordinates (j, i, d) from a double value. More...
 
virtual long long getl (const int &j=0, const int &i=0, const int &d=0) const =0
 Get the value at coordinates (j, i, d) casted to long long. More...
 
virtual void setl (const long long &value, const int &j=0, const int &i=0, const int &d=0)=0
 Set the value at coordinates (j, i, d) from an integer value. More...
 
virtual int geti (const int &j=0, const int &i=0, const int &d=0) const =0
 Get the value at coordinates (j, i, d) casted to int. More...
 
virtual void seti (const int &value, const int &j=0, const int &i=0, const int &d=0)=0
 Set the value at coordinates (j, i, d) from an integer value. More...
 
virtual unsigned char getb (const int &j=0, const int &i=0, const int &d=0) const =0
 Get the value at coordinates (j, i, d) casted to unsigned char. More...
 
virtual void setb (const unsigned char &value, const int &j=0, const int &i=0, const int &d=0)=0
 Set the value at coordinates (j, i, d) from an unsigned char value. More...
 
virtual float getNormalized (const int &j=0, const int &i=0, const int &d=0) const =0
 Get the value at coordinates (j, i, d) in a normalized range. More...
 
virtual void setNormalized (const float &value, const int &j=0, const int &i=0, const int &d=0)=0
 Set the value at coordinates (j, i, d) from a normalized value. More...
 
virtual void * get (const int &j=0, const int &i=0, const int &d=0) const =0
 Get direct pointer to the data. More...
 
virtual void set (void *value, const int &j=0, const int &i=0, const int &d=0) const =0
 Set data, assuming the same underlying type. More...
 
virtual float readf (size_t offset) const =0
 Reading a floatting point value from the given position. More...
 
virtual void writef (const float &value, size_t offset)=0
 Write a floatting point value at the given position. More...
 
virtual double readd (size_t offset) const =0
 Reading a floatting point value from the given position. More...
 
virtual void writed (const double &value, size_t offset)=0
 Write a floatting point value at the given position. More...
 
virtual long long readl (size_t offset) const =0
 Reading an integer value from the given position. More...
 
virtual void writel (const long long &value, size_t offset)=0
 Write an integer value at the given position. More...
 
virtual int readi (size_t offset) const =0
 Reading an integer value from the given position. More...
 
virtual void writei (const int &value, size_t offset)=0
 Write an integer value at the given position. More...
 
virtual unsigned char readb (size_t offset) const =0
 Reading an integer value from the given position. More...
 
virtual void writeb (const unsigned char &value, size_t offset)=0
 Write an integer value at the given position. More...
 
virtual float readNormalized (size_t offset) const =0
 Reading an integer value from the given position. More...
 
virtual void writeNormalized (const float &value, size_t offset)=0
 Write a normalized value at the given position. More...
 
virtual void write (const void *value, size_t offset)=0
 Write a shapeless value at the given position (presumed within the table and of the same type). More...
 
void writeBytes (const void *value, size_t length, size_t offset)
 Write a shapeless value array at the given position. More...
 
virtual const void * getPtr (void) const =0
 Get the pointer to the data (const). More...
 
virtual void * getPtr (void)=0
 Get the pointer to the data. More...
 
virtual const void * getRowPtr (int i) const =0
 Get the pointer to the begin of the targeted row (const). More...
 
virtual void * getRowPtr (int i)=0
 Get the pointer to the begin of the targeted row. More...
 
virtual const HdlDynamicTableoperator= (const HdlDynamicTable &cpy)=0
 Copy the value from another HdlDynamicData object. Type MUST match, will raise an exception otherwise. More...
 
void memset (unsigned char c)
 Clear the array. More...
 

Static Public Member Functions

static HdlDynamicTablebuild (const GLenum &type, const int &_columns, const int &_rows, const int &_slices, bool _normalized=false, int _alignment=1)
 Build dynamic data from a GL data identifier (see supported types in main description of HdlDynamicData). More...
 
static HdlDynamicTablebuildProxy (void *buffer, const GLenum &type, const int &_columns, const int &_rows, const int &_slices, bool _normalized=false, int _alignment=1)
 Build dynamic data proxy from a GL data identifier and a buffer pointer (see supported types in main description of HdlDynamicData). More...
 
static HdlDynamicTablecopy (const HdlDynamicTable &cpy)
 Copy dynamic data. More...
 

Detailed Description

Dynamic table allocator for GL types (run-time resolution of type).

Supported types : GL_BOOL, GL_BYTE, GL_UNSIGNED_BYTE, GL_SHORT, GL_UNSIGNED_SHORT, GL_INT, GL_UNSIGNED_INT, GL_FLOAT, GL_DOUBLE. The indexing is row major and the slices are interleaved ("RGBRGBRGB..." image-like). Most of the accessors do NOT perform tests on coordinate validity.

Example :

// Get a GL_UNSIGNED_CHAR buffer for an image :
HdlDynamicTable* table = HdlDynamicTable::build(GL_UNSIGNED_CHAR, 640, 480, 3);
// Set some data ("first pixel to medium green") :
data->seti(0, 0, 0, 0);
data->seti(128, 0, 0, 1);
data->seti(0, 0, 0, 2);
// Delete :
delete data;

Member Function Documentation

HdlDynamicTable * HdlDynamicTable::build ( const GLenum &  type,
const int &  _columns,
const int &  _rows,
const int &  _slices,
bool  _normalized = false,
int  _alignment = 1 
)
static

Build dynamic data from a GL data identifier (see supported types in main description of HdlDynamicData).

Parameters
typeThe required GL type.
_columnsThe number of columns of the table.
_rowsThe number of rows of the table.
_slicesThe number of slices of the table.
_normalizedTrue if the data is normalized.
_alignmentData alignment (per row, should be either 1, 4, or 8).
Returns
A data object allocated on the stack, that the user will have to delete once used. Raise an exception if any error occurs.
HdlDynamicTable * HdlDynamicTable::buildProxy ( void *  buffer,
const GLenum &  type,
const int &  _columns,
const int &  _rows,
const int &  _slices,
bool  _normalized = false,
int  _alignment = 1 
)
static

Build dynamic data proxy from a GL data identifier and a buffer pointer (see supported types in main description of HdlDynamicData).

Parameters
bufferThe original data (will not be deleted, the user must guarantee that this object is destroyed when the original data is).
typeThe required GL type.
_columnsThe number of columns of the table.
_rowsThe number of rows of the table.
_slicesThe number of slices of the table.
_normalizedTrue if the data is normalized.
_alignmentData alignment (per row, should be either 1, 4, or 8).
Returns
A data object allocated on the stack, that the user will have to delete once used. Raise an exception if any error occurs.
HdlDynamicTable * HdlDynamicTable::copy ( const HdlDynamicTable cpy)
static

Copy dynamic data.

Parameters
cpyThe original element to be copied.
Returns
A data object allocated on the stack, that the user will have to delete once used. Raise an exception if any error occurs.
void * Glip::CoreGL::HdlDynamicTable::get ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get direct pointer to the data.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
Shapeless pointer to the data.
const int & HdlDynamicTable::getAlignment ( void  ) const

Get the data alignment.

Returns
The row alignment in memory, in bytes.
unsigned char Glip::CoreGL::HdlDynamicTable::getb ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get the value at coordinates (j, i, d) casted to unsigned char.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The value at the requested coordinates converted to unsigned char.
double Glip::CoreGL::HdlDynamicTable::getd ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get the value at coordinates (j, i, d) casted to double.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The value at the requested coordinates converted to double.
size_t Glip::CoreGL::HdlDynamicTable::getElementSize ( void  ) const
pure virtual

Get the size of one element, in bytes.

Returns
The size, in bytes.
float Glip::CoreGL::HdlDynamicTable::getf ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get the value at coordinates (j, i, d) casted to float.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The value at the requested coordinates converted to float.
const GLenum & HdlDynamicTable::getGLType ( void  ) const

Get the type of the current data as the GL identifier.

Returns
The GLenum corresponding to the type.
int Glip::CoreGL::HdlDynamicTable::geti ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get the value at coordinates (j, i, d) casted to int.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The value at the requested coordinates converted to int.
int HdlDynamicTable::getIndex ( const int &  i,
const int &  j,
const int &  d 
) const

Get the linear index corresponding to these coordinates.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The linear index.
long long Glip::CoreGL::HdlDynamicTable::getl ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get the value at coordinates (j, i, d) casted to long long.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The value at the requested coordinates converted to long long.
float Glip::CoreGL::HdlDynamicTable::getNormalized ( const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Get the value at coordinates (j, i, d) in a normalized range.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The value at the requested coordinates converted to a normalized range.
const int & HdlDynamicTable::getNumColumns ( void  ) const

Get the number of columns of the data.

Returns
The number of columns of the table.
int HdlDynamicTable::getNumElements ( void  ) const

Get the number of elements of the table (rows times columns times slices).

Returns
The number of elements in the table.
const int & HdlDynamicTable::getNumRows ( void  ) const

Get the number of rows of the data.

Returns
The number of rows of the table.
const int & HdlDynamicTable::getNumSlices ( void  ) const

Get the number of slices of the data.

Returns
The number of slices of the table.
size_t HdlDynamicTable::getOffset ( const int &  j,
const int &  i,
const int &  d 
) const

Get the distance in memory, from the beginning of the table to the targeted element.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
The distance to the beginning of the table, in bytes.
const void * Glip::CoreGL::HdlDynamicTable::getPtr ( void  ) const
pure virtual

Get the pointer to the data (const).

Returns
The pointer to the data casted to const void*.
void * Glip::CoreGL::HdlDynamicTable::getPtr ( void  )
pure virtual

Get the pointer to the data.

Returns
The pointer to the data casted to void*.
size_t HdlDynamicTable::getRowOffset ( const int &  i) const

Get the offset for the beginning of a row.

Parameters
iThe index of the row.
Returns
The distance to the beginning of the table, in bytes.
const void * Glip::CoreGL::HdlDynamicTable::getRowPtr ( int  i) const
pure virtual

Get the pointer to the begin of the targeted row (const).

Parameters
iThe row index.
Returns
The pointer to the begin of the targeted row casted to const void*.
void * Glip::CoreGL::HdlDynamicTable::getRowPtr ( int  i)
pure virtual

Get the pointer to the begin of the targeted row.

Parameters
iThe row index.
Returns
The pointer to the begin of the targeted row casted to void*.
size_t HdlDynamicTable::getRowSize ( void  ) const

Get the size of one row, in bytes.

Returns
The size of one row, in bytes, and accounting for the alignment.
size_t HdlDynamicTable::getSize ( void  ) const

Get the size of whole table, in bytes.

Returns
The size of the whole table, in bytes, and accounting for the alignment.
size_t HdlDynamicTable::getSliceSize ( void  ) const

Get the size of one slice, in bytes.

Returns
The size of one slice, or HdlDynamicTable::getNumSlices times HdlDynamicTable::getElementSize, in bytes.
bool HdlDynamicTable::isFloatingPointType ( void  ) const

Test if the data is floatting point.

Test if the data is unsigned.

Test if the data is boolean.

Returns
True if the data is floatting point.
True if the data is boolean.
True if the data is unsigned.
bool HdlDynamicTable::isInside ( const int &  i,
const int &  j,
const int &  d 
) const

Test if the coordinates are for a valid element inside the table.

Parameters
jThe index of the column.
iThe index of the row.
dThe index of the slice.
Returns
True if the coordinates are valid, false otherwise.
bool HdlDynamicTable::isIntegerType ( void  ) const

Test if the data is integer.

Returns
True if the data is integer.
bool HdlDynamicTable::isNormalized ( void  ) const

Test if the table is normalized.

Returns
True if this table is normalized (floatting point data in the range [0, 1]).
bool HdlDynamicTable::isProxy ( void  ) const

Test if the table is actually a proxy.

Returns
True if this table is a proxy to some data.
void HdlDynamicTable::memset ( unsigned char  c)

Clear the array.

Parameters
cCharacter to be used to clear the array.
const HdlDynamicTable & Glip::CoreGL::HdlDynamicTable::operator= ( const HdlDynamicTable cpy)
pure virtual

Copy the value from another HdlDynamicData object. Type MUST match, will raise an exception otherwise.

Parameters
cpyThe object to be copied.
Returns
Reference to this object.
unsigned char Glip::CoreGL::HdlDynamicTable::readb ( size_t  offset) const
pure virtual

Reading an integer value from the given position.

Parameters
offsetOffset in the table.
Returns
Value at the given position, casted to unsigned char.
double Glip::CoreGL::HdlDynamicTable::readd ( size_t  offset) const
pure virtual

Reading a floatting point value from the given position.

Parameters
offsetOffset in the table.
Returns
Value at the given position, casted to double.
float Glip::CoreGL::HdlDynamicTable::readf ( size_t  offset) const
pure virtual

Reading a floatting point value from the given position.

Parameters
offsetOffset in the table.
Returns
Value at the given position, casted to float.
int Glip::CoreGL::HdlDynamicTable::readi ( size_t  offset) const
pure virtual

Reading an integer value from the given position.

Parameters
offsetOffset in the table.
Returns
Value at the given position, casted to int.
long long Glip::CoreGL::HdlDynamicTable::readl ( size_t  offset) const
pure virtual

Reading an integer value from the given position.

Parameters
offsetOffset in the table.
Returns
Value at the given position, casted to long long.
float Glip::CoreGL::HdlDynamicTable::readNormalized ( size_t  offset) const
pure virtual

Reading an integer value from the given position.

Parameters
offsetOffset in the table.
Returns
Value at the given position, casted to a normalized range.
void Glip::CoreGL::HdlDynamicTable::set ( void *  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
) const
pure virtual

Set data, assuming the same underlying type.

Parameters
valueThe new value (assumed to be of the same type).
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::setb ( const unsigned char &  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
)
pure virtual

Set the value at coordinates (j, i, d) from an unsigned char value.

Parameters
valueThe new value.
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::setd ( const double &  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
)
pure virtual

Set the value at coordinates (j, i, d) from a double value.

Parameters
valueThe new value.
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::setf ( const float &  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
)
pure virtual

Set the value at coordinates (j, i, d) from a float value.

Parameters
valueThe new value.
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::seti ( const int &  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
)
pure virtual

Set the value at coordinates (j, i, d) from an integer value.

Parameters
valueThe new value.
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::setl ( const long long &  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
)
pure virtual

Set the value at coordinates (j, i, d) from an integer value.

Parameters
valueThe new value.
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::setNormalized ( const float &  value,
const int &  j = 0,
const int &  i = 0,
const int &  d = 0 
)
pure virtual

Set the value at coordinates (j, i, d) from a normalized value.

Parameters
valueThe new value.
jThe index of the column.
iThe index of the row.
dThe index of the slice.
void Glip::CoreGL::HdlDynamicTable::write ( const void *  value,
size_t  offset 
)
pure virtual

Write a shapeless value at the given position (presumed within the table and of the same type).

Parameters
valueShapeless value (of the same type as for the table).
offsetOffset in the table.
void Glip::CoreGL::HdlDynamicTable::writeb ( const unsigned char &  value,
size_t  offset 
)
pure virtual

Write an integer value at the given position.

Parameters
valueInteger value to write.
offsetOffset in the table.
void HdlDynamicTable::writeBytes ( const void *  value,
size_t  length,
size_t  offset 
)

Write a shapeless value array at the given position.

Parameters
valueShapeless value.
lengthThe amount of data to write (in bytes).
offsetOffset in the table.
void Glip::CoreGL::HdlDynamicTable::writed ( const double &  value,
size_t  offset 
)
pure virtual

Write a floatting point value at the given position.

Parameters
valueFloatting point value to write.
offsetOffset in the table.
void Glip::CoreGL::HdlDynamicTable::writef ( const float &  value,
size_t  offset 
)
pure virtual

Write a floatting point value at the given position.

Parameters
valueFloatting point value to write.
offsetOffset in the table.
void Glip::CoreGL::HdlDynamicTable::writei ( const int &  value,
size_t  offset 
)
pure virtual

Write an integer value at the given position.

Parameters
valueInteger value to write.
offsetOffset in the table.
void Glip::CoreGL::HdlDynamicTable::writel ( const long long &  value,
size_t  offset 
)
pure virtual

Write an integer value at the given position.

Parameters
valueInteger value to write.
offsetOffset in the table.
void Glip::CoreGL::HdlDynamicTable::writeNormalized ( const float &  value,
size_t  offset 
)
pure virtual

Write a normalized value at the given position.

Parameters
valueNormalized value to write.
offsetOffset in the table.

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