Nebula
Loading...
Searching...
No Matches
Attr::AttributeTable Class Reference

#include <attributetable.h>

Detailed Description

A table of attributes with a compact memory footprint and fast random access.

Table columns are defined by attribute ids which associate a name, a fourcc code, a datatype and an access mode (ReadWrite, ReadOnly) to the table. Attribute values are stored in one big chunk of memory without additional overhead. Table cells can have the NULL status, which means the cell contains no value.

The table's value buffer consists of 16-byte aligned rows, each row consists of a bitfield with 2 bits per row (one bit is set if a column/row value is valid, the other is used as modified-marker).

Rows are allocated contigously in memory, which means padding might be inserted "between columns/values" to fulfill memory alignment requirements

The AttributeTable object keeps track of all changes (added columns, added rows, modified rows, modified values).

Inherits Core::RefCounted.

Inherited by Db::ValueTable.

Classes

struct  ColumnInfo
 

Public Member Functions

 AttributeTable ()
 constructor
 
 AttributeTable (std::initializer_list< Attr::AttrId > columns, bool recordColumns=false)
 construct with initializer list
 
virtual ~AttributeTable ()
 destructor
 
void SetModifiedTracking (bool b)
 enable/disable modified tracking (default is on)
 
bool GetModifiedTracking () const
 get modified tracking flag
 
bool IsModified () const
 return true if the object has been modified since the last ResetModifiedState()
 
void ResetModifiedState ()
 reset all the modified bits in the table
 
void Clear ()
 clear the table object
 
void PrintDebug ()
 print the contents of the table for debugging reasons
 
void BeginAddColumns (bool recordNewColumns=true)
 optional: call before adding columns, speeds up adding many columns at once
 
void AddColumn (const AttrId &id, bool recordNewColumn=true)
 add a column
 
void EndAddColumns ()
 optional: call after adding columns, speeds up adding many columns at once
 
bool HasColumn (const AttrId &id) const
 return true if a column exists
 
IndexT GetColumnIndex (const AttrId &id) const
 return index of column by id
 
SizeT GetNumColumns () const
 get number of columns
 
const AttrIdGetColumnId (IndexT colIndex) const
 get column definition at index
 
const Util::StringGetColumnName (IndexT colIndex) const
 get a column's name
 
const Util::FourCCGetColumnFourCC (IndexT colIndex) const
 get column FourCC
 
AccessMode GetColumnAccessMode (IndexT colIndex) const
 get a column's access mode
 
ValueType GetColumnValueType (IndexT colIndex) const
 get a column's value type
 
const Util::Array< IndexT > & GetNewColumnIndices () const
 return indices of columns added since the last ResetModifiedState()
 
const Util::Array< IndexT > & GetReadWriteColumnIndices () const
 return indices of all ReadWrite columns
 
IndexT AddRow ()
 add a row to the table, returns index of new row
 
void ClearNewRowFlags ()
 clear the new row flags, so that new rows are treated like updated rows
 
void ClearDeletedRowsFlags ()
 clear deleted rows flags
 
void DeleteRow (IndexT rowIndex)
 mark a row as deleted from the table
 
void DeleteAllRows ()
 mark all rows as deleted
 
bool IsRowDeleted (IndexT rowIndex) const
 return true if row has been marked as deleted
 
IndexT CopyRow (IndexT rowIndex)
 create a new row as copy of another row
 
void CopyRow (IndexT srcRowIndex, IndexT dstRowIndex)
 Copy contents of one row into another.
 
IndexT CopyExtRow (AttributeTable *other, IndexT otherRowIndex, bool createMissingRows=false)
 create a new row as copy of a row from another value table
 
SizeT GetNumRows () const
 get number of rows in table
 
bool HasNewRows () const
 return true if table has new rows
 
bool HasModifiedRows () const
 return true if table has modified rows
 
bool HasDeletedRows () const
 return true if table has deleted rows
 
bool IsRowModified (IndexT rowIndex) const
 return true if a row has been modified since the last ResetModifiedState()
 
const Util::Array< IndexT > & GetNewRowIndices () const
 return indices of rows added since the last ResetModfiedState()
 
const Util::Array< IndexT > & GetDeletedRowIndices () const
 return indices of rows deleted since the last ResetModifiedState()
 
Util::Array< IndexTGetModifiedRowsExcludeNewAndDeletedRows () const
 return array of modified rows, exclude rows marked as rows
 
void ReserveRows (SizeT numRows)
 reserve rows to reduce re-allocation overhead
 
Util::Array< IndexTFindRowIndicesByAttr (const Attribute &attr, bool firstMatchOnly) const
 find all matching row indices by attribute value
 
Util::Array< IndexTFindRowIndicesByAttrs (const Util::Array< Attribute > &attrs, bool firstMatchOnly) const
 find all matching row indices by multiple attribute values
 
