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
49 namespace Data {
54 class DataHandler
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
262 uint64_t scaleLocation(const uint64_t rawLocation,
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
Data::DataHandler
Base class for all sources of data to be accessed by a TPG Instruction executed within a Program.
Definition dataHandler.h:55
Data::DataHandler::getId
size_t getId() const
Get the ID of the DataHandler.
Definition dataHandler.cpp:47
Data::DataHandler::~DataHandler
virtual ~DataHandler()=default
Default destructor.
Data::DataHandler::getNativeType
virtual const std::type_info & getNativeType() const =0
Function returning the native type of the DataHandler.
Data::DataHandler::getDimensionsSize
virtual std::vector< size_t > getDimensionsSize() const =0
Give the size of each dimension (if any) of the DataHandler.
Data::DataHandler::getLargestAddressSpace
virtual size_t getLargestAddressSpace() const =0
Get the largest AddressSpace for all data types handled by the DataHandler.
Data::DataHandler::getAddressSpace
virtual size_t getAddressSpace(const std::type_info &type) const =0
Get the getAddressSpace size for the given data type.
Data::DataHandler::DataHandler
DataHandler()
Default constructor of the DataHandler class.
Definition dataHandler.cpp:44
Data::DataHandler::resetData
virtual void resetData()=0
Generic method for DataHandler to reset their data.
Data::DataHandler::invalidCachedHash
bool invalidCachedHash
Boolean value indicating whether the current cachedValue is valid, or not.
Definition dataHandler.h:90
Data::DataHandler::getDataAt
virtual UntypedSharedPtr getDataAt(const std::type_info &type, const size_t address) const =0
Get data of the given type, from the given address.
Data::DataHandler::updateHash
virtual size_t updateHash() const =0
Update the cachedHash value.
Data::DataHandler::scaleLocation
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
Data::DataHandler::getAddressesAccessed
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.
Data::DataHandler::canHandle
virtual bool canHandle(const std::type_info &type) const =0
Check a given DataHandler can handle data for the given data type.
Data::DataHandler::cachedHash
size_t cachedHash
Cached value returned by the getHash() function.
Definition dataHandler.h:78
Data::DataHandler::count
static size_t count
Static count used to initialize the id of each DataHandler.
Definition dataHandler.h:61
Data::DataHandler::id
const size_t id
Identifier of each DataHandler.
Definition dataHandler.h:70
Data::DataHandler::clone
virtual DataHandler * clone() const =0
Return a copy of the DataHandler (with all its content).
Data::DataHandler::DataHandler
DataHandler(const DataHandler &other)=default
Default copy constructor.
Data::DataHandler::getHash
virtual size_t getHash() const
Get the current value of the hash for this DataHandler.
Definition dataHandler.cpp:52
Data::PrimitiveTypeArray2D
DataHandler for 2D arrays of primitive types.
Definition primitiveTypeArray2D.h:69
Data::UntypedSharedPtr
Class behaving as a std::shared_ptr whose type is not templated.
Definition untypedSharedPtr.h:72
Data
Definition array2DWrapper.h:44