GEGELATI
dataHandler.h
1
38#ifndef DATA_HANDLER_H
39#define DATA_HANDLER_H
40
41#include <functional>
42#include <memory>
43#include <typeinfo>
44#include <vector>
45
46#include "data/untypedSharedPtr.h"
47
48namespace Data {
54 {
55
56 protected:
60 static size_t count;
61
69 const size_t id;
70
77 mutable size_t cachedHash;
78
89 mutable bool invalidCachedHash;
90
99 virtual size_t updateHash() const = 0;
100
101 public:
105 DataHandler();
106
108 virtual ~DataHandler() = default;
109
113 DataHandler(const DataHandler& other) = default;
114
124 virtual DataHandler* clone() const = 0;
125
135 size_t getId() const;
136
145 size_t getHash() const;
146
155 virtual bool canHandle(const std::type_info& type) const = 0;
156
169 virtual size_t getAddressSpace(const std::type_info& type) const = 0;
170
179 virtual size_t getLargestAddressSpace() const = 0;
180
191 virtual void resetData() = 0;
192
216 virtual UntypedSharedPtr getDataAt(const std::type_info& type,
217 const size_t address) const = 0;
218
240 virtual std::vector<size_t> getAddressesAccessed(
241 const std::type_info& type, const size_t address) const = 0;
242
261 uint64_t scaleLocation(const uint64_t rawLocation,
262 const std::type_info& type) const;
263
264#ifdef CODE_GENERATION
276 virtual const std::type_info& getNativeType() const = 0;
277
294 virtual std::vector<size_t> getDimensionsSize() const = 0;
295#endif
296 };
297} // namespace Data
298
299#endif
Base class for all sources of data to be accessed by a TPG Instruction executed within a Program.
Definition: dataHandler.h:54
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:89
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:77
static size_t count
Static count used to initialize the id of each DataHandler.
Definition: dataHandler.h:60
const size_t id
Identifier of each DataHandler.
Definition: dataHandler.h:69
virtual DataHandler * clone() const =0
Return a copy of the DataHandler (with all its content).
DataHandler(const DataHandler &other)=default
Default copy constructor.
size_t getHash() const
Get the current value of the hash for this DataHandler.
Definition: dataHandler.cpp:52
Class behaving as a std::shared_ptr whose type is not templated.
Definition: untypedSharedPtr.h:72
Definition: array2DWrapper.h:44