IndexT FindRowIndexByAttr (const Attribute &attr) const
 find all matching row indices by attribute value
 
IndexT FindRowIndexByAttrs (const Util::Array< Attribute > &attrs) const
 find all matching row indices by multiple attribute values
 
void SetRowUserData (IndexT rowIndex, void *p)
 set an optional row user data pointer
 
void * GetRowUserData (IndexT rowIndex) const
 get optional row user data pointer
 
void SetAttr (const Attr::Attribute &attr, IndexT rowIndex)
 set a generic attribute (slow!)
 
Attr::Attribute GetAttr (IndexT rowIndex, IndexT colIndex) const
 get a generic attribute
 
void SetVariant (const Attr::AttrId &attrId, IndexT rowIndex, const Util::Variant &val)
 set variant value
 
void SetBool (const BoolAttrId &colAttrId, IndexT rowIndex, bool val)
 set bool value
 
bool GetBool (const BoolAttrId &colAttrId, IndexT rowIndex) const
 get bool value
 
void SetFloat (const FloatAttrId &colAttrId, IndexT rowIndex, float val)
 set float value
 
float GetFloat (const FloatAttrId &colAttrId, IndexT rowIndex) const
 get float value
 
void SetInt (const IntAttrId &colAttrId, IndexT rowIndex, int val)
 set int value
 
int GetInt (const IntAttrId &colAttrId, IndexT rowIndex) const
 get int value
 
void SetString (const StringAttrId &colAttrId, IndexT rowIndex, const Util::String &val)
 set string value
 
const Util::StringGetString (const StringAttrId &colAttrId, IndexT rowIndex) const
 get string value
 
void SetVec4 (const Vec4AttrId &colAttrId, IndexT rowIndex, const Math::vec4 &val)
 set float4 value
 
Math::vec4 GetVec4 (const Vec4AttrId &colAttrId, IndexT rowIndex) const
 get float4 value
 
void SetMat4 (const Mat4AttrId &colAttrId, IndexT rowIndex, const Math::mat4 &val)
 set mat4 value
 
Math::mat4 GetMat4 (const Mat4AttrId &colAttrId, IndexT rowIndex) const
 get mat4 value
 
void SetGuid (const GuidAttrId &colAttrId, IndexT rowIndex, const Util::Guid &guid)
 set guid value
 
const Util::GuidGetGuid (const GuidAttrId &colAttrId, IndexT rowIndex) const
 get guid value
 
void SetBlob (const BlobAttrId &colAttrId, IndexT rowIndex, const Util::Blob &blob)
 set blob value
 
const Util::BlobGetBlob (const BlobAttrId &colAttrId, IndexT rowIndex) const
 get blob value
 
void SetVariant (IndexT colIndex, IndexT rowIndex, const Util::Variant &val)
 set variant value
 
void SetBool (IndexT colIndex, IndexT rowIndex, bool val)
 set bool value by column index
 
bool GetBool (IndexT colIndex, IndexT rowIndex) const
 get bool value by column index
 
void SetFloat (IndexT colIndex, IndexT rowIndex, float val)
 set float value by column index
 
float GetFloat (IndexT colIndex, IndexT rowIndex) const
 get float value by column index
 
void SetInt (IndexT colIndex, IndexT rowIndex, int val)
 set int value by column index
 
int GetInt (IndexT colIndex, IndexT rowIndex) const
 get int value by column index
 
void SetUInt (IndexT colIndex, IndexT rowIndex, uint val)
 set uint value by column index
 
uint GetUInt (IndexT colIndex, IndexT rowIndex) const
 get uint value by column index
 
void SetString (IndexT colIndex, IndexT rowIndex, const Util::String &val)
 set string value by column index
 
const Util::StringGetString (IndexT colIndex, IndexT rowIndex) const
 get string value by column index
 
void SetVec4 (IndexT colIndex, IndexT rowIndex, const Math::vec4 &val)
 set float4 value by column index
 
Math::vec4 GetVec4 (IndexT colIndex, IndexT rowIndex) const
 get float4 value by column index
 
void SetMat4 (IndexT colIndex, IndexT rowIndex, const Math::mat4 &val)
 set mat4 value by column index
 
Math::mat4 GetMat4 (IndexT colIndex, IndexT rowIndex) const
 get mat4 value by column index
 
void SetGuid (IndexT colIndex, IndexT rowIndex, const Util::Guid &guid)
 set guid value by column index
 
const Util::GuidGetGuid (IndexT colIndex, IndexT rowIndex) const
 get guid value by column index
 
void SetBlob (IndexT colIndex, IndexT rowIndex, const Util::Blob &blob)
 set blob value by column index
 
const Util::BlobGetBlob (IndexT colIndex, IndexT rowIndex) const
 get blob value by column index
 
bool LoadXmlTable (const Util::String &fileName)
 load xml table
 
