aqnwb 0.1.0
Loading...
Searching...
No Matches
NamespaceRegistry.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <string>
5#include <string_view>
6#include <unordered_map>
7#include <vector>
8
9#include "Types.hpp"
10
15namespace AQNWB::SPEC
16{
22{
23public:
24 using RegistryType = std::unordered_map<std::string, Types::NamespaceInfo>;
25
31
37 void registerNamespace(const std::string& name,
38 const Types::NamespaceInfo& info);
39
46 const Types::NamespaceInfo* getNamespaceInfo(const std::string& name) const;
47
52 const RegistryType& getAllNamespaces() const;
53
54private:
56};
57
64#define REGISTER_NAMESPACE(name, version, specVariables) \
65 namespace \
66 { \
67 struct NamespaceRegistrar \
68 { \
69 NamespaceRegistrar() \
70 { \
71 NamespaceRegistry::instance().registerNamespace( \
72 name, {name, version, specVariables}); \
73 } \
74 }; \
75 static NamespaceRegistrar registrar; \
76 }
77
78} // namespace AQNWB::SPEC
Singleton class to manage the registration and lookup of namespace information.
Definition NamespaceRegistry.hpp:22
std::unordered_map< std::string, Types::NamespaceInfo > RegistryType
Definition NamespaceRegistry.hpp:24
void registerNamespace(const std::string &name, const Types::NamespaceInfo &info)
Register a namespace with its information.
Definition NamespaceRegistry.cpp:12
static NamespaceRegistry & instance()
Get the singleton instance of the NamespaceRegistry.
Definition NamespaceRegistry.cpp:6
RegistryType registry_
The registry storing namespace information.
Definition NamespaceRegistry.hpp:55
const Types::NamespaceInfo * getNamespaceInfo(const std::string &name) const
Get the namespace information for a given namespace name.
Definition NamespaceRegistry.cpp:18
const RegistryType & getAllNamespaces() const
Get all registered namespaces.
Definition NamespaceRegistry.cpp:28
The namespace for managing format schema and namespaces.
Struct to hold namespace information.
Definition Types.hpp:92