From 36dee4f0d8ea806b2f061ed66a89e812ab007ed2 Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Mon, 22 Dec 2025 07:38:52 +0100 Subject: feat: test: Add `kout` test and rename DeviceInterface to IDevice in KernelKit. introduce UserPtr and unburden vettable by removing the IVettable helper. Signed-off-by: Amlal El Mahrouss --- src/kernel/KernelKit/DeviceMgr.h | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'src/kernel/KernelKit/DeviceMgr.h') diff --git a/src/kernel/KernelKit/DeviceMgr.h b/src/kernel/KernelKit/DeviceMgr.h index 1dbad161..56208140 100644 --- a/src/kernel/KernelKit/DeviceMgr.h +++ b/src/kernel/KernelKit/DeviceMgr.h @@ -24,13 +24,13 @@ #define kDeviceMgrRootDirPath "/devices/" -#define NE_DEVICE : public ::Kernel::DeviceInterface +#define NE_DEVICE : public ::Kernel::IDevice // Last Rev: Wed, May 27, 2025 6:22 PM namespace Kernel { template -class DeviceInterface; +class IDevice; template class IOBuf; @@ -39,26 +39,30 @@ class IOBuf; /// @brief Device contract interface, represents an HW device. /***********************************************************************************/ template -class DeviceInterface { +class IDevice { public: - DeviceInterface() = default; + IDevice() = default; - explicit DeviceInterface(void (*Out)(DeviceInterface*, T), void (*In)(DeviceInterface*, T)) - : fOut(Out), fIn(In) {} + explicit IDevice(void (*Out)(IDevice*, T), void (*In)(IDevice*, T)) : fOut(Out), fIn(In) {} - virtual ~DeviceInterface() = default; + virtual ~IDevice() = default; public: - DeviceInterface& operator=(const DeviceInterface&) = default; - DeviceInterface(const DeviceInterface&) = default; + using Type = T; + using TypeRef = T&; + using ConstType = const T&; + using TypePtr = T*; + + IDevice& operator=(const IDevice&) = default; + IDevice(const IDevice&) = default; public: - virtual DeviceInterface& operator<<(T Data) { + virtual IDevice& operator<<(T Data) { fOut(this, Data); return *this; } - virtual DeviceInterface& operator>>(T Data) { + virtual IDevice& operator>>(T Data) { fIn(this, Data); return *this; } @@ -70,8 +74,8 @@ class DeviceInterface { Bool operator!() { return !fOut || !fIn; } protected: - Void (*fOut)(DeviceInterface*, T Data) = {nullptr}; - Void (*fIn)(DeviceInterface*, T Data) = {nullptr}; + Void (*fOut)(IDevice*, T Data) = {nullptr}; + Void (*fIn)(IDevice*, T Data) = {nullptr}; }; /// -- cgit v1.2.3