- Public Member Functions inherited from Core::RefCounted
 RefCounted ()
 constructor
 
int GetRefCount () const
 get the current refcount
 
void AddRef ()
 increment refcount by one
 
void Release ()
 decrement refcount and destroy object if refcount is zero
 
bool IsInstanceOf (const Rtti &rtti) const
 return true if this object is instance of given class
 
bool IsInstanceOf (const Util::String &className) const
 return true if this object is instance of given class by string
 
bool IsInstanceOf (const Util::FourCC &classFourCC) const
 return true if this object is instance of given class by fourcc
 
bool IsA (const Rtti &rtti) const
 return true if this object is instance of given class, or a derived class
 
bool IsA (const Util::String &rttiName) const
 return true if this object is instance of given class, or a derived class, by string
 
bool IsA (const Util::FourCC &rttiFourCC) const
 return true if this object is instance of given class, or a derived class, by fourcc
 
const Util::StringGetClassName () const
 get the class name
 
Util::FourCC GetClassFourCC () const
 get the class FourCC code
 

Private Member Functions

 __DeclareClass (AttributeTable)
 
void Realloc (SizeT newPitch, SizeT newAllocRows)
 (re-)allocate the current buffer
 
SizeT UpdateColumnOffsets ()
 update the column byte offset and return new pitch
 
SizeT GetValueTypeSize (ValueType type) const
 returns the byte size of the given value type
 
void * GetValuePtr (IndexT colIndex, IndexT rowIndex) const
 returns pointer to a value's memory location
 
void Delete ()
 delete all externally allocated data of this object
 
void DeleteRowData (IndexT rowIndex)
 delete row data, frees all memory used in one row
 
void DeleteString (IndexT colIndex, IndexT rowIndex)
 delete a string from the table
 
void CopyString (IndexT colIndex, IndexT rowIndex, const Util::String &val)
 copy a string into the table
 
void DeleteBlob (IndexT colIndex, IndexT rowIndex)
 delete a blob from the table
 
void CopyBlob (IndexT colIndex, IndexT rowIndex, const Util::Blob &val)
 copy a blob into the table
 
void DeleteGuid (IndexT colIndex, IndexT rowIndex)
 delete a guid from the table
 
void CopyGuid (IndexT colIndex, IndexT rowIndex, const Util::Guid &val)
 copy a guid into the table
 
Util::Array< IndexTInternalFindRowIndicesByAttr (const Attr::Attribute &attr, bool firstMatchOnly) const
 internal row-indices-by-attr find method
 
Util::Array< IndexTInternalFindRowIndicesByAttrs (const Util::Array< Attr::Attribute > &attr, bool firstMatchOnly) const
 internal row-indices-by-multiple-attrs find method
 
void InternalAddColumnHelper (const AttrId &id, bool recordAsNewColumn)
 internal helper method for adding a column
 
void SetColumnToDefaultValues (IndexT colIndex)
 set entire column to its default values
 
void SetRowToDefaultValues (IndexT rowIndex)
 set a row to its default values
 
void SetColumnBool (const BoolAttrId &attrId, bool val)
 set entire column float value
 
void SetColumnFloat (const FloatAttrId &attrId, float val)
 set entire column float value
 
void SetColumnInt (const IntAttrId &attrId, int val)
 set entire column to int value
 
void SetColumnString (const StringAttrId &attrId, const Util::String &val)
 set entire column to string value
 
void SetColumnVec4 (const Vec4AttrId &attrId, const Math::vec4 &val)
 set entire column vec4 value
 
void SetColumnMat4 (const Mat4AttrId &attrId, const Math::mat4 &val)
 set entire column to mat4 value
 
void SetColumnGuid (const GuidAttrId &attrId, const Util::Guid &guid)
 set entire column to guid value
 
void SetColumnBlob (const BlobAttrId &attrId, const Util::Blob &blob)
 set entire column to blob value
 

Private Attributes

Util::Array< ColumnInfocolumns
 
Util::Dictionary< AttrId, IndexTindexMap
 
Util::Array< IndexTreadWriteColumnIndices
 
Util::Array< IndexTnewColumnIndices
 
Util::Array< IndexTnewRowIndices
 
Util::Array< IndexTdeletedRowIndices
 
Util::Array< void * > userData
 
SizeT rowPitch
 
SizeT numRows
 
SizeT allocatedRows
 
void * valueBuffer
 
ucharrowModifiedBuffer
 
ucharrowDeletedBuffer
 
ucharrowNewBuffer
 
bool trackModifications
 
bool isModified
 
bool rowsModified
 
bool inBeginAddColumns
 
bool addColumnsRecordAsNewColumns
 
IndexT firstNewColumnIndex
 

Additional Inherited Members

- Static Public Member Functions inherited from Core::RefCounted
static void DumpRefCountingLeaks ()
 dump refcounting leaks, call at end of application (NEBULA_DEBUG builds only!)
 
