#include <filesystem>
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include "Types.hpp"
#include "Utils.hpp"
#include "io/BaseIO.hpp"
#include "io/ReadIO.hpp"
Go to the source code of this file.
|
namespace | AQNWB |
| The main namespace for AqNWB.
|
|
namespace | AQNWB::NWB |
| Namespace for all classes related to the NWB data standard.
|
|
|
#define | REGISTER_SUBCLASS_WITH_TYPENAME(T, NAMESPACE, TYPENAME) |
| Macro to register a subclass with the RegisteredType class registry.
|
|
#define | REGISTER_SUBCLASS(T, NAMESPACE) |
| Macro to register a subclass with the RegisteredType class registry.
|
|
#define | REGISTER_SUBCLASS_IMPL(T) |
| Macro to initialize the static member registered_ to trigger registration.
|
|
#define | DEFINE_FIELD(name, storageObjectType, default_type, fieldPath, description) |
| Defines a lazy-loaded field accessor function.
|
|
#define | DEFINE_REGISTERED_FIELD(name, registeredType, fieldPath, description) |
| Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes.
|
|
#define | DEFINE_REFERENCED_REGISTERED_FIELD(name, registeredType, fieldPath, description) |
| Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes that are linked to by a reference attribute.
|
|
|
constexpr auto | AQNWB::NWB::AttributeField = AQNWB::Types::StorageObjectType::Attribute |
| Alias for AQNWB::Types::StorageObjectType::Attribute.
|
|
constexpr auto | AQNWB::NWB::DatasetField = AQNWB::Types::StorageObjectType::Dataset |
| Alias for AQNWB::Types::StorageObjectType::Dataset.
|
|
◆ DEFINE_FIELD
#define DEFINE_FIELD |
( |
| name, |
|
|
| storageObjectType, |
|
|
| default_type, |
|
|
| fieldPath, |
|
|
| description ) |
Value: \
template<typename VTYPE = default_type> \
inline std::unique_ptr<IO::ReadDataWrapper<storageObjectType, VTYPE>> name() \
const \
{ \
return std::make_unique<IO::ReadDataWrapper<storageObjectType, VTYPE>>( \
}
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
Defines a lazy-loaded field accessor function.
This macro generates a function that returns a lazy-loaded wrapper for a dataset or attribute field.
- Note
- The Doxyfile.in defines a simplified expansion of this function for generating the documentation for the autogenerated function. This means: 1) When updating the macro here, we also need to ensure that the expansion in the Doxyfile.in is still accurate and 2) the docstring that is defined by the macro here is not being used by Doxygen but the version generated by its on PREDEFINED expansion.
- Parameters
-
name | The name of the function to generate. |
storageObjectType | The type of storage object (Attribute or Dataset). |
default_type | The default type of the field. |
fieldPath | The path to the field. |
description | A detailed description of the field. |
◆ DEFINE_REFERENCED_REGISTERED_FIELD
#define DEFINE_REFERENCED_REGISTERED_FIELD |
( |
| name, |
|
|
| registeredType, |
|
|
| fieldPath, |
|
|
| description ) |
Value: \
template<typename RTYPE = registeredType> \
inline std::shared_ptr<RTYPE> name() const \
{ \
try { \
std::string objectPath = m_io->readReferenceAttribute(attrPath); \
if (m_io->objectExists(objectPath)) { \
return RegisteredType::create<RTYPE>(objectPath, m_io); \
} \
} catch (const std::exception& e) { \
return nullptr; \
} \
return nullptr; \
}
Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes that are linked to by a reference attribute.
This macro generates a function that returns the appropriate subtype of RegisteredType, e.g., to read VectorData from a DynamicTable or a TimeSeries from an NWBFile.
- Note
- The Doxyfile.in defines a simplified expansion of this function for generating the documentation for the autogenerated function. This means: 1) When updating the macro here, we also need to ensure that the expansion in the Doxyfile.in is still accurate and 2) the docstring that is defined by the macro here is not being used by Doxygen but the version generated by its on PREDEFINED expansion.
- Parameters
-
name | The name of the function to generate. |
registeredType | The specific subclass of registered type to use |
fieldPath | The path to the attribute that stores reference to the field |
description | A detailed description of the field. |
◆ DEFINE_REGISTERED_FIELD
#define DEFINE_REGISTERED_FIELD |
( |
| name, |
|
|
| registeredType, |
|
|
| fieldPath, |
|
|
| description ) |
Value: \
template<typename RTYPE = registeredType> \
inline std::shared_ptr<RTYPE> name() const \
{ \
if (m_io->objectExists(objectPath)) { \
return RegisteredType::create<RTYPE>(objectPath, m_io); \
} \
return nullptr; \
}
Defines a lazy-loaded accessor function for reading fields that are RegisteredTypes.
This macro generates a function that returns the approbriate subtype of RegisteredType, e.g., to read VectorData from a DynamicTable or a TimeSeries from and NWBFile.
- Note
- The Doxyfile.in defines a simplified expansion of this function for generating the documentation for the autogenerated function. This means: 1) When updating the macro here, we also need to ensure that the expansion in the Doxyfile.in is still accurate and 2) the docstring that is defined by the macro here is not being used by Doxygen but the version generated by its on PREDEFINED expansion.
- Parameters
-
name | The name of the function to generate. |
registeredType | The specific subclass of registered type to use |
fieldPath | The path to the field. |
description | A detailed description of the field. |
◆ REGISTER_SUBCLASS
#define REGISTER_SUBCLASS |
( |
| T, |
|
|
| NAMESPACE ) |
Value:
#define REGISTER_SUBCLASS_WITH_TYPENAME(T, NAMESPACE, TYPENAME)
Macro to register a subclass with the RegisteredType class registry.
Definition RegisteredType.hpp:341
Macro to register a subclass with the RegisteredType class registry.
This macro is a convenience wrapper around the main REGISTER_SUBCLASS macro, providing a default value for TYPENAME.
- Parameters
-
T | The subclass type to register. The name must match the type in the schema. |
NAMESPACE | The namespace of the subclass type in the format schema |
◆ REGISTER_SUBCLASS_IMPL
#define REGISTER_SUBCLASS_IMPL |
( |
| T | ) |
|
Value:bool T::registered_ = T::registerSubclass();
Macro to initialize the static member registered_
to trigger registration.
This macro ensures that the registration of the subclass occurs when the program starts.
- Parameters
-
T | The subclass type to register. |
◆ REGISTER_SUBCLASS_WITH_TYPENAME
#define REGISTER_SUBCLASS_WITH_TYPENAME |
( |
| T, |
|
|
| NAMESPACE, |
|
|
| TYPENAME ) |
Value: static bool registerSubclass() \
{ \
AQNWB::NWB::RegisteredType::registerSubclass( \
NAMESPACE "::" #T, \
[](const std::string& path, std::shared_ptr<IO::BaseIO> io) \
-> std::unique_ptr<AQNWB::NWB::RegisteredType> \
{ return std::make_unique<T>(path, io); }, \
TYPENAME, \
NAMESPACE); \
return true; \
} \
static bool registered_; \
virtual std::string getTypeName() const override \
{ \
return TYPENAME; \
} \
virtual std::string getNamespace() const override \
{ \
return NAMESPACE; \
}
Macro to register a subclass with the RegisteredType class registry.
This macro defines:
- A static method
registerSubclass
that triggers registration of the subclass type when the subclass type is loaded.
- A static member
registered_
that ensures the registration occurs.
- override getTypeName for the class to return the correct type name
- override getNamespace for the class to return the correct namespace used
- Parameters
-
T | The subclass type to register. The name must match the type in the schema. |
NAMESPACE | The namespace of the subclass type in the format schema |
TYPENAME | The name of the type (usually the class name). |