GEGELATI
|
#include <arrayWrapper.h>
Public Member Functions | |
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 DataHandler * | clone () 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... | |
![]() | |
DataHandler () | |
Default constructor of the DataHandler class. | |
virtual | ~DataHandler ()=default |
Default destructor. | |
DataHandler (const DataHandler &other)=default | |
Default copy constructor. | |
virtual DataHandler * | clone () 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 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. More... | |
virtual size_t | updateHash () const =0 |
Update the cachedHash value. More... | |
Protected Attributes | |
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. | |
![]() | |
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 | |
![]() | |
static size_t | count = 0 |
Static count used to initialize the id of each DataHandler. More... | |
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:
|
inline |
Constructor for the ArrayWrapper class.
[in] | size | the fixed number of elements of primitive type T contained in the ArrayWrapper. |
[in] | ptr | the pointer managed by the ArrayWrapper. |
std::domain_error | in case the given non-null pointer points to a vector that does not the expected size. |
|
overridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
|
protected |
Check whether the given type of data can be accessed at the given address. Throws exception otherwise.
[in] | type | the std::type_info of data. |
[in] | address | the location of the data. |
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. |
|
inlineoverridevirtual |
Return a PrimitiveTypeArray<T> where all data of the ArrayWrapper has been copied.
Implements Data::DataHandler.
Reimplemented in Data::Array2DWrapper< T >, Data::PrimitiveTypeArray< T >, Data::PrimitiveTypeArray< Constant >, Data::PrimitiveTypeArray< double >, and Data::PrimitiveTypeArray2D< T >.
|
overridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
Reimplemented in Data::Array2DWrapper< T >.
|
overridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
Reimplemented in Data::Array2DWrapper< T >.
|
inlineoverridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
Reimplemented in Data::Array2DWrapper< T >.
|
overridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
Reimplemented in Data::Array2DWrapper< T >.
|
overridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
|
overridevirtual |
Inherited from DataHandler.
Implements Data::DataHandler.
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.
|
overridevirtual |
Inherited from DataHandler. Does nothing.
Implements Data::DataHandler.
Reimplemented in Data::PrimitiveTypeArray< T >, Data::PrimitiveTypeArray< Constant >, Data::PrimitiveTypeArray< double >, and Data::PrimitiveTypeArray2D< T >.
|
inline |
Set the pointer of the ArrayWrapper.
This method automatically invalidates the cachedHash.
[in] | ptr | the new pointer managed by the ArrayWrapper. |
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. |
|
inlineoverrideprotectedvirtual |
Implementation of the updateHash method.
Implements Data::DataHandler.
|
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.)