- Protected Member Functions inherited from Core::RefCounted
virtual ~RefCounted ()
 destructor (called when refcount reaches zero)
 

Constructor & Destructor Documentation

◆ AttributeTable() [1/2]

Attr::AttributeTable::AttributeTable ( )

constructor

◆ AttributeTable() [2/2]

Attr::AttributeTable::AttributeTable ( std::initializer_list< Attr::AttrId > columns,
bool recordColumns = false )

construct with initializer list

◆ ~AttributeTable()

Attr::AttributeTable::~AttributeTable ( )
virtual

destructor

Member Function Documentation

◆ __DeclareClass()

Attr::AttributeTable::__DeclareClass ( AttributeTable )
private

◆ AddColumn()

void Attr::AttributeTable::AddColumn ( const AttrId & id,
bool recordAsNewColumn = true )

add a column

Add a column to the attribute table.

If the attribute table already contains data, this will reallocate the existing data buffer. The name, data type, access mode, etc of the column is all defined by the given attribute id. The new column will be filled with the attribute id's default value.

◆ AddRow()

IndexT Attr::AttributeTable::AddRow ( )

add a row to the table, returns index of new row

Adds an empty row at the end of the value buffer.

The row will be marked invalid until the first value is set in the row. This will re-allocate the existing value buffer. If you know beforehand how many rows will exist in the table it is more efficient to use one SetNumRows(N) instead of N times AddRow()! The method returns the index of the newly added row. The row will be filled with the row attribute's default values.

◆ BeginAddColumns()

void Attr::AttributeTable::BeginAddColumns ( bool recordAsNewColumns = true)

optional: call before adding columns, speeds up adding many columns at once

Begin adding columns.

Columns can be added at any time, but it will be much more efficient when called between BeginAddColumns() and EndAddColumns(), since this will save a lot of re-allocations.

◆ Clear()

void Attr::AttributeTable::Clear ( )

clear the table object

Clear all rows data and reset the number of rows.

◆ ClearDeletedRowsFlags()

void Attr::AttributeTable::ClearDeletedRowsFlags ( )

clear deleted rows flags

Clears the deleted row flags.

◆ ClearNewRowFlags()

void Attr::AttributeTable::ClearNewRowFlags ( )

clear the new row flags, so that new rows are treated like updated rows

Clears the new row flags.

After this, new rows are treated just like updated rows, which may be useful for some database operations (when an UPDATE is wanted instead of an INSERT).

◆ CopyBlob()

void Attr::AttributeTable::CopyBlob ( IndexT colIndex,
IndexT rowIndex,
const Util::Blob & val )
private

copy a blob into the table

◆ CopyExtRow()

IndexT Attr::AttributeTable::CopyExtRow ( AttributeTable * other,
IndexT otherRowIndex,
bool createMissingRows = false )

create a new row as copy of a row from another value table

Create a new row as a copy of a row in another value table.

The layouts of the value tables must not match, since only matching columns will be considered. NOTE: the user data will be initialised to 0 for the new row.

◆ CopyGuid()

void Attr::AttributeTable::CopyGuid ( IndexT colIndex,
IndexT rowIndex,
const Util::Guid & val )
private

copy a guid into the table

◆ CopyRow() [1/2]

IndexT Attr::AttributeTable::CopyRow ( IndexT fromRowIndex)

create a new row as copy of another row

This creates a new row as a copy of an existing row.

Returns the index of the new row. NOTE: the user data will be initialized to 0 for the new row!

◆ CopyRow() [2/2]

void Attr::AttributeTable::CopyRow ( IndexT srcRowIndex,
IndexT dstRowIndex )

Copy contents of one row into another.

◆ CopyString()

void Attr::AttributeTable::CopyString ( IndexT colIndex,
IndexT rowIndex,
const Util::String & val )
private

copy a string into the table

◆ Delete()

void Attr::AttributeTable::Delete ( )
private

delete all externally allocated data of this object

This frees all allocated data associated with the table.

◆ DeleteAllRows()

void Attr::AttributeTable::DeleteAllRows ( )

mark all rows as deleted

Marks all rows in the table as deleted.

◆ DeleteBlob()

void Attr::AttributeTable::DeleteBlob ( IndexT colIndex,
IndexT rowIndex )
private

delete a blob from the table

◆ DeleteGuid()

void Attr::AttributeTable::DeleteGuid ( IndexT colIndex,
IndexT rowIndex )
private

delete a guid from the table

◆ DeleteRow()

void Attr::AttributeTable::DeleteRow ( IndexT rowIndex)

mark a row as deleted from the table

This marks a row for deletion.

Note that the row will only be marked for deletion, deleted row indices are returned with the GetDeletedRowIndices() call. The row will never be physically removed from memory!

◆ DeleteRowData()

