aqnwb 0.1.0
Loading...
Searching...
No Matches
DynamicTable.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <string>
4
5#include "Utils.hpp"
6#include "io/BaseIO.hpp"
7#include "io/ReadIO.hpp"
11#include "spec/hdmf_common.hpp"
12
13namespace AQNWB::NWB
14{
22class DynamicTable : public Container
23{
24public:
25 // Register the TimeSeries as a subclass of Container
27
28
33 DynamicTable(const std::string& path, std::shared_ptr<IO::BaseIO> io);
34
38 virtual ~DynamicTable();
39
47 Status initialize(const std::string& description);
48
58
65 Status addColumn(std::unique_ptr<VectorData>& vectorData,
66 const std::vector<std::string>& values);
67
75 Status addReferenceColumn(const std::string& name,
76 const std::string& colDescription,
77 const std::vector<std::string>& dataset);
78
85 Status setRowIDs(std::unique_ptr<ElementIdentifiers>& elementIDs,
86 const std::vector<int>& values);
87
102 virtual void setColNames(const std::vector<std::string>& newColNames)
103 {
104 m_colNames = newColNames;
105 }
106
117 template<typename DTYPE = std::any>
118 std::shared_ptr<VectorDataTyped<DTYPE>> readColumn(const std::string& colName)
119 {
120 std::string columnPath = AQNWB::mergePaths(m_path, colName);
121 if (m_io->objectExists(columnPath)) {
122 if (m_io->getStorageObjectType(columnPath) == StorageObjectType::Dataset)
123 {
124 return std::make_shared<VectorDataTyped<DTYPE>>(columnPath, m_io);
125 }
126 }
127 return nullptr;
128 }
129
131 std::string,
132 "colnames",
133 The names of the columns in the table)
134
136 std::string,
137 "description",
138 Description of what is in this dynamic table)
139
143 "id",
144 "unique identifiers for the rows of this dynamic table")
145
146protected:
150 std::vector<std::string> m_colNames;
151};
152} // 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_REGISTERED_FIELD(name, registeredType, fieldPath, description)
Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes.
Definition RegisteredType.hpp:528
Container(const std::string &path, std::shared_ptr< IO::BaseIO > io)
Constructor.
Definition Container.cpp:10
Status initialize()
Initialize the container.
Definition Container.cpp:20
std::vector< std::string > m_colNames
Names of the columns in the table.
Definition DynamicTable.hpp:150
Status setRowIDs(std::unique_ptr< ElementIdentifiers > &elementIDs, const std::vector< int > &values)
Adds a column of element identifiers to the table.
Definition DynamicTable.cpp:63
std::shared_ptr< VectorDataTyped< DTYPE > > readColumn(const std::string &colName)
Read an arbitrary column of the DyanmicTable.
Definition DynamicTable.hpp:118
virtual ~DynamicTable()
Destructor.
Definition DynamicTable.cpp:30
DynamicTable(const std::string &path, std::shared_ptr< IO::BaseIO > io)
Constructor.
Definition DynamicTable.cpp:12
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readColNames() const
Status finalize()
Finalizes writing the DynamicTable.
Definition DynamicTable.cpp:102
Status addColumn(std::unique_ptr< VectorData > &vectorData, const std::vector< std::string > &values)
Adds a column of vector string data to the table.
Definition DynamicTable.cpp:43
Status addReferenceColumn(const std::string &name, const std::string &colDescription, const std::vector< std::string > &dataset)
Adds a column of references to the table.
Definition DynamicTable.cpp:82
std::unique_ptr< IO::ReadDataWrapper< AttributeField, VTYPE > > readDescription() const
virtual void setColNames(const std::vector< std::string > &newColNames)
Sets the column names of the DynamicTable.
Definition DynamicTable.hpp:102
std::shared_ptr< RTYPE > readIdColumn() const
A list of unique identifiers for values within a dataset, e.g. rows of a DynamicTable.
Definition ElementIdentifiers.hpp:13
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
Namespace for all classes related to the NWB data standard.
Definition TimeSeries.hpp:13
const std::string namespaceName
Definition hdmf_common.hpp:21
static std::string mergePaths(const std::string &path1, const std::string &path2)
Merge two paths into a single path, handling extra trailing and starting "/".
Definition Utils.hpp:112