GEGELATI
Public Member Functions | Protected Attributes | List of all members
Data::PrimitiveTypeArray2D< T > Class Template Reference

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

#include <primitiveTypeArray2D.h>

Inheritance diagram for Data::PrimitiveTypeArray2D< T >:
Data::Array2DWrapper< T > Data::ArrayWrapper< T > Data::DataHandler

Public Member Functions

 PrimitiveTypeArray2D (const size_t w=2, const size_t h=4)
 Constructor for the 2D array. More...
 
 PrimitiveTypeArray2D (const PrimitiveTypeArray2D< T > &other)
 Copy constructor.
 
 PrimitiveTypeArray2D (const Array2DWrapper< T > &other)
 Copy content from an Array2DWrapper.
 
virtual DataHandlerclone () const override
 Inherited from DataHandler. More...
 
void resetData () override
 Sets all elements of the Array to 0 (or its equivalent for the given template param.) More...
 
void setDataAt (const std::type_info &type, const size_t address, const T &value)
 Set the data at the given address to the given value. More...
 
PrimitiveTypeArray2D< T > & operator= (const PrimitiveTypeArray2D< T > &other)
 Assignement Operator for PrimitiveTypeArray2D<T> More...
 
- Public Member Functions inherited from Data::Array2DWrapper< T >
 Array2DWrapper (const size_t w=2, const size_t h=4, std::vector< T > *ptr=nullptr)
 Constructor for the 2D array. More...
 
 Array2DWrapper (const Array2DWrapper &other)=default
 Default copy constructor.
 
virtual ~Array2DWrapper ()=default
 Default destructor.
 
virtual DataHandlerclone () const override
 Return a PrimitiveTypeArray2D<T> where all data of the Array2DWrapper has been copied. More...
 
virtual size_t getAddressSpace (const std::type_info &type) const override
 Inherited from DataHandler. More...
 
virtual std::vector< size_t > getAddressesAccessed (const std::type_info &type, const size_t address) const override
 Inherited from DataHandler. More...
 
virtual UntypedSharedPtr getDataAt (const std::type_info &type, const size_t address) const override
 Inherited from DataHandler. More...
 
virtual std::vector< size_t > getDimensionsSize () const override
 Inherited from DataHandler. More...
 
- Public Member Functions inherited from Data::ArrayWrapper< T >
 ArrayWrapper (size_t size=8, std::vector< T > *ptr=nullptr)
 Constructor for the ArrayWrapper class. More...
 
virtual ~ArrayWrapper ()=default
 Default destructor.
 
 ArrayWrapper (const ArrayWrapper< T > &other)=default
 Default copy constructor.
 
virtual DataHandlerclone () const override
 Return a PrimitiveTypeArray<T> where all data of the ArrayWrapper has been copied. More...
 
virtual bool canHandle (const std::type_info &type) const override
 Inherited from DataHandler. More...
 
virtual size_t getAddressSpace (const std::type_info &type) const override
 Inherited from DataHandler. More...
 
virtual size_t getLargestAddressSpace (void) const override
 Inherited from DataHandler. More...
 
void invalidateCachedHash ()
 Invalidate the hash of the container. More...
 
void resetData () override
 Inherited from DataHandler. Does nothing. More...
 
void setPointer (std::vector< T > *ptr)
 Set the pointer of the ArrayWrapper. More...
 
virtual UntypedSharedPtr getDataAt (const std::type_info &type, const size_t address) const override
 Inherited from DataHandler. More...
 
virtual std::vector< size_t > getAddressesAccessed (const std::type_info &type, const size_t address) const override
 Inherited from DataHandler. More...
 
virtual const std::type_info & getNativeType () const override
 Inherited from DataHandler. More...
 
virtual std::vector< size_t > getDimensionsSize () const override
 Inherited from DataHandler. More...
 
- 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.
 
virtual DataHandlerclone () const =0
 Return a copy of the DataHandler (with all its content). More...
 
size_t getId () const
 Get the ID of the DataHandler. More...
 
size_t getHash () const
 Get the current value of the hash for this DataHandler. More...
 
virtual bool canHandle (const std::type_info &type) const =0
 Check a given DataHandler can handle data for the given data type. More...
 