void Attr::AttributeTable::DeleteRowData ( IndexT rowIndex)
private

delete row data, frees all memory used in one row

Clears all data associated with cells of one row (string, blob and guid)

◆ DeleteString()

void Attr::AttributeTable::DeleteString ( IndexT colIndex,
IndexT rowIndex )
private

delete a string from the table

◆ EndAddColumns()

void Attr::AttributeTable::EndAddColumns ( )

optional: call after adding columns, speeds up adding many columns at once

End adding columns.

This will do the actual work.

◆ FindRowIndexByAttr()

IndexT Attr::AttributeTable::FindRowIndexByAttr ( const Attribute & attr) const

find all matching row indices by attribute value

Finds single row index by matching attribute.

This method can be slow since it may search linearly (and vertically) through the table.

◆ FindRowIndexByAttrs()

IndexT Attr::AttributeTable::FindRowIndexByAttrs ( const Util::Array< Attribute > & attrs) const

find all matching row indices by multiple attribute values

Finds single row index by multiple matching attributes.

This method can be slow since it may search linearly (and vertically) through the table.

◆ FindRowIndicesByAttr()

Util::Array< IndexT > Attr::AttributeTable::FindRowIndicesByAttr ( const Attribute & attr,
bool firstMatchOnly ) const

find all matching row indices by attribute value

Finds multiple row indices by matching attribute.

This method can be slow since it may search linearly (and vertically) through the table.

◆ FindRowIndicesByAttrs()

Util::Array< IndexT > Attr::AttributeTable::FindRowIndicesByAttrs ( const Util::Array< Attribute > & attrs,
bool firstMatchOnly ) const

find all matching row indices by multiple attribute values

Finds multiple row indices by multiple matching attribute.

This method can be slow since it may search linearly (and vertically) through the table.

◆ GetAttr()

Attr::Attribute Attr::AttributeTable::GetAttr ( IndexT rowIndex,
IndexT colIndex ) const

get a generic attribute

◆ GetBlob() [1/2]

const Util::Blob & Attr::AttributeTable::GetBlob ( const BlobAttrId & colAttrId,
IndexT rowIndex ) const
inline

get blob value

◆ GetBlob() [2/2]

const Util::Blob & Attr::AttributeTable::GetBlob ( IndexT colIndex,
IndexT rowIndex ) const
inline

get blob value by column index

◆ GetBool() [1/2]

bool Attr::AttributeTable::GetBool ( const BoolAttrId & colAttrId,
IndexT rowIndex ) const
inline

get bool value

◆ GetBool() [2/2]

bool Attr::AttributeTable::GetBool ( IndexT colIndex,
IndexT rowIndex ) const
inline

get bool value by column index

◆ GetColumnAccessMode()

AccessMode Attr::AttributeTable::GetColumnAccessMode ( IndexT colIndex) const
inline

get a column's access mode

◆ GetColumnFourCC()

const Util::FourCC & Attr::AttributeTable::GetColumnFourCC ( IndexT colIndex) const
inline

get column FourCC

◆ GetColumnId()

const AttrId & Attr::AttributeTable::GetColumnId ( IndexT colIndex) const
inline

get column definition at index

◆ GetColumnIndex()

IndexT Attr::AttributeTable::GetColumnIndex ( const AttrId & id) const
inline

return index of column by id

◆ GetColumnName()

const Util::String & Attr::AttributeTable::GetColumnName ( IndexT colIndex) const
inline

get a column's name

◆ GetColumnValueType()

ValueType Attr::AttributeTable::GetColumnValueType ( IndexT colIndex) const
inline

get a column's value type

◆ GetDeletedRowIndices()

const Util::Array< IndexT > & Attr::AttributeTable::GetDeletedRowIndices ( ) const
inline

return indices of rows deleted since the last ResetModifiedState()

◆ GetFloat() [1/2]

float Attr::AttributeTable::GetFloat ( const FloatAttrId & colAttrId,
IndexT rowIndex ) const
inline

get float value

◆ GetFloat() [2/2]

float Attr::AttributeTable::GetFloat ( IndexT colIndex,
IndexT rowIndex ) const
inline

get float value by column index

◆ GetGuid() [1/2]

const Util::Guid & Attr::AttributeTable::GetGuid ( const GuidAttrId & colAttrId,
IndexT rowIndex ) const
inline

get guid value

◆ GetGuid() [2/2]

const Util::Guid & Attr::AttributeTable::GetGuid ( IndexT colIndex,
IndexT rowIndex ) const
inline

get guid value by column index

◆ GetInt() [1/2]

int Attr::AttributeTable::GetInt ( const IntAttrId & colAttrId,
IndexT rowIndex ) const
inline

get int value

◆ GetInt() [2/2]

int Attr::AttributeTable::GetInt ( IndexT colIndex,
IndexT rowIndex ) const
inline

