aqnwb 0.1.0
Loading...
Searching...
No Matches
VectorData.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5#include "Utils.hpp"
6#include "io/ReadIO.hpp"
9
10namespace AQNWB::NWB
11{
15class VectorData : public Data
16{
17public:
19
20
26 VectorData(const std::string& path, std::shared_ptr<IO::BaseIO> io);
27
31 virtual ~VectorData() override {}
32
43 static std::shared_ptr<VectorData> createReferenceVectorData(
44 const std::string& path,
45 std::shared_ptr<IO::BaseIO> io,
46 const std::string& description,
47 const std::vector<std::string>& references)
48 {
49 Status dataStatus = io->createReferenceDataSet(path, references);
50 if (dataStatus != Status::Success) {
51 return nullptr;
52 }
53
54 auto vectorData = std::make_shared<VectorData>(path, io);
55 Status commonAttrsStatus = io->createCommonNWBAttributes(
56 path, vectorData->getNamespace(), vectorData->getTypeName());
57 Status attrStatus = io->createAttribute(description, path, "description");
58 if ((attrStatus && commonAttrsStatus) != Status::Success) {
59 return nullptr;
60 }
61
62 return vectorData;
63 }
64
75 const std::string& description)
76 {
77 Status dataStatus = Data::initialize(dataConfig);
78 Status attrStatus =
79 m_io->createAttribute(description, m_path, "description");
80 return dataStatus && attrStatus;
81 }
82
84 std::string,
85 "description",
86 Description of what these vectors represent)
87};
88
103template<typename DTYPE = std::any>
105{
106public:
113 VectorDataTyped(const std::string& path, std::shared_ptr<IO::BaseIO> io)
114 : VectorData(path, io)
115 {
116 }
117
121 virtual ~VectorDataTyped() override {}
122
136 static std::shared_ptr<VectorDataTyped<DTYPE>> fromVectorData(
137 const VectorData& data)
138 {
139 return std::make_shared<VectorDataTyped<DTYPE>>(data.getPath(),
140 data.getIO());
141 }
142
145
146 // Define the data fields to expose for lazy read access
147 DEFINE_DATASET_FIELD(readData, recordData, DTYPE, "", The main data)
148};
149} // namespace AQNWB::NWB
AQNWB::Types::Status Status
Definition BaseIO.hpp:22
#define REGISTER_SUBCLASS(T, NAMESPACE)
Macro to register a subclass with the RegisteredType class registry.
Definition RegisteredType.hpp:410
#define DEFINE_ATTRIBUTE_FIELD(name, default_type, fieldPath, description)
Defines a lazy-loaded attribute field accessor function.
Definition RegisteredType.hpp:443
#define DEFINE_DATASET_FIELD(readName, writeName, default_type, fieldPath, description)
Defines a lazy-loaded dataset field accessor function.
Definition RegisteredType.hpp:475
The configuration for an array dataset.
Definition BaseIO.hpp:200
Status initialize(const IO::ArrayDataSetConfig &dataConfig)
Initialize the dataset for the Data object.
Definition Data.hpp:42
Data(const std::string &path, std::shared_ptr< IO::BaseIO > io)
Constructor.
Definition Data.cpp:9
std::string m_path
The path of the registered type.
Definition RegisteredType.hpp:338
std::shared_ptr< IO::BaseIO > m_io
A shared pointer to the IO object.
Definition RegisteredType.hpp:343
std::string getPath() const
Gets the path of the registered type.
Definition RegisteredType.hpp:71
std::shared_ptr< AQNWB::IO::BaseIO > getIO() const
Get a shared pointer to the IO object.
Definition RegisteredType.hpp:89
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDescription() const
VectorData(const std::string &path, std::shared_ptr< IO::BaseIO > io)
Constructor.
Definition VectorData.cpp:8
Status initialize(const IO::ArrayDataSetConfig &dataConfig, const std::string &description)
Initialize the dataset for the VectorData object.
Definition VectorData.hpp:74
static std::shared_ptr< VectorData > createReferenceVectorData(const std::string &path, std::shared_ptr< IO::BaseIO > io, const std::string &description, const std::vector< std::string > &references)
Create a VectorData object with a reference dataset.
Definition VectorData.hpp:43
virtual ~VectorData() override
Virtual destructor.
Definition VectorData.hpp:31
static std::shared_ptr< VectorDataTyped< DTYPE > > fromVectorData(const VectorData &data)
Create a VectorDataTyped object from a Data object.
Definition VectorData.hpp:136
std::shared_ptr< IO::BaseRecordingData > recordData(bool reset=false)
std::unique_ptr< IO::ReadDataWrapper< DatasetField, VTYPE > > readData() const
VectorDataTyped(const std::string &path, std::shared_ptr< IO::BaseIO > io)
Constructor.
Definition VectorData.hpp:113
virtual ~VectorDataTyped() override
Virtual destructor.
Definition VectorData.hpp:121
Namespace for all classes related to the NWB data standard.
Definition TimeSeries.hpp:13
const std::string namespaceName
Definition hdmf_common.hpp:21