Skip to content

Commit

Permalink
Add functions to construct ReadDatasetWrapper and ReadAttributeWrappe…
Browse files Browse the repository at this point in the history
…r from BaseIO
  • Loading branch information
oruebel committed Aug 31, 2024
1 parent e1bfa2e commit 4aedefd
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
11 changes: 11 additions & 0 deletions src/BaseIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ Status BaseIO::createTimestampsAttributes(const std::string& path)
return Status::Success;
}

std::unique_ptr<ReadDatasetWrapper> BaseIO::lazyReadDataset(const std::string& dataPath)
{
return std::make_unique<ReadDatasetWrapper>(std::shared_ptr<BaseIO>(this), dataPath);
}

std::unique_ptr<ReadAttributeWrapper> BaseIO::lazyReadAttribute(const std::string& dataPath)
{
return std::make_unique<ReadAttributeWrapper>(std::shared_ptr<BaseIO>(this), dataPath);
}


// BaseRecordingData

BaseRecordingData::BaseRecordingData() {}
Expand Down
30 changes: 25 additions & 5 deletions src/BaseIO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ namespace AQNWB
{

class BaseRecordingData;
class ReadDatasetWrapper;
class ReadAttributeWrapper;

/**
* @brief Represents a base data type.
Expand Down Expand Up @@ -206,6 +208,15 @@ class BaseIO
const std::vector<SizeType>& stride = {},
const std::vector<SizeType>& 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<ReadDatasetWrapper> lazyReadDataset(const std::string& dataPath);

/**
* @brief Reads a attribute and determines the data type
*
Expand All @@ -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<ReadAttributeWrapper> 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.
Expand Down Expand Up @@ -447,7 +467,7 @@ class ReadDatasetWrapper
/**
* @brief Default constructor.
*/
ReadDatasetWrapper();
ReadDatasetWrapper(std::shared_ptr<BaseIO> io, std::string dataPath) : io(io), dataPath(dataPath) {}

/**
* @brief Deleted copy constructor to prevent construction-copying.
Expand All @@ -462,7 +482,7 @@ class ReadDatasetWrapper
/**
* @brief Destructor.
*/
virtual ~ReadDatasetWrapper();
virtual ~ReadDatasetWrapper(){}

/**
* @brief Reads an dataset or attribute and determines the data type.
Expand Down Expand Up @@ -495,7 +515,7 @@ class ReadDatasetWrapper
*
* @return A DataBlock structure containing the data and shape.
*/
template<typename T>
template <typename T>
DataBlock<T> values(const std::vector<SizeType>& start = {},
const std::vector<SizeType>& count = {},
const std::vector<SizeType>& stride = {},
Expand Down Expand Up @@ -526,7 +546,7 @@ class ReadAttributeWrapper
/**
* @brief Default constructor.
*/
ReadAttributeWrapper();
ReadAttributeWrapper(std::shared_ptr<BaseIO> io, std::string dataPath) : io(io), dataPath(dataPath) {}

/**
* @brief Deleted copy constructor to prevent construction-copying.
Expand All @@ -541,7 +561,7 @@ class ReadAttributeWrapper
/**
* @brief Destructor.
*/
virtual ~ReadAttributeWrapper();
virtual ~ReadAttributeWrapper(){}

/**
* @brief Reads an attribute and determines the data type.
Expand Down

0 comments on commit 4aedefd

Please sign in to comment.