get int value by column index

◆ GetMat4() [1/2]

Math::mat4 Attr::AttributeTable::GetMat4 ( const Mat4AttrId & colAttrId,
IndexT rowIndex ) const
inline

get mat4 value

◆ GetMat4() [2/2]

Math::mat4 Attr::AttributeTable::GetMat4 ( IndexT colIndex,
IndexT rowIndex ) const
inline

get mat4 value by column index

◆ GetModifiedRowsExcludeNewAndDeletedRows()

Util::Array< IndexT > Attr::AttributeTable::GetModifiedRowsExcludeNewAndDeletedRows ( ) const

return array of modified rows, exclude rows marked as rows

Returns an array of all modified rows, but excludes rows marked as new.

◆ GetModifiedTracking()

bool Attr::AttributeTable::GetModifiedTracking ( ) const
inline

get modified tracking flag

◆ GetNewColumnIndices()

const Util::Array< IndexT > & Attr::AttributeTable::GetNewColumnIndices ( ) const
inline

return indices of columns added since the last ResetModifiedState()

◆ GetNewRowIndices()

const Util::Array< IndexT > & Attr::AttributeTable::GetNewRowIndices ( ) const
inline

return indices of rows added since the last ResetModfiedState()

◆ GetNumColumns()

SizeT Attr::AttributeTable::GetNumColumns ( ) const
inline

get number of columns

◆ GetNumRows()

SizeT Attr::AttributeTable::GetNumRows ( ) const
inline

get number of rows in table

◆ GetReadWriteColumnIndices()

const Util::Array< IndexT > & Attr::AttributeTable::GetReadWriteColumnIndices ( ) const
inline

return indices of all ReadWrite columns

◆ GetRowUserData()

void * Attr::AttributeTable::GetRowUserData ( IndexT rowIndex) const

get optional row user data pointer

◆ GetString() [1/2]

const Util::String & Attr::AttributeTable::GetString ( const StringAttrId & colAttrId,
IndexT rowIndex ) const
inline

get string value

◆ GetString() [2/2]

const Util::String & Attr::AttributeTable::GetString ( IndexT colIndex,
IndexT rowIndex ) const
inline

get string value by column index

◆ GetUInt()

uint Attr::AttributeTable::GetUInt ( IndexT colIndex,
IndexT rowIndex ) const
inline

get uint value by column index

◆ GetValuePtr()

void * Attr::AttributeTable::GetValuePtr ( IndexT colIndex,
IndexT rowIndex ) const
inlineprivate

returns pointer to a value's memory location

This returns a pointer to a value's memory location.

◆ GetValueTypeSize()

SizeT Attr::AttributeTable::GetValueTypeSize ( ValueType type) const
private

returns the byte size of the given value type

This returns the cell size for a value type.

The minimum size is 4 (even for Bools), for data alignment reasons. Strings are stored as char pointers, the rest takes as much memory as needed.

◆ GetVec4() [1/2]

Math::vec4 Attr::AttributeTable::GetVec4 ( const Vec4AttrId & colAttrId,
IndexT rowIndex ) const
inline

get float4 value

◆ GetVec4() [2/2]

Math::vec4 Attr::AttributeTable::GetVec4 ( IndexT colIndex,
IndexT rowIndex ) const
inline

get float4 value by column index

◆ HasColumn()

bool Attr::AttributeTable::HasColumn ( const AttrId & id) const
inline

return true if a column exists

◆ HasDeletedRows()

bool Attr::AttributeTable::HasDeletedRows ( ) const
inline

return true if table has deleted rows

◆ HasModifiedRows()

bool Attr::AttributeTable::HasModifiedRows ( ) const
inline

return true if table has modified rows

◆ HasNewRows()

bool Attr::AttributeTable::HasNewRows ( ) const
inline

return true if table has new rows

◆ InternalAddColumnHelper()

void Attr::AttributeTable::InternalAddColumnHelper ( const AttrId & id,
bool recordAsNewColumn )
private

internal helper method for adding a column

Internal helper method to add a new column.

This is called by EndAddColumns() and AddColumn().

◆ InternalFindRowIndicesByAttr()

Util::Array< IndexT > Attr::AttributeTable::InternalFindRowIndicesByAttr ( const Attr::Attribute & attr,
bool firstMatchOnly ) const
private

internal row-indices-by-attr find method

Finds a row index by single attribute value.

This method can be slow since it may search linearly (and vertically) through the table.

FIXME: keep row indices for indexed rows in nDictionaries?

◆ InternalFindRowIndicesByAttrs()

Util::Array< IndexT > Attr::AttributeTable::InternalFindRowIndicesByAttrs ( const Util::Array< Attr::Attribute > & attr,
bool firstMatchOnly ) const
private

internal row-indices-by-multiple-attrs find method

Finds a row index by multiple attribute values.

