diff options
| author | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-25 10:41:06 -0500 |
|---|---|---|
| committer | Amlal El Mahrouss <amlal@nekernel.org> | 2025-11-25 10:42:34 -0500 |
| commit | 771459c68c26970784f3beea5398d3e21bb8286a (patch) | |
| tree | 83697f985f49b0307999e018ba70186ee177ef94 /src/libDDK/DriverKit/c++ | |
| parent | cdfc807e90c713a3c7e6698c8b255b4523b8d311 (diff) | |
feat! DDK: A new C++ friendly contract header file.
Signed-off-by: Amlal El Mahrouss <amlal@nekernel.org>
Diffstat (limited to 'src/libDDK/DriverKit/c++')
| -rw-r--r-- | src/libDDK/DriverKit/c++/contract.h | 48 |
1 files changed, 48 insertions, 0 deletions
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 <CompilerKit/CompilerKit.h> +#include <libDDK/DriverKit/macros.h> + +#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 <typename T> +concept IsValidDriver = requires(T a) { + { a.IsActive() && a.Type() > 0 }; +}; + +/// @note This helper is consteval only. +template<IsValidDriver T> +inline consteval void ce_ddk_is_valid(T) {} + +} // namespace Kernel::DDK |
