From 771459c68c26970784f3beea5398d3e21bb8286a Mon Sep 17 00:00:00 2001 From: Amlal El Mahrouss Date: Tue, 25 Nov 2025 10:41:06 -0500 Subject: feat! DDK: A new C++ friendly contract header file. Signed-off-by: Amlal El Mahrouss --- src/libDDK/DriverKit/c++/contract.h | 48 +++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/libDDK/DriverKit/c++/contract.h (limited to 'src/libDDK/DriverKit/c++') diff --git a/src/libDDK/DriverKit/c++/contract.h b/src/libDDK/DriverKit/c++/contract.h new file mode 100644 index 00000000..e341f1a0 --- /dev/null +++ b/src/libDDK/DriverKit/c++/contract.h @@ -0,0 +1,48 @@ +/* ======================================== + + Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license. + + FILE: ddk.h + PURPOSE: Driver Kernel Interface Model base header. + + ======================================== */ + +#pragma once + +#include +#include + +#define DKI_DRIVER_IMPL \ + final: \ + public \ + ::Kernel::DDK::IDriverBase + +/// @author Amlal El Mahrouss + +namespace Kernel::DDK { +class IDriverBase { + public: + explicit IDriverBase() = default; + virtual ~IDriverBase() = default; + + NE_COPY_DEFAULT(IDriverBase); + + using PtrType = VoidPtr; + + virtual BOOL IsCastable() { return NO; } + virtual constexpr BOOL IsActive() { return NO; } + virtual PtrType Leak() { return nullptr; } + virtual constexpr Int32 Type() { return 0; } +}; + +/// @brief This concept requires the Driver to be IDriverBase compliant. +template +concept IsValidDriver = requires(T a) { + { a.IsActive() && a.Type() > 0 }; +}; + +/// @note This helper is consteval only. +template +inline consteval void ce_ddk_is_valid(T) {} + +} // namespace Kernel::DDK -- cgit v1.2.3