This method can be slow since it may search linearly (and vertically) through the table. Also, for one attribute this method is slower then InternalFindRowIndicesByAttr()!

FIXME: keep row indices for indexed rows in nDictionaries?

◆ IsModified()

bool Attr::AttributeTable::IsModified ( ) const
inline

return true if the object has been modified since the last ResetModifiedState()

◆ IsRowDeleted()

bool Attr::AttributeTable::IsRowDeleted ( IndexT rowIndex) const
inline

return true if row has been marked as deleted

Return true if a row has been marked as deleted.

◆ IsRowModified()

bool Attr::AttributeTable::IsRowModified ( IndexT rowIndex) const
inline

return true if a row has been modified since the last ResetModifiedState()

Quickly check if a row is modified.

◆ LoadXmlTable()

bool Attr::AttributeTable::LoadXmlTable ( const Util::String & fileName)

load xml table

◆ PrintDebug()

void Attr::AttributeTable::PrintDebug ( )

print the contents of the table for debugging reasons

Print contents of the table for debugging.

◆ Realloc()

void Attr::AttributeTable::Realloc ( SizeT newPitch,
SizeT newAllocRows )
private

(re-)allocate the current buffer

Reallocate the value and modified row buffer, and copy contents over into the new buffer.

◆ ReserveRows()

void Attr::AttributeTable::ReserveRows ( SizeT numRows)

reserve rows to reduce re-allocation overhead

Reserve N more rows beforehand to reduce re-allocation overhead during AddRow().

◆ ResetModifiedState()

void Attr::AttributeTable::ResetModifiedState ( )

reset all the modified bits in the table

This method resets the object to the unmodified state, which means the new-row and new-column index arrays are reset, and all modified bits are cleared.

◆ SetAttr()

void Attr::AttributeTable::SetAttr ( const Attr::Attribute & attr,
IndexT rowIndex )

set a generic attribute (slow!)

Set a generic attribute, this is a slow method!

◆ SetBlob() [1/2]

void Attr::AttributeTable::SetBlob ( const BlobAttrId & colAttrId,
IndexT rowIndex,
const Util::Blob & blob )
inline

set blob value

◆ SetBlob() [2/2]

void Attr::AttributeTable::SetBlob ( IndexT colIndex,
IndexT rowIndex,
const Util::Blob & blob )
inline

set blob value by column index

◆ SetBool() [1/2]

void Attr::AttributeTable::SetBool ( const BoolAttrId & colAttrId,
IndexT rowIndex,
bool val )
inline

set bool value

◆ SetBool() [2/2]

void Attr::AttributeTable::SetBool ( IndexT colIndex,
IndexT rowIndex,
bool val )
inline

set bool value by column index

◆ SetColumnBlob()

void Attr::AttributeTable::SetColumnBlob ( const BlobAttrId & attrId,
const Util::Blob & blob )
private

set entire column to blob value

◆ SetColumnBool()

void Attr::AttributeTable::SetColumnBool ( const BoolAttrId & attrId,
bool val )
private

set entire column float value

◆ SetColumnFloat()

void Attr::AttributeTable::SetColumnFloat ( const FloatAttrId & attrId,
float val )
private

set entire column float value

◆ SetColumnGuid()

void Attr::AttributeTable::SetColumnGuid ( const GuidAttrId & attrId,
const Util::Guid & guid )
private

set entire column to guid value

◆ SetColumnInt()

void Attr::AttributeTable::SetColumnInt ( const IntAttrId & attrId,
int val )
private

set entire column to int value

◆ SetColumnMat4()

void Attr::AttributeTable::SetColumnMat4 ( const Mat4AttrId & attrId,
const Math::mat4 & val )
private

set entire column to mat4 value

◆ SetColumnString()

void Attr::AttributeTable::SetColumnString ( const StringAttrId & attrId,
const Util::String & val )
private

set entire column to string value

◆ SetColumnToDefaultValues()

void Attr::AttributeTable::SetColumnToDefaultValues ( IndexT colIndex)
private

set entire column to its default values

This sets all attributes in a column to its default values.

◆ SetColumnVec4()

void Attr::AttributeTable::SetColumnVec4 ( const Vec4AttrId & attrId,
const Math::vec4 & val )
private

set entire column vec4 value

◆ SetFloat() [1/2]

void Attr::AttributeTable::SetFloat ( const FloatAttrId & colAttrId,
IndexT rowIndex,
float val )
inline

set float value

◆ SetFloat() [2/2]

void Attr::AttributeTable::SetFloat ( IndexT colIndex,
IndexT rowIndex,
float val )
inline

set float value by column index

◆ SetGuid() [1/2]

void Attr::AttributeTable::SetGuid ( const GuidAttrId & colAttrId,
IndexT rowIndex,
const Util::Guid & guid )
inline

set guid value

◆ SetGuid() [2/2]

