37#ifndef ARRAY_2D_WRAPPER_H
38#define ARRAY_2D_WRAPPER_H
40#include "data/arrayWrapper.h"
41#include "data/dataHandler.h"
42#include "data/demangle.h"
85 mutable std::map<std::type_index, std::tuple<size_t, size_t, size_t>>
121 std::vector<T>* ptr =
nullptr);
139 const std::type_info& type)
const override;
143 const std::type_info& type,
const size_t address)
const override;
147 const size_t address)
const override;
149#ifdef CODE_GENERATION
173 template <
typename T>
175 const std::type_info&
type,
const size_t address)
const
178 std::vector<size_t> result;
187 if (
type ==
typeid(
T)) {
209 template <
typename T>
216 template <
typename T>
221 auto iter = this->cachedAddressSpace.find(
type);
222 if (
iter != this->cachedAddressSpace.end()) {
223 if (
dim1 !=
nullptr) {
226 if (
dim2 !=
nullptr) {
229 return std::get<0>(
iter->second);
234 if (
type ==
typeid(
T)) {
235 this->cachedAddressSpace.emplace(
245 regex.append(
"\\s*(const\\s*)?\\[([0-9]+)\\](\\[([0-9]+)\\])?");
267 result = (this->
height - typeH + 1) *
268 ((this->width -
typeW + 1));
269 if (
dim1 !=
nullptr) {
272 if (
dim2 !=
nullptr) {
275 this->cachedAddressSpace.emplace(
284 template <
typename T>
293 if (
type ==
typeid(
T)) {
296 UntypedSharedPtr::emptyDestructor<const T>());
327 std::make_shared<UntypedSharedPtr::Model<const T[]>>(
array)};
331#ifdef CODE_GENERATION
343#include "data/primitiveTypeArray2D.h"
DataHandler for 2D arrays of primitive types.
Definition array2DWrapper.h:68
size_t width
Number of columns of the 2D array.
Definition array2DWrapper.h:90
virtual std::vector< size_t > getAddressesAccessed(const std::type_info &type, const size_t address) const override
Inherited from DataHandler.
Definition array2DWrapper.h:174
size_t height
Number of lines of the 2D array.
Definition array2DWrapper.h:93
virtual UntypedSharedPtr getDataAt(const std::type_info &type, const size_t address) const override
Inherited from DataHandler.
Definition array2DWrapper.h:285
virtual ~Array2DWrapper()=default
Default destructor.
size_t getAddressSpace(const std::type_info &type, size_t *dim1, size_t *dim2) const
Utility function for the class.
Definition array2DWrapper.h:217
virtual std::vector< size_t > getDimensionsSize() const override
Inherited from DataHandler.
Definition array2DWrapper.h:333
virtual DataHandler * clone() const override
Return a PrimitiveTypeArray2D<T> where all data of the Array2DWrapper has been copied.
Definition array2DWrapper.h:165
Array2DWrapper(const size_t w=2, const size_t h=4, std::vector< T > *ptr=nullptr)
Constructor for the 2D array.
Definition array2DWrapper.h:156
Array2DWrapper(const Array2DWrapper &other)=default
Default copy constructor.
Definition arrayWrapper.h:69
std::vector< T > * containerPtr
Pointer to the array containing the data accessed through the ArrayWrapper.
Definition arrayWrapper.h:105
const size_t nbElements
Number of elements contained pointer vector.
Definition arrayWrapper.h:99
void checkAddressAndType(const std::type_info &type, const size_t &address) const
Definition arrayWrapper.h:232
Base class for all sources of data to be accessed by a TPG Instruction executed within a Program.
Definition dataHandler.h:56
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
Class behaving as a std::shared_ptr whose type is not templated.
Definition untypedSharedPtr.h:72
Definition array2DWrapper.h:44