diff --git a/src/BaseIO.cpp b/src/BaseIO.cpp index 353f709d..5a7b08eb 100644 --- a/src/BaseIO.cpp +++ b/src/BaseIO.cpp @@ -92,6 +92,17 @@ Status BaseIO::createTimestampsAttributes(const std::string& path) return Status::Success; } +std::unique_ptr BaseIO::lazyReadDataset(const std::string& dataPath) +{ + return std::make_unique(std::shared_ptr(this), dataPath); +} + +std::unique_ptr BaseIO::lazyReadAttribute(const std::string& dataPath) +{ + return std::make_unique(std::shared_ptr(this), dataPath); +} + + // BaseRecordingData BaseRecordingData::BaseRecordingData() {} diff --git a/src/BaseIO.hpp b/src/BaseIO.hpp index c5ed0ee3..a852971e 100644 --- a/src/BaseIO.hpp +++ b/src/BaseIO.hpp @@ -24,6 +24,8 @@ namespace AQNWB { class BaseRecordingData; +class ReadDatasetWrapper; +class ReadAttributeWrapper; /** * @brief Represents a base data type. @@ -206,6 +208,15 @@ class BaseIO const std::vector& stride = {}, const std::vector& block = {}) = 0; + /** + * @brief Create a ReadDatasetWrapper for a dataset for lazy reading + * + * @param dataPath The path to the dataset within the file. + * + * @return A ReadDatasetWrapper object for lazy reading from the dataset + */ + virtual std::unique_ptr lazyReadDataset(const std::string& dataPath); + /** * @brief Reads a attribute and determines the data type * @@ -219,6 +230,15 @@ class BaseIO */ virtual DataBlockGeneric readAttribute(const std::string& dataPath) = 0; + /** + * @brief Create a ReadAttributeWrapper for an attribute for lazy reading + * + * @param dataPath The path to the dataset within the file. + * + * @return A ReadAttributeWrapper object for lazy reading from the dataset + */ + virtual std::unique_ptr lazyReadAttribute(const std::string& dataPath); + /** * @brief Creates an attribute at a given location in the file. * @param type The base data type of the attribute. @@ -447,7 +467,7 @@ class ReadDatasetWrapper /** * @brief Default constructor. */ - ReadDatasetWrapper(); + ReadDatasetWrapper(std::shared_ptr io, std::string dataPath) : io(io), dataPath(dataPath) {} /** * @brief Deleted copy constructor to prevent construction-copying. @@ -462,7 +482,7 @@ class ReadDatasetWrapper /** * @brief Destructor. */ - virtual ~ReadDatasetWrapper(); + virtual ~ReadDatasetWrapper(){} /** * @brief Reads an dataset or attribute and determines the data type. @@ -495,7 +515,7 @@ class ReadDatasetWrapper * * @return A DataBlock structure containing the data and shape. */ - template + template DataBlock values(const std::vector& start = {}, const std::vector& count = {}, const std::vector& stride = {}, @@ -526,7 +546,7 @@ class ReadAttributeWrapper /** * @brief Default constructor. */ - ReadAttributeWrapper(); + ReadAttributeWrapper(std::shared_ptr io, std::string dataPath) : io(io), dataPath(dataPath) {} /** * @brief Deleted copy constructor to prevent construction-copying. @@ -541,7 +561,7 @@ class ReadAttributeWrapper /** * @brief Destructor. */ - virtual ~ReadAttributeWrapper(); + virtual ~ReadAttributeWrapper(){} /** * @brief Reads an attribute and determines the data type.