libtgd 4.2
A library that makes working with multidimensional arrays in C++ easy
List of all members
TGD::ArrayDescription Class Reference

The ArrayDescription manages array metadata. More...

#include <array.hpp>

Inherited by TGD::ArrayContainer.

Public Member Functions

Constructors / Destructor
 ArrayDescription ()
 Constructor for an empty array description. More...
 
 ArrayDescription (const std::vector< size_t > &dimensions, size_t componentCount, Type componentType)
 Constructor for an array description. More...
 
 ArrayDescription (const ArrayDescription &descr, Type type)
 Constructor for an array description. More...
 
Access to array data specifications.
size_t dimensionCount () const
 Returns the number of dimensions. More...
 
size_t dimension (size_t d) const
 Returns the size of dimension d. More...
 
const std::vector< size_t > & dimensions () const
 Returns the list of dimensions. More...
 
size_t componentCount () const
 Returns the number of components in each element. More...
 
Type componentType () const
 Returns the type represented by each element component. More...
 
size_t componentSize () const
 Returns the size of a component. More...
 
size_t elementSize () const
 Returns the size of an element. More...
 
size_t elementCount () const
 Returns the number of elements in the array. More...
 
size_t dataSize () const
 Returns the total data size. More...
 
bool isCompatible (const ArrayDescription &a) const
 Returns whether the dimensions and components of array match those of this array. More...
 
const ArrayDescriptiondescription () const
 Returns this as a description. This is useful for derived classes. More...
 
Index management
size_t toLinearIndex (const std::vector< size_t > &elementIndex) const
 Convert the given multidimensional element index to a linear element index. For example, for a 800x600 array, the multidimensional index { 1, 1 } is converted to linear index 601. More...
 
size_t toLinearIndex (const std::initializer_list< size_t > &elementIndex) const
 Convert the given multidimensional element index to a linear element index. For example, for a 800x600 array, the multidimensional index { 1, 1 } is converted to linear index 601. More...
 
void toVectorIndex (size_t elementIndex, size_t *vectorIndex) const
 Convert the given linear element index to a multidimensional index. For example, for a 800x600 array, the linear index 601 is converted to the multidimensional index { 1, 1 }. More...
 
size_t elementOffset (size_t elementIndex) const
 Returns the offset of the element with index elementIndex within the data. More...
 
size_t elementOffset (const std::vector< size_t > &elementIndex) const
 Returns the offset of the element with index elementIndex within the data. More...
 
size_t elementOffset (const std::initializer_list< size_t > &elementIndex) const
 Returns the offset of the element with index elementIndex within the data. More...
 
size_t componentOffset (size_t componentIndex) const
 Returns the offset of the component with index componentIndex within an array element. More...
 
size_t componentOffset (size_t elementIndex, size_t componentIndex) const
 Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element. More...
 
size_t componentOffset (const std::vector< size_t > &elementIndex, size_t componentIndex) const
 Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element. More...
 
size_t componentOffset (const std::initializer_list< size_t > &elementIndex, size_t componentIndex) const
 Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element. More...
 
Metadata management
const TagListglobalTagList () const
 Returns the global tag list. More...
 
TagListglobalTagList ()
 Returns the global tag list. More...
 
const TagListdimensionTagList (size_t d) const
 Returns the tag list for dimension d. More...
 
TagListdimensionTagList (size_t d)
 Returns the tag list for dimension d. More...
 
const TagListcomponentTagList (size_t c) const
 Returns the tag list for component c. More...
 
TagListcomponentTagList (size_t c)
 Returns the tag list for component c. More...
 

Detailed Description

The ArrayDescription manages array metadata.

Constructor & Destructor Documentation

◆ ArrayDescription() [1/3]

TGD::ArrayDescription::ArrayDescription ( )
inline

Constructor for an empty array description.

◆ ArrayDescription() [2/3]

TGD::ArrayDescription::ArrayDescription ( const std::vector< size_t > &  dimensions,
size_t  componentCount,
Type  componentType 
)
inline

Constructor for an array description.

Parameters
dimensionsList of sizes, defining both the number of dimensions and the array size.
componentCountNumber of components in one array element
componentTypeData type of the components

The array dimensions and the type and number of the element components must be specified. For example, for an image with 800x600 RGB pixels one might construct the following array: Array image({ 800, 600}, 3, uint8);

◆ ArrayDescription() [3/3]

TGD::ArrayDescription::ArrayDescription ( const ArrayDescription descr,
Type  type 
)
inlineexplicit

Constructor for an array description.

Parameters
descrExisting array description
typeNew type

Constructs an array description that is a copy of the given description except that it has the given new type.

Member Function Documentation

◆ componentCount()

