GEGELATI
Loading...
Searching...
No Matches
dataHandler.h
1
39#ifndef DATA_HANDLER_H
40#define DATA_HANDLER_H
41
42#include <cstdint>
43#include <functional>
44#include <memory>
45#include <typeinfo>
46#include <vector>
47
48#include "data/untypedSharedPtr.h"
49
50namespace Data {
56 {
57
58 protected:
62 static size_t count;
63
71 const size_t id;
72
79 mutable size_t cachedHash;
80
91 mutable bool invalidCachedHash;
92
101 virtual size_t updateHash() const = 0;
102
103 public:
107 DataHandler();
108
110 virtual ~DataHandler() = default;
111
115 DataHandler(const DataHandler& other) = default;
116
126 virtual DataHandler* clone() const = 0;
127
137 size_t getId() const;
138
147 virtual size_t getHash() const;
148
157 virtual bool canHandle(const std::type_info& type) const = 0;
158
171 virtual size_t getAddressSpace(const std::type_info& type) const = 0;
172
181 virtual size_t getLargestAddressSpace() const = 0;
182
193 virtual void resetData() = 0;
194
218 virtual UntypedSharedPtr getDataAt(const std::type_info& type,
219 const size_t address) const = 0;
220
242 virtual std::vector<size_t> getAddressesAccessed(
243 const std::type_info& type, const size_t address) const = 0;
244
264 const std::type_info& type) const;
265
266#ifdef CODE_GENERATION
278 virtual const std::type_info& getNativeType() const = 0;
279
296 virtual std::vector<size_t> getDimensionsSize() const = 0;
297#endif
298 };
299} // namespace Data
300
301#endif
Base class for all sources of data to be accessed by a TPG Instruction executed within a Program.
Definition dataHandler.h:56
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:91
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:79
static size_t count
Static count used to initialize the id of each DataHandler.
Definition dataHandler.h:62
const size_t id
Identifier of each DataHandler.
Definition dataHandler.h:71
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