GEGELATI
Loading...
Searching...
No Matches
dataHandler.h
1
38#ifndef DATA_HANDLER_H
39#define DATA_HANDLER_H
40
41#include <cstdint>
42#include <functional>
43#include <memory>
44#include <typeinfo>
45#include <vector>
46
47#include "data/untypedSharedPtr.h"
48
49namespace Data {
55 {
56
57 protected:
61 static size_t count;
62
70 const size_t id;
71
78 mutable size_t cachedHash;
79
90 mutable bool invalidCachedHash;
91
100 virtual size_t updateHash() const = 0;
101
102 public:
106 DataHandler();
107
109 virtual ~DataHandler() = default;
110
114 DataHandler(const DataHandler& other) = default;
115
125 virtual DataHandler* clone() const = 0;
126
136 size_t getId() const;
137
146 virtual size_t getHash() const;
147
156 virtual bool canHandle(const std::type_info& type) const = 0;
157
170 virtual size_t getAddressSpace(const std::type_info& type) const = 0;
171
180 virtual size_t getLargestAddressSpace() const = 0;
181
192 virtual void resetData() = 0;
193
217 virtual UntypedSharedPtr getDataAt(const std::type_info& type,
218 const size_t address) const = 0;
219
241 virtual std::vector<size_t> getAddressesAccessed(
242 const std::type_info& type, const size_t address) const = 0;
243
263 const std::type_info& type) const;
264
265#ifdef CODE_GENERATION
277 virtual const std::type_info& getNativeType() const = 0;
278
295 virtual std::vector<size_t> getDimensionsSize() const = 0;
296#endif
297 };
298} // namespace Data
299
300#endif
Base class for all sources of data to be accessed by a TPG Instruction executed within a Program.
Definition dataHandler.h:55
size_t getId() const
Get the ID of the DataHandler.
Definition dataHandler.cpp:47
virtual ~DataHandler()=default
Default destructor.
virtual const std::type_info & getNativeType() const =0
Function returning the native type of the DataHandler.
virtual std::vector< size_t > getDimensionsSize() const =0
Give the size of each dimension (if any) of the DataHandler.
virtual size_t getLargestAddressSpace() const =0
Get the largest AddressSpace for all data types handled by the DataHandler.
virtual size_t getAddressSpace(const std::type_info &type) const =0
Get the getAddressSpace size for the given data type.
DataHandler()
Default constructor of the DataHandler class.
Definition dataHandler.cpp:44
virtual void resetData()=0
Generic method for DataHandler to reset their data.
bool invalidCachedHash
Boolean value indicating whether the current cachedValue is valid, or not.
Definition dataHandler.h:90
virtual UntypedSharedPtr getDataAt(const std::type_info &type, const size_t address) const =0
Get data of the given type, from the given address.
virtual size_t updateHash() const =0
Update the cachedHash value.
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 dataHandl...
Definition dataHandler.cpp:61
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.
virtual bool canHandle(const std::type_info &type) const =0
Check a given DataHandler can handle data for the given data type.
size_t cachedHash
Cached value returned by the getHash() function.
Definition dataHandler.h:78
static size_t count
Static count used to initialize the id of each DataHandler.
Definition dataHandler.h:61
const size_t id
Identifier of each DataHandler.
Definition dataHandler.h:70
virtual DataHandler * clone() const =0
Return a copy of the DataHandler (with all its content).
DataHandler(const DataHandler &other)=default
Default copy constructor.
virtual size_t getHash() const
Get the current value of the hash for this DataHandler.
Definition dataHandler.cpp:52
DataHandler for 2D arrays of primitive types.
Definition primitiveTypeArray2D.h:69
Class behaving as a std::shared_ptr whose type is not templated.
Definition untypedSharedPtr.h:72
Definition array2DWrapper.h:44