size_t TGD::ArrayDescription::componentCount ( ) const
inline

Returns the number of components in each element.

◆ componentOffset() [1/4]

size_t TGD::ArrayDescription::componentOffset ( const std::initializer_list< size_t > &  elementIndex,
size_t  componentIndex 
) const
inline

Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element.

◆ componentOffset() [2/4]

size_t TGD::ArrayDescription::componentOffset ( const std::vector< size_t > &  elementIndex,
size_t  componentIndex 
) const
inline

Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element.

◆ componentOffset() [3/4]

size_t TGD::ArrayDescription::componentOffset ( size_t  componentIndex) const
inline

Returns the offset of the component with index componentIndex within an array element.

◆ componentOffset() [4/4]

size_t TGD::ArrayDescription::componentOffset ( size_t  elementIndex,
size_t  componentIndex 
) const
inline

Returns the offset of the component with index componentIndex in the element with index elementIndex within an array element.

◆ componentSize()

size_t TGD::ArrayDescription::componentSize ( ) const
inline

Returns the size of a component.

◆ componentTagList() [1/2]

TagList & TGD::ArrayDescription::componentTagList ( size_t  c)
inline

Returns the tag list for component c.

◆ componentTagList() [2/2]

const TagList & TGD::ArrayDescription::componentTagList ( size_t  c) const
inline

Returns the tag list for component c.

◆ componentType()

Type TGD::ArrayDescription::componentType ( ) const
inline

Returns the type represented by each element component.

◆ dataSize()

size_t TGD::ArrayDescription::dataSize ( ) const
inline

Returns the total data size.

◆ description()

const ArrayDescription & TGD::ArrayDescription::description ( ) const
inline

Returns this as a description. This is useful for derived classes.

◆ dimension()

size_t TGD::ArrayDescription::dimension ( size_t  d) const
inline

Returns the size of dimension d.

◆ dimensionCount()

size_t TGD::ArrayDescription::dimensionCount ( ) const
inline

Returns the number of dimensions.

◆ dimensions()

const std::vector< size_t > & TGD::ArrayDescription::dimensions ( ) const
inline

Returns the list of dimensions.

◆ dimensionTagList() [1/2]

TagList & TGD::ArrayDescription::dimensionTagList ( size_t  d)
inline

Returns the tag list for dimension d.

◆ dimensionTagList() [2/2]

const TagList & TGD::ArrayDescription::dimensionTagList ( size_t  d) const
inline

Returns the tag list for dimension d.

◆ elementCount()

size_t TGD::ArrayDescription::elementCount ( ) const
inline

Returns the number of elements in the array.

◆ elementOffset() [1/3]

size_t TGD::ArrayDescription::elementOffset ( const std::initializer_list< size_t > &  elementIndex) const
inline

Returns the offset of the element with index elementIndex within the data.

◆ elementOffset() [2/3]

size_t TGD::ArrayDescription::elementOffset ( const std::vector< size_t > &  elementIndex) const
inline

Returns the offset of the element with index elementIndex within the data.

◆ elementOffset() [3/3]

size_t TGD::ArrayDescription::elementOffset ( size_t  elementIndex) const
inline

Returns the offset of the element with index elementIndex within the data.

◆ elementSize()

size_t TGD::ArrayDescription::elementSize ( ) const
inline

Returns the size of an element.

◆ globalTagList() [1/2]

TagList & TGD::ArrayDescription::globalTagList ( )
inline

Returns the global tag list.

◆ globalTagList() [2/2]

const TagList & TGD::ArrayDescription::globalTagList ( ) const
inline

Returns the global tag list.

◆ isCompatible()

bool TGD::ArrayDescription::isCompatible ( const ArrayDescription a) const
inline

Returns whether the dimensions and components of array match those of this array.

◆ toLinearIndex() [1/2]

size_t TGD::ArrayDescription::toLinearIndex ( const std::initializer_list< size_t > &  elementIndex) const
inline

Convert the given multidimensional element index to a linear element index. For example, for a 800x600 array, the multidimensional index { 1, 1 } is converted to linear index 601.

◆ toLinearIndex() [2/2]

size_t TGD::ArrayDescription::toLinearIndex ( const std::vector< size_t > &  elementIndex) const
inline

Convert the given multidimensional element index to a linear element index. For example, for a 800x600 array, the multidimensional index { 1, 1 } is converted to linear index 601.

◆ toVectorIndex()

void TGD::ArrayDescription::toVectorIndex ( size_t  elementIndex,
size_t *  vectorIndex 
) const
inline

Convert the given linear element index to a multidimensional index. For example, for a 800x600 array, the linear index 601 is converted to the multidimensional index { 1, 1 }.


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