8#include <unordered_map>
9#include <unordered_set>
12#include <boost/multi_array.hpp>
16#define DEFAULT_STR_SIZE 256
17#define DEFAULT_ARRAY_SIZE 1
149 BaseIO(
const std::string& filename);
242 virtual std::vector<std::pair<std::string, StorageObjectType>>
245 StorageObjectType::Undefined)
const = 0;
261 virtual std::unordered_map<std::string, std::string>
findTypes(
262 const std::string& starting_path,
263 const std::unordered_set<std::string>& types,
282 const std::string& dataPath,
283 const std::vector<SizeType>& start = {},
284 const std::vector<SizeType>& count = {},
285 const std::vector<SizeType>& stride = {},
286 const std::vector<SizeType>& block = {}) = 0;
312 const std::string& path,
313 const std::string& name,
324 const std::string& path,
325 const std::string& name) = 0;
335 const std::string& path,
336 const std::string& name) = 0;
347 const std::string& path,
348 const std::string& name,
359 const std::string& path,
360 const std::string& name) = 0;
377 const std::string& reference) = 0;
386 const std::string& value) = 0;
395 const std::string& path,
const std::vector<std::string>& values) = 0;
405 const std::string& path,
const std::vector<std::string>& references) = 0;
441 const std::string& path) = 0;
449 const std::string& path) = 0;
459 const std::string& objectNamespace,
460 const std::string& neurodataType =
"");
548 const std::vector<SizeType>& positionOffset,
550 const void* data) = 0;
563 const std::vector<SizeType>& positionOffset,
565 const std::vector<std::string>& data) = 0;
577 inline const std::vector<SizeType>&
getSize()
const {
return size; }
AQNWB::Types::StorageObjectType StorageObjectType
Definition BaseIO.hpp:19
AQNWB::Types::Status Status
Definition BaseIO.hpp:20
AQNWB::Types::SizeArray SizeArray
Definition BaseIO.hpp:21
AQNWB::Types::SizeType SizeType
Definition Channel.hpp:8
Represents a base data type.
Definition BaseIO.hpp:41
static const BaseDataType F32
Accessor for 32-bit floating point.
Definition BaseIO.hpp:81
static const BaseDataType I64
Accessor for signed 64-bit integer.
Definition BaseIO.hpp:80
static BaseDataType STR(SizeType size)
Accessor for string with specified size.
Definition BaseIO.cpp:16
static const BaseDataType U32
Accessor for unsigned 32-bit integer.
Definition BaseIO.hpp:75
static const BaseDataType DSTR
Accessor for dynamic string.
Definition BaseIO.hpp:83
Type
Enumeration of different data types.
Definition BaseIO.hpp:47
@ V_STR
Variable length string.
Definition BaseIO.hpp:59
@ T_I32
Signed 32-bit integer.
Definition BaseIO.hpp:54
@ T_I64
Signed 64-bit integer.
Definition BaseIO.hpp:55
@ T_I8
Signed 8-bit integer.
Definition BaseIO.hpp:52
@ T_U32
Unsigned 32-bit integer.
Definition BaseIO.hpp:50
@ T_U64
Unsigned 64-bit integer.
Definition BaseIO.hpp:51
@ T_U8
Unsigned 8-bit integer.
Definition BaseIO.hpp:48
@ T_F32
32-bit floating point
Definition BaseIO.hpp:56
@ T_STR
String.
Definition BaseIO.hpp:58
@ T_F64
64-bit floating point
Definition BaseIO.hpp:57
@ T_U16
Unsigned 16-bit integer.
Definition BaseIO.hpp:49
@ T_I16
Signed 16-bit integer.
Definition BaseIO.hpp:53
static const BaseDataType U64
Accessor for unsigned 64-bit integer.
Definition BaseIO.hpp:76
static const BaseDataType U16
Accessor for unsigned 16-bit integer.
Definition BaseIO.hpp:74
static const BaseDataType F64
Accessor for 64-bit floating point.
Definition BaseIO.hpp:82
static const BaseDataType U8
Accessor for unsigned 8-bit integer.
Definition BaseIO.hpp:73
static const BaseDataType I32
Accessor for signed 32-bit integer.
Definition BaseIO.hpp:79
static const BaseDataType I16
Accessor for signed 16-bit integer.
Definition BaseIO.hpp:78
BaseDataType(Type t=T_I32, SizeType s=1)
Constructs a BaseDataType object with the specified type and size.
Definition BaseIO.cpp:10
Type type
The data type.
Definition BaseIO.hpp:69
SizeType typeSize
The size of the data type.
Definition BaseIO.hpp:70
static const BaseDataType I8
Accessor for signed 8-bit integer.
Definition BaseIO.hpp:77
virtual Status startRecording()=0
Starts the recording process.
virtual bool objectExists(const std::string &path) const =0
Checks whether a Dataset, Group, or Link already exists at the location in the file.
virtual StorageObjectType getStorageObjectType(std::string path) const =0
Get the storage type (Group, Dataset, Attribute) of the object at path.
virtual bool attributeExists(const std::string &path) const =0
Checks whether an Attribute exists at the location in the file.
BaseIO & operator=(const BaseIO &)=delete
Assignment operator is deleted to prevent copying.
virtual Status createReferenceAttribute(const std::string &referencePath, const std::string &path, const std::string &name)=0
Sets an object reference attribute for a given location in the file.
virtual Status createStringDataSet(const std::string &path, const std::string &value)=0
Creates a non-modifiable dataset with a string value.
virtual Status createAttribute(const std::vector< std::string > &data, const std::string &path, const std::string &name)=0
Creates a string array attribute at a given location in the file.
virtual std::unique_ptr< BaseRecordingData > createArrayDataSet(const BaseDataType &type, const SizeArray &size, const SizeArray &chunking, const std::string &path)=0
Creates an extendable dataset with a given base data type, size, chunking, and path.
BaseIO(const std::string &filename)
Constructor for the BaseIO class.
Definition BaseIO.cpp:35
bool isOpen() const
Returns true if the file is open.
Definition BaseIO.hpp:466
virtual Status createAttribute(const BaseDataType &type, const void *data, const std::string &path, const std::string &name, const SizeType &size=1)=0
Creates an attribute at a given location in the file.
virtual DataBlockGeneric readDataset(const std::string &dataPath, const std::vector< SizeType > &start={}, const std::vector< SizeType > &count={}, const std::vector< SizeType > &stride={}, const std::vector< SizeType > &block={})=0
Reads a dataset and determines the data type.
virtual ~BaseIO()
Destructor the BaseIO class.
Definition BaseIO.cpp:42
virtual Status createGroup(const std::string &path)=0
Creates a new group in the file.
Status createCommonNWBAttributes(const std::string &path, const std::string &objectNamespace, const std::string &neurodataType="")
Convenience function for creating NWB related attributes.
Definition BaseIO.cpp:44
virtual Status createLink(const std::string &path, const std::string &reference)=0
Creates a soft link to another location in the file.
const std::string m_filename
The name of the file.
Definition BaseIO.hpp:478
virtual std::unique_ptr< BaseRecordingData > getDataSet(const std::string &path)=0
Returns a pointer to a dataset at a given path.
bool m_readyToOpen
Whether the file is ready to be opened.
Definition BaseIO.hpp:490
virtual Status flush()=0
Flush data to disk.
bool isReadyToOpen() const
Returns true if the file is able to be opened.
Definition BaseIO.hpp:472
virtual std::vector< std::pair< std::string, StorageObjectType > > getStorageObjects(const std::string &path, const StorageObjectType &objectType=StorageObjectType::Undefined) const =0
Gets the list of storage objects (groups, datasets, attributes) inside a group.
virtual std::unordered_map< std::string, std::string > findTypes(const std::string &starting_path, const std::unordered_set< std::string > &types, SearchMode search_mode) const
Finds all datasets and groups of the given types in the HDF5 file.
Definition BaseIO.cpp:55
virtual Status createGroupIfDoesNotExist(const std::string &path)=0
Creates a new group if it does not already exist.
virtual DataBlockGeneric readAttribute(const std::string &dataPath) const =0
Reads a attribute and determines the data type.
virtual std::string getFileName() const
Returns the full path to the file.
Definition BaseIO.hpp:170
virtual Status createAttribute(const std::string &data, const std::string &path, const std::string &name)=0
Creates a string attribute at a given location in the file.
virtual Status stopRecording()=0
Stops the recording process.
virtual Status createAttribute(const std::vector< const char * > &data, const std::string &path, const std::string &name, const SizeType &maxSize)=0
Creates a string array attribute at a given location in the file.
virtual Status close()=0
Closes the file.
virtual bool canModifyObjects()
Returns true if the file is in a mode where objects can be added or deleted. Note,...
Definition BaseIO.hpp:426
BaseIO(const BaseIO &)=delete
Copy constructor is deleted to prevent construction-copying.
virtual Status open(FileMode mode)=0
Opens an existing file or creates a new file for writing.
virtual Status open()=0
Opens the file for writing.
virtual Status createReferenceDataSet(const std::string &path, const std::vector< std::string > &references)=0
Creates a dataset that holds an array of references to groups within the file.
virtual Status createStringDataSet(const std::string &path, const std::vector< std::string > &values)=0
Creates a dataset that holds an array of string values.
bool m_opened
Whether the file is currently open.
Definition BaseIO.hpp:495
The base class to represent recording data that can be extended.
Definition BaseIO.hpp:504
virtual Status writeDataBlock(const std::vector< SizeType > &dataShape, const std::vector< SizeType > &positionOffset, const BaseDataType &type, const std::vector< std::string > &data)=0
Writes a block of string data (any number of dimensions).
SizeType getNumDimensions() const
Get the number of dimensions in the dataset.
Definition BaseIO.hpp:571
std::vector< SizeType > position
The current position in the dataset.
Definition BaseIO.hpp:594
BaseRecordingData()
Default constructor.
Definition BaseIO.cpp:143
SizeType nDimensions
Number of dimensions in the dataset.
Definition BaseIO.hpp:599
const std::vector< SizeType > & getPosition() const
Get the current position in the dataset.
Definition BaseIO.hpp:583
Status writeDataBlock(const std::vector< SizeType > &dataShape, const BaseDataType &type, const void *data)
Writes a block of data using the stored position information. This is not intended to be overwritten ...
Definition BaseIO.cpp:149
const std::vector< SizeType > & getSize() const
Get the size of the dataset.
Definition BaseIO.hpp:577
BaseRecordingData(const BaseRecordingData &)=delete
Deleted copy constructor to prevent construction-copying.
std::vector< SizeType > size
The size of the dataset in each dimension.
Definition BaseIO.hpp:589
virtual Status writeDataBlock(const std::vector< SizeType > &dataShape, const std::vector< SizeType > &positionOffset, const BaseDataType &type, const void *data)=0
Writes a block of data (any number of dimensions).
BaseRecordingData & operator=(const BaseRecordingData &)=delete
Deleted copy assignment operator to prevent copying.
virtual ~BaseRecordingData()
Destructor.
Definition BaseIO.cpp:145
Generic structure to hold type-erased data and shape.
Definition ReadIO.hpp:29
StorageObjectType
Types of object used in the NWB schema.
Definition Types.hpp:31
Status
Represents the status of an operation.
Definition Types.hpp:22
std::vector< size_t > SizeArray
Alias for an array of size types used in the project.
Definition Types.hpp:59
size_t SizeType
Alias for the size type used in the project.
Definition Types.hpp:54
FileMode
The access mode for the file.
Definition BaseIO.hpp:111
@ ReadOnly
Opens the file in read only mode.
Definition BaseIO.hpp:131
@ ReadWrite
Opens the file with both read and write access.
Definition BaseIO.hpp:123
@ Overwrite
Opens the file and overwrites any existing file.
Definition BaseIO.hpp:115
SearchMode
Enum class for specifying the search mode for findTypes.
Definition BaseIO.hpp:95
@ STOP_ON_TYPE
Stop searching inside an object once a matching type is found.
Definition BaseIO.hpp:99
@ CONTINUE_ON_TYPE
Continue searching inside an object even after a matching type is found.
Definition BaseIO.hpp:104