void Attr::AttributeTable::SetGuid ( IndexT colIndex,
IndexT rowIndex,
const Util::Guid & guid )
inline

set guid value by column index

◆ SetInt() [1/2]

void Attr::AttributeTable::SetInt ( const IntAttrId & colAttrId,
IndexT rowIndex,
int val )
inline

set int value

◆ SetInt() [2/2]

void Attr::AttributeTable::SetInt ( IndexT colIndex,
IndexT rowIndex,
int val )
inline

set int value by column index

◆ SetMat4() [1/2]

void Attr::AttributeTable::SetMat4 ( const Mat4AttrId & colAttrId,
IndexT rowIndex,
const Math::mat4 & val )
inline

set mat4 value

◆ SetMat4() [2/2]

void Attr::AttributeTable::SetMat4 ( IndexT colIndex,
IndexT rowIndex,
const Math::mat4 & val )
inline

set mat4 value by column index

◆ SetModifiedTracking()

void Attr::AttributeTable::SetModifiedTracking ( bool b)
inline

enable/disable modified tracking (default is on)

◆ SetRowToDefaultValues()

void Attr::AttributeTable::SetRowToDefaultValues ( IndexT rowIndex)
private

set a row to its default values

This sets all attributes in a row to its default values.

◆ SetRowUserData()

void Attr::AttributeTable::SetRowUserData ( IndexT rowIndex,
void * p )

set an optional row user data pointer

◆ SetString() [1/2]

void Attr::AttributeTable::SetString ( const StringAttrId & colAttrId,
IndexT rowIndex,
const Util::String & val )
inline

set string value

◆ SetString() [2/2]

void Attr::AttributeTable::SetString ( IndexT colIndex,
IndexT rowIndex,
const Util::String & val )
inline

set string value by column index

◆ SetUInt()

void Attr::AttributeTable::SetUInt ( IndexT colIndex,
IndexT rowIndex,
uint val )
inline

set uint value by column index

◆ SetVariant() [1/2]

void Attr::AttributeTable::SetVariant ( const Attr::AttrId & attrId,
IndexT rowIndex,
const Util::Variant & val )

set variant value

◆ SetVariant() [2/2]

void Attr::AttributeTable::SetVariant ( IndexT colIndex,
IndexT rowIndex,
const Util::Variant & val )

set variant value

◆ SetVec4() [1/2]

void Attr::AttributeTable::SetVec4 ( const Vec4AttrId & colAttrId,
IndexT rowIndex,
const Math::vec4 & val )
inline

set float4 value

◆ SetVec4() [2/2]

void Attr::AttributeTable::SetVec4 ( IndexT colIndex,
IndexT rowIndex,
const Math::vec4 & val )
inline

set float4 value by column index

◆ UpdateColumnOffsets()

SizeT Attr::AttributeTable::UpdateColumnOffsets ( )
private

update the column byte offset and return new pitch

This updates the byte offsets for the current column configuration.

Member Data Documentation

◆ addColumnsRecordAsNewColumns

bool Attr::AttributeTable::addColumnsRecordAsNewColumns
private

◆ allocatedRows

SizeT Attr::AttributeTable::allocatedRows
private

◆ columns

Util::Array<ColumnInfo> Attr::AttributeTable::columns
private

◆ deletedRowIndices

Util::Array<IndexT> Attr::AttributeTable::deletedRowIndices
private

◆ firstNewColumnIndex

IndexT Attr::AttributeTable::firstNewColumnIndex
private

◆ inBeginAddColumns

bool Attr::AttributeTable::inBeginAddColumns
private

◆ indexMap

Util::Dictionary<AttrId,IndexT> Attr::AttributeTable::indexMap
private

◆ isModified

bool Attr::AttributeTable::isModified
private

◆ newColumnIndices

Util::Array<IndexT> Attr::AttributeTable::newColumnIndices
private

◆ newRowIndices

Util::Array<IndexT> Attr::AttributeTable::newRowIndices
private

◆ numRows

SizeT Attr::AttributeTable::numRows
private

◆ readWriteColumnIndices

Util::Array<IndexT> Attr::AttributeTable::readWriteColumnIndices
private

◆ rowDeletedBuffer

uchar* Attr::AttributeTable::rowDeletedBuffer
private

◆ rowModifiedBuffer

uchar* Attr::AttributeTable::rowModifiedBuffer
private

◆ rowNewBuffer

uchar* Attr::AttributeTable::rowNewBuffer
private

◆ rowPitch

SizeT Attr::AttributeTable::rowPitch
private

◆ rowsModified

bool Attr::AttributeTable::rowsModified
private

◆ trackModifications

bool Attr::AttributeTable::trackModifications
private

◆ userData

Util::Array<void*> Attr::AttributeTable::userData
private

◆ valueBuffer

void* Attr::AttributeTable::valueBuffer
private

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