virtual size_t getAddressSpace (const std::type_info &type) const =0
 Get the getAddressSpace size for the given data type. More...
 
virtual size_t getLargestAddressSpace () const =0
 Get the largest AddressSpace for all data types handled by the DataHandler. More...
 
virtual void resetData ()=0
 Generic method for DataHandler to reset their data. More...
 
virtual UntypedSharedPtr getDataAt (const std::type_info &type, const size_t address) const =0
 Get data of the given type, from the given address. More...
 
virtual std::vector< size_t > getAddressesAccessed (const std::type_info &type, const size_t address) const =0
 Get the set of addresses actually used when getting the given type of data, at the given address. More...
 
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. More...
 
virtual const std::type_info & getNativeType () const =0
 Function returning the native type of the DataHandler. More...
 
virtual std::vector< size_t > getDimensionsSize () const =0
 Give the size of each dimension (if any) of the DataHandler. More...
 

Protected Attributes

std::vector< T > data
 Array storing the data of the PrimitiveTypeArray2D.
 
- Protected Attributes inherited from Data::Array2DWrapper< T >
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. More...
 
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. More...
 
size_t cachedHash
 Cached value returned by the getHash() function. More...
 
bool invalidCachedHash
 Boolean value indicating whether the current cachedValue is valid, or not. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Data::Array2DWrapper< T >
size_t getAddressSpace (const std::type_info &type, size_t *dim1, size_t *dim2) const
 Utility function for the class. More...
 
- 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. More...
 
virtual size_t updateHash () const =0
 Update the cachedHash value. More...
 
- Static Protected Attributes inherited from Data::DataHandler
static size_t count = 0
 Static count used to initialize the id of each DataHandler. More...
 

Detailed Description

template<typename T>
class Data::PrimitiveTypeArray2D< T >

DataHandler for 2D arrays of primitive types.

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

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 PrimitiveDataArray with the same number of nbElements.

Constructor & Destructor Documentation

◆ PrimitiveTypeArray2D()

template<typename T >
Data::PrimitiveTypeArray2D< T >::PrimitiveTypeArray2D ( const size_t  w = 2,
const size_t  h = 4 
)
inline

Constructor for the 2D array.

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

Parameters
[in]wThe width of the 2D array.
[in]hThe height of the 2D array.

Member Function Documentation

◆ clone()

template<typename T >
DataHandler * Data::PrimitiveTypeArray2D< T >::clone
inlineoverridevirtual

Inherited from DataHandler.

Reimplemented from Data::Array2DWrapper< T >.

◆ operator=()

template<class T >
PrimitiveTypeArray2D< T > & Data::PrimitiveTypeArray2D< T >::operator= ( const PrimitiveTypeArray2D< T > &  other)

Assignement Operator for PrimitiveTypeArray2D<T>

Copy nbElements and data from the right side argument to the left side argument

Parameters
[in]otherthe left side argument, to be assigned to the right side argument.
Returns
the assigned PrimitiveTypeArray2D
Exceptions
std::domain_errorif both arguents do not have the same size, which implies that assignement cannot be successfull.

◆ resetData()

template<class T >
void Data::PrimitiveTypeArray2D< T >::resetData
overridevirtual

Sets all elements of the Array to 0 (or its equivalent for the given template param.)

Reimplemented from Data::ArrayWrapper< T >.

◆ setDataAt()

template<class T >
void Data::PrimitiveTypeArray2D< T >::setDataAt ( const std::type_info &  type,
const size_t  address,
const T &  value 
)

Set the data at the given address to the given value.

This method is not (yet) part of the DataHandler class as for now, the TPG engine does not need to update data of DataHandler, except for the one used as registers, which are managed with a PrimitiveTypeArray<double>.

Invalidates the cache.

Parameters
[in]typethe std::type_info of data set.
[in]addressthe location of the data to set.
[in]valuea const reference to the PrimitiveType holding a value of the data to write in the current PrimitiveTypeArray
Exceptions
std::invalid_argumentif the given data type is not handled by the DataHandler.
std::out_of_rangeif the given address is invalid for the given data type.

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