GEGELATI

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

`#include <arrayWrapper.h>`

Inheritance diagram for Data::ArrayWrapper< T >:

## Public Member Functions
| 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 DataHandler * | clone () const override
| Return a PrimitiveTypeArray<T> where all data of the ArrayWrapper has been copied.
virtual bool | canHandle (const std::type_info &type) const override
| Inherited from DataHandler.
virtual size_t | getAddressSpace (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 UntypedSharedPtr | getDataAt (const std::type_info &type, const size_t address) 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 const std::type_info & | getNativeType () const override
| Inherited from DataHandler.
virtual std::vector< size_t > | getDimensionsSize () 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
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
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::ArrayWrapper< T >

DataHandler for manipulating arrays of primitive data type.

Contrary to the PrimitiveTypeArray, the ArrayWrapper does not contain its data, but possesses a pointer to them.

Every time the data associated to the pointer is modified, the invalidateCachedHash method should be called.

In addition to native data types T, this DataHandler can also provide the following composite data type:

- T[n]: with $n <=$ to the size of the ArrayWrapper.

## Constructor & Destructor Documentation

## ◆ ArrayWrapper() [1/2]

template<class T >

Data::ArrayWrapper< T >::ArrayWrapper | ( | size_t | size = 8,
|  | std::vector< T > * | ptr = nullptr )
| inline

Constructor for the ArrayWrapper class.

Parameters

  [in] | size | the fixed number of elements of primitive type T contained in the ArrayWrapper.
  [in] | ptr | the pointer managed by the ArrayWrapper.

Exceptions

  std::domain_error | in case the given non-null pointer points to a vector that does not the expected size.

## ◆ ArrayWrapper() [2/2]

template<class T >

Data::ArrayWrapper< T >::ArrayWrapper | ( | const DataHandler & | other,
|  | size_t | size )

Copy constructor for DataHandler.

This constructor ensures the id of the other DataHandler is copied and initialize the ArrayWrapper with a null pointer.

Parameters

  [in] | other | Other DataHandler whose id is copied.
  [in] | size | Number of element of the created ArrayWrapper.

## Member Function Documentation

## ◆ canHandle()

template<class T >

bool Data::ArrayWrapper< T >::canHandle | ( | const std::type_info & | type | ) | const
| overridevirtual

Inherited from DataHandler.

Implements Data::DataHandler.

## ◆ checkAddressAndType()

template<class T >

void Data::ArrayWrapper< T >::checkAddressAndType | ( | const std::type_info & | type,
|  | const size_t & | address ) const
| protected

Check whether the given type of data can be accessed at the given address. Throws exception otherwise.

Parameters

  [in] | type | the std::type_info of data.
  [in] | address | the location of the data.

Exceptions

  std::invalid_argument | if the given data type is not provided by the DataHandler.
  std::out_of_range | if the given address is invalid for the given data type.

## ◆ clone()

template<class T >

DataHandler * Data::ArrayWrapper< T >::clone | ( |  | ) | const
| inlineoverridevirtual

Return a PrimitiveTypeArray<T> where all data of the ArrayWrapper has been copied.

Returns
  a PrimitiveTypeArray.

Implements Data::DataHandler.

Reimplemented in Data::Array2DWrapper< T >, Data::PrimitiveTypeArray< T >, Data::PrimitiveTypeArray< Constant >, Data::PrimitiveTypeArray< double >, and Data::PrimitiveTypeArray2D< T >.

## ◆ getAddressesAccessed()

template<class T >

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

Inherited from DataHandler.

Implements Data::DataHandler.

Reimplemented in Data::Array2DWrapper< T >.

## ◆ getAddressSpace()

template<class T >

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

Inherited from DataHandler.

Implements Data::DataHandler.

Reimplemented in Data::Array2DWrapper< T >.

## ◆ getDataAt()

template<class T >

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

Inherited from DataHandler.

Implements Data::DataHandler.

Reimplemented in Data::Array2DWrapper< T >.

## ◆ getDimensionsSize()

template<class T >

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

Inherited from DataHandler.

Implements Data::DataHandler.

Reimplemented in Data::Array2DWrapper< T >.

## ◆ getLargestAddressSpace()

template<class T >

size_t Data::ArrayWrapper< T >::getLargestAddressSpace | ( | void |  | ) | const
| overridevirtual

Inherited from DataHandler.

Implements Data::DataHandler.

## ◆ getNativeType()

template<class T >

const std::type_info & Data::ArrayWrapper< T >::getNativeType | ( |  | ) | const
| overridevirtual

Inherited from DataHandler.

Implements Data::DataHandler.

## ◆ invalidateCachedHash()

template<class T >

void Data::ArrayWrapper< T >::invalidateCachedHash | ( |  | ) |

Invalidate the hash of the container.

Each time the data pointed by the ArrayWrapper is modified, this method should be called to ensure that the hash value of the DataHandler is properly updated.

## ◆ resetData()

template<class T >

void Data::ArrayWrapper< T >::resetData | ( |  | ) |
| overridevirtual

Inherited from DataHandler. Does nothing.

Implements Data::DataHandler.

Reimplemented in Data::PrimitiveTypeArray< T >, Data::PrimitiveTypeArray< Constant >, Data::PrimitiveTypeArray< double >, and Data::PrimitiveTypeArray2D< T >.

## ◆ setPointer()

template<class T >

void Data::ArrayWrapper< T >::setPointer | ( | std::vector< T > * | ptr | ) |
| inline

Set the pointer of the ArrayWrapper.

This method automatically invalidates the cachedHash.

Parameters

  [in] | ptr | the new pointer managed by the ArrayWrapper.

Exceptions

  std::domain_error | in case the given non-null pointer points to a vector that does not have the same size as defined when constructing the ArrayWrapper.

## ◆ updateHash()

template<class T >

size_t Data::ArrayWrapper< T >::updateHash | ( |  | ) | const
| inlineoverrideprotectedvirtual

Implementation of the updateHash method.

Implements Data::DataHandler.

## Member Data Documentation

## ◆ nbElements

template<class T >

const size_t Data::ArrayWrapper< T >::nbElements
| protected

Number of elements contained pointer vector.

Although this may seem redundant with the containerPtr->size() method, this attribute is here to make it possible to check whether the size of the data vector was modified throughout the lifetime of the ArrayWrapper. (Which should not be possible.)

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

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