36#ifndef POINTER_WRAPPER_H
37#define POINTER_WRAPPER_H
39#include "data/constant.h"
40#include "data/dataHandler.h"
55 static_assert(std::is_fundamental<T>::value ||
56 std::is_same<T, Data::Constant>(),
57 "Template class PrimitiveTypeArray<T> can only be used "
58 "for primitive types.");
103 virtual bool canHandle(
const std::type_info&
type)
const override;
107 const std::type_info&
type)
const override;
113 virtual size_t getHash()
const override;
130 const size_t address)
const override;
134 const std::type_info&
type,
const size_t address)
const override;
136#ifdef CODE_GENERATION
138 virtual const std::type_info&
getNativeType()
const override;
183 if (
typeid(
T) ==
type) {
191 const std::type_info&
type)
const
193 if (
typeid(
T) ==
type) {
220 const std::type_info&
type,
const size_t address)
const
223 throw std::runtime_error(
"Null pointer access.");
231 <<
" cannot be accessed in a "
233 throw std::invalid_argument(
message.str());
239 <<
" cannot be accessed at address " <<
address
240 <<
", address space size is 1.";
241 throw std::out_of_range(
message.str());
246 UntypedSharedPtr::emptyDestructor<const T>());
252 const std::type_info&
type,
const size_t address)
const
255 std::vector<size_t> result;
261 if (
type ==
typeid(
T)) {
268#ifdef CODE_GENERATION
272 const std::type_info&
a =
typeid(
T);
279 std::vector<size_t>
sizes = {1};
size_t getAddressSpace(const std::type_info &type, size_t *dim1, size_t *dim2) const
Utility function for the class.
Definition array2DWrapper.h:217
std::vector< T > * containerPtr
Pointer to the array containing the data accessed through the ArrayWrapper.
Definition arrayWrapper.h:105
virtual size_t updateHash() const override
Implementation of the updateHash method.
Definition arrayWrapper.h:407
virtual bool canHandle(const std::type_info &type) const override
Inherited from DataHandler.
Definition arrayWrapper.h:221
Base class for all sources of data to be accessed by a TPG Instruction executed within a Program.
Definition dataHandler.h:55
size_t cachedHash
Cached value returned by the getHash() function.
Definition dataHandler.h:78
const size_t id
Identifier of each DataHandler.
Definition dataHandler.h:70
Definition pointerWrapper.h:54
void setPointer(T *ptr)
Set the pointer of the PointerWrapper.
Definition pointerWrapper.h:212
void resetData() override
Inherited from DataHandler. Does nothing.
Definition pointerWrapper.h:207
PointerWrapper(T *ptr=nullptr)
Constructor for the PointerWrapper class.
Definition pointerWrapper.h:80
virtual DataHandler * clone() const override
Return a PrimitiveTypeArray<T> where the data of the PointerWrapper has been copied.
Definition pointerWrapper.h:172
virtual size_t getAddressSpace(const std::type_info &type) const override
Inherited from DataHandler.
Definition pointerWrapper.h:190
virtual std::vector< size_t > getDimensionsSize() const override
Inherited from DataHandler.
Definition pointerWrapper.h:277
virtual const std::type_info & getNativeType() const override
Inherited from DataHandler.
Definition pointerWrapper.h:270
virtual bool canHandle(const std::type_info &type) const override
Inherited from DataHandler.
Definition pointerWrapper.h:181
PointerWrapper(const PointerWrapper< T > &other)=default
Default copy constructor.
virtual size_t getHash() const override
Inherited from DataHandler.
Definition pointerWrapper.h:145
virtual std::vector< size_t > getAddressesAccessed(const std::type_info &type, const size_t address) const override
Inherited from DataHandler.
Definition pointerWrapper.h:251
virtual size_t getLargestAddressSpace(void) const override
Inherited from DataHandler.
Definition pointerWrapper.h:202
virtual size_t updateHash() const override
Implementation of the updateHash method.
Definition pointerWrapper.h:150
virtual ~PointerWrapper()=default
Default destructor.
virtual UntypedSharedPtr getDataAt(const std::type_info &type, const size_t address) const override
Inherited from DataHandler.
Definition pointerWrapper.h:219
T * containerPtr
Pointer to the data accessed through the PointerWrapper.
Definition pointerWrapper.h:64
DataHandler for 2D arrays of primitive types.
Definition primitiveTypeArray2D.h:69
PrimitiveTypeArray2D(const size_t w=2, const size_t h=4)
Constructor for the 2D array.
Definition primitiveTypeArray2D.h:142
Definition primitiveTypeArray.h:55
Class behaving as a std::shared_ptr whose type is not templated.
Definition untypedSharedPtr.h:72
Definition array2DWrapper.h:44