From 40b8dcdbc77d5d845f9eaeb9fa4440a799727c6a Mon Sep 17 00:00:00 2001 From: Felix Morgner Date: Fri, 24 Jul 2026 23:49:56 +0200 Subject: kapi: move interface_id --- kapi/kapi/capabilities/interface_id.hpp | 31 +++++++++++++++++++++++++ kapi/kapi/devices/interface_id.hpp | 28 +++++----------------- kapi/kapi/devices/interface_registry.hpp | 2 +- kapi/kapi/filesystem.hpp | 1 + kapi/kapi/filesystem/block_special_file.hpp | 4 ++-- kapi/kapi/filesystem/character_special_file.hpp | 4 ++-- kapi/kapi/filesystem/interface_id.hpp | 15 ++++++++++++ 7 files changed, 58 insertions(+), 27 deletions(-) create mode 100644 kapi/kapi/capabilities/interface_id.hpp create mode 100644 kapi/kapi/filesystem/interface_id.hpp (limited to 'kapi') diff --git a/kapi/kapi/capabilities/interface_id.hpp b/kapi/kapi/capabilities/interface_id.hpp new file mode 100644 index 00000000..5ddae585 --- /dev/null +++ b/kapi/kapi/capabilities/interface_id.hpp @@ -0,0 +1,31 @@ +#ifndef TEACHOS_KAPI_CAPABILITIES_INTERFACE_HPP +#define TEACHOS_KAPI_CAPABILITIES_INTERFACE_HPP + +// IWYU pragma: private + +#include + +namespace kapi::capabilities +{ + + //! A tag to mark that a given devices provides a specific device capability interface. + struct interface_id + { + //! Construct a new interface with a given name. + constexpr explicit interface_id(std::string_view name) + : m_name{name} + {} + + //! Get the name of this interface. + [[nodiscard]] constexpr auto name() const noexcept -> std::string_view const &; + + //! Check if this interface is equal to another one. + constexpr auto operator==(interface_id const &) const noexcept -> bool = default; + + private: + std::string_view m_name; + }; + +} // namespace kapi::capabilities + +#endif diff --git a/kapi/kapi/devices/interface_id.hpp b/kapi/kapi/devices/interface_id.hpp index 6c472e59..0698d2fd 100644 --- a/kapi/kapi/devices/interface_id.hpp +++ b/kapi/kapi/devices/interface_id.hpp @@ -1,31 +1,15 @@ -#ifndef TEACHOS_KAPI_DEVICES_INTERFACE_HPP -#define TEACHOS_KAPI_DEVICES_INTERFACE_HPP +#ifndef TEACHOS_KAPI_DEVICES_INTERFACE_ID_HPP +#define TEACHOS_KAPI_DEVICES_INTERFACE_ID_HPP -// IWYU pragma: private, include +// IWYU pragma: private -#include +#include namespace kapi::devices { - //! A tag to mark that a given devices provides a specific device capability interface. - struct interface_id - { - //! Construct a new interface with a given name. - constexpr explicit interface_id(std::string_view name) - : m_name{name} - {} + using interface_id = kapi::capabilities::interface_id; - //! Get the name of this interface. - [[nodiscard]] constexpr auto name() const noexcept -> std::string_view const &; - - //! Check if this interface is equal to another one. - constexpr auto operator==(interface_id const &) const noexcept -> bool = default; - - private: - std::string_view m_name; - }; - -} // namespace kapi::devices +} #endif diff --git a/kapi/kapi/devices/interface_registry.hpp b/kapi/kapi/devices/interface_registry.hpp index 9df76f6d..25a8b90f 100644 --- a/kapi/kapi/devices/interface_registry.hpp +++ b/kapi/kapi/devices/interface_registry.hpp @@ -65,7 +65,7 @@ namespace kapi::devices private: kstd::weak_ptr m_device; kstd::string m_name; - struct interface_id m_interface; + interface_id m_interface; void * m_implementation; }; diff --git a/kapi/kapi/filesystem.hpp b/kapi/kapi/filesystem.hpp index 161a1019..52bc22bc 100644 --- a/kapi/kapi/filesystem.hpp +++ b/kapi/kapi/filesystem.hpp @@ -6,6 +6,7 @@ #include // IWYU pragma: export #include // IWYU pragma: export #include // IWYU pragma: export +#include // IWYU pragma: export #include #include diff --git a/kapi/kapi/filesystem/block_special_file.hpp b/kapi/kapi/filesystem/block_special_file.hpp index 6e125117..c7f3ac51 100644 --- a/kapi/kapi/filesystem/block_special_file.hpp +++ b/kapi/kapi/filesystem/block_special_file.hpp @@ -3,7 +3,7 @@ // IWYU pragma: private, include -#include +#include #include #include @@ -15,7 +15,7 @@ namespace kapi::filesystem struct block_special_file { - constexpr auto static id = kapi::devices::interface_id{"block"}; + constexpr auto static id = interface_id{"block"}; //! Virtual destructor to enable clean deletes through base pointers. virtual ~block_special_file() = default; diff --git a/kapi/kapi/filesystem/character_special_file.hpp b/kapi/kapi/filesystem/character_special_file.hpp index d7bc8c64..7ce5fdaa 100644 --- a/kapi/kapi/filesystem/character_special_file.hpp +++ b/kapi/kapi/filesystem/character_special_file.hpp @@ -3,7 +3,7 @@ // IWYU pragma: private, include -#include +#include #include #include @@ -16,7 +16,7 @@ namespace kapi::filesystem struct character_special_file { - constexpr auto static id = kapi::devices::interface_id{"char"}; + constexpr auto static id = interface_id{"char"}; //! Virtual destructor to enable clean deletes through base pointers. virtual ~character_special_file() = default; diff --git a/kapi/kapi/filesystem/interface_id.hpp b/kapi/kapi/filesystem/interface_id.hpp new file mode 100644 index 00000000..18e0fbc4 --- /dev/null +++ b/kapi/kapi/filesystem/interface_id.hpp @@ -0,0 +1,15 @@ +#ifndef TEACHOS_KAPI_FILESYSTEM_INTERFACE_ID_HPP +#define TEACHOS_KAPI_FILESYSTEM_INTERFACE_ID_HPP + +// IWYU pragma: private + +#include + +namespace kapi::filesystem +{ + + using interface_id = kapi::capabilities::interface_id; + +} + +#endif -- cgit v1.2.3