aqnwb 0.1.0
Loading...
Searching...
No Matches
RegisteredType.hpp File Reference
#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"
Include dependency graph for RegisteredType.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  AQNWB::NWB::RegisteredType
 Base class for types defined in the NWB schema. More...
 

Namespaces

namespace  AQNWB
 The main namespace for AqNWB.
 
namespace  AQNWB::NWB
 Namespace for all classes related to the NWB data standard.
 

Macros

#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.
 

Variables

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.
 

Macro Definition Documentation

◆ 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>>( \
m_io, AQNWB::mergePaths(m_path, fieldPath)); \
}
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 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
nameThe name of the function to generate.
storageObjectTypeThe type of storage object (Attribute or Dataset).
default_typeThe default type of the field.
fieldPathThe path to the field.
descriptionA 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:289

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
TThe subclass type to register. The name must match the type in the schema.
NAMESPACEThe 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
TThe 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
TThe subclass type to register. The name must match the type in the schema.
NAMESPACEThe namespace of the subclass type in the format schema
TYPENAMEThe name of the type (usually the class name).