GEGELATI

Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Data::Array2DWrapper< T > Class Template Reference

DataHandler for 2D arrays of primitive types. More...

`#include <array2DWrapper.h>`

Inheritance diagram for Data::Array2DWrapper< T >:

## Public Member Functions
| Array2DWrapper (const size_t w=2, const size_t h=4, std::vector< T > *ptr=nullptr)
| Constructor for the 2D array.
| Array2DWrapper (const Array2DWrapper &other)=default
| Default copy constructor.
virtual | ~Array2DWrapper ()=default
| Default destructor.
virtual DataHandler * | clone () const override
| Return a PrimitiveTypeArray2D<T> where all data of the Array2DWrapper has been copied.
virtual size_t | getAddressSpace (const std::type_info &type) const override
| Inherited from DataHandler.
virtual std::vector< size_t > | getAddressesAccessed (const std::type_info &type, const size_t address) const override
| Inherited from DataHandler.
virtual UntypedSharedPtr | getDataAt (const std::type_info &type, const size_t address) const override
| Inherited from DataHandler.
virtual std::vector< size_t > | getDimensionsSize () const override
| Inherited from DataHandler.
Public Member Functions inherited from Data::ArrayWrapper< T >
| ArrayWrapper (size_t size=8, std::vector< T > *ptr=nullptr)
| Constructor for the ArrayWrapper class.
virtual | ~ArrayWrapper ()=default
| Default destructor.
| ArrayWrapper (const ArrayWrapper< T > &other)=default
| Default copy constructor.
| ArrayWrapper (const DataHandler &other, size_t size)
| Copy constructor for DataHandler.
virtual bool | canHandle (const std::type_info &type) const override
| Inherited from DataHandler.
virtual size_t | getLargestAddressSpace (void) const override
| Inherited from DataHandler.
void | invalidateCachedHash ()
| Invalidate the hash of the container.
void | resetData () override
| Inherited from DataHandler. Does nothing.
void | setPointer (std::vector< T > *ptr)
| Set the pointer of the ArrayWrapper.
virtual const std::type_info & | getNativeType () const override
| Inherited from DataHandler.
Public Member Functions inherited from Data::DataHandler
| DataHandler ()
| Default constructor of the DataHandler class.
virtual | ~DataHandler ()=default
| Default destructor.
| DataHandler (const DataHandler &other)=default
| Default copy constructor.
size_t | getId () const
| Get the ID of the DataHandler.
virtual size_t | getHash () const
| Get the current value of the hash for this DataHandler.
uint64_t | scaleLocation (const uint64_t rawLocation, const std::type_info &type) const
| Scale a location from the Environment largestAddressSpace to the largestAddressSpace of the dataHandler, for the given data type.

## Protected Member Functions
size_t | getAddressSpace (const std::type_info &type, size_t *dim1, size_t *dim2) const
| Utility function for the class.
Protected Member Functions inherited from Data::ArrayWrapper< T >
void | checkAddressAndType (const std::type_info &type, const size_t &address) const
virtual size_t | updateHash () const override
| Implementation of the updateHash method.

## Protected Attributes
size_t | width
| Number of columns of the 2D array.
size_t | height
| Number of lines of the 2D array.
Protected Attributes inherited from Data::ArrayWrapper< T >
const size_t | nbElements
| Number of elements contained pointer vector.
std::vector< T > * | containerPtr
| Pointer to the array containing the data accessed through the ArrayWrapper.
Protected Attributes inherited from Data::DataHandler
const size_t | id
| Identifier of each DataHandler.
size_t | cachedHash
| Cached value returned by the getHash() function.
bool | invalidCachedHash
| Boolean value indicating whether the current cachedValue is valid, or not.

## Additional Inherited Members
Static Protected Attributes inherited from Data::DataHandler
static size_t | count = 0
| Static count used to initialize the id of each DataHandler.

## Detailed Description

template<class T>
class Data::Array2DWrapper< T >

DataHandler for 2D arrays of primitive types.

This specialization of the ArrayWrapper template class provides the possibility to get data with the type:

- T: The primitive type.
- T[n][m]: with $n <= height$ and $m <= width$ of the Array2DWrapper.
- T[n]: with $n <= width$ of the Array2DWrapper.

It is important to note that only spatially coherent values will be returned when arrays are requested. For example, when requesting a 1D array of N pixels, the returned pixels will always be taken from a single line of pixels, and will never comprise the last pixel from a line i, and the first pixels from line i+1. This means that the addressable space for arrays will be less than a 1D ArrayWrapper with the same number of nbElements.

Like with the ArrayWrapper, every time the data associated to the pointer is modified, the invalidateCachedHash method should be called.

## Constructor & Destructor Documentation

## ◆ Array2DWrapper()

template<class T >

Data::Array2DWrapper< T >::Array2DWrapper | ( | const size_t | w = 2,
|  | const size_t | h = 4,
|  | std::vector< T > * | ptr = nullptr )
| inline

Constructor for the 2D array.

The size of the underlying ArrayWrapper will be $nbElements = h*w$.

Parameters

  [in] | w | The width of the 2D array.
  [in] | h | The height of the 2D array.
  [in] | ptr | the pointer managed by the Array2DWrapper.

## Member Function Documentation

## ◆ clone()

template<class T >

DataHandler * Data::Array2DWrapper< T >::clone | ( |  | ) | const
| overridevirtual

Return a PrimitiveTypeArray2D<T> where all data of the Array2DWrapper has been copied.

Returns
  a PrimitiveTypeArray2D.

Reimplemented from Data::ArrayWrapper< T >.

Reimplemented in Data::PrimitiveTypeArray2D< T >.

## ◆ getAddressesAccessed()

template<typename T >

std::vector< size_t > Data::Array2DWrapper< T >::getAddressesAccessed | ( | const std::type_info & | type,
|  | const size_t | address ) const
| overridevirtual

Inherited from DataHandler.

Reimplemented from Data::ArrayWrapper< T >.

## ◆ getAddressSpace() [1/2]

template<typename T >

size_t Data::Array2DWrapper< T >::getAddressSpace | ( | const std::type_info & | type | ) | const
| overridevirtual

Inherited from DataHandler.

Reimplemented from Data::ArrayWrapper< T >.

## ◆ getAddressSpace() [2/2]

template<typename T >

size_t Data::Array2DWrapper< T >::getAddressSpace | ( | const std::type_info & | type,
|  | size_t * | dim1,
|  | size_t * | dim2 ) const
| protected

Utility function for the class.

This method implements the getAddressSpace method, with additional arguments that are used to return the number of array dimensions of the requested type.

Parameters

  [in] | type | The requested type_info.
  [out] | dim1 | Size of the 1st dimension (if any).
  [out] | dim2 | Size of the 2st dimension (if any).

## ◆ getDataAt()

template<typename T >

UntypedSharedPtr Data::Array2DWrapper< T >::getDataAt | ( | const std::type_info & | type,
|  | const size_t | address ) const
| overridevirtual

Inherited from DataHandler.

Reimplemented from Data::ArrayWrapper< T >.

## ◆ getDimensionsSize()

template<class T >

std::vector< size_t > Data::Array2DWrapper< T >::getDimensionsSize | ( |  | ) | const
| overridevirtual

Inherited from DataHandler.

Reimplemented from Data::ArrayWrapper< T >.

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

- D:/a/gegelati/gegelati/gegelatilib/include/data/array2DWrapper.h