diff --git a/docs/pages/devdocs/registered_types.dox b/docs/pages/devdocs/registered_types.dox index 7cbe8052..9f2c31a7 100644 --- a/docs/pages/devdocs/registered_types.dox +++ b/docs/pages/devdocs/registered_types.dox @@ -53,6 +53,22 @@ * we can look up the corresponding class for an object in a file based on the * ``neurodata_type`` and ``namespace`` attributes stored in the file. * + * \note + * A special version of the ``REGISTER_SUBCLASS`` macro, called ``REGISTER_SUBCLASS_WITH_TYPENAME``, + * allows setting the typename explicitly as a third argument. This is for the **special case** + * where we want to implement a class for a modified type that does not have its + * own `neurodata_type` in the NWB schema. An example is `ElectrodesTable` in NWB m_io; }; + /** * @brief Macro to register a subclass with the RegisteredType class registry. * @@ -197,8 +198,9 @@ class RegisteredType * @param T The subclass type to register. The name must match the type in the * schema. * @param NAMESPACE The namespace of the subclass type in the format schema + * @param TYPENAME The name of the type (usually the class name). */ -#define REGISTER_SUBCLASS(T, NAMESPACE) \ +#define REGISTER_SUBCLASS_WITH_TYPENAME(T, NAMESPACE, TYPENAME) \ static bool registerSubclass() \ { \ AQNWB::NWB::RegisteredType::registerSubclass( \ @@ -206,20 +208,34 @@ class RegisteredType [](const std::string& path, std::shared_ptr io) \ -> std::unique_ptr \ { return std::make_unique(path, io); }, \ - #T, \ + TYPENAME, \ NAMESPACE); \ return true; \ } \ static bool registered_; \ virtual std::string getTypeName() const override \ { \ - return #T; \ + return TYPENAME; \ } \ virtual std::string getNamespace() const override \ { \ return NAMESPACE; \ } +/** + * @brief 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. + * + * @param T The subclass type to register. The name must match the type in the + * schema. + * @param NAMESPACE The namespace of the subclass type in the format schema + */ +#define REGISTER_SUBCLASS(T, NAMESPACE) REGISTER_SUBCLASS_WITH_TYPENAME(T, NAMESPACE, #T) + + + /** * @brief Macro to initialize the static member `registered_` to trigger * registration. diff --git a/src/nwb/file/ElectrodeTable.hpp b/src/nwb/file/ElectrodeTable.hpp index fdee8cde..0a3dad9c 100644 --- a/src/nwb/file/ElectrodeTable.hpp +++ b/src/nwb/file/ElectrodeTable.hpp @@ -16,7 +16,8 @@ class ElectrodeTable : public DynamicTable { public: // Register the ElectrodeTable as a subclass of Container - REGISTER_SUBCLASS(ElectrodeTable, "core") + //REGISTER_SUBCLASS(ElectrodeTable, "core") + REGISTER_SUBCLASS_WITH_TYPENAME(ElectrodeTable, "core", "DynamicTable") /** * @brief Constructor.