summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/libDDK/DriverKit/c++/contract.h48
-rw-r--r--src/libDDK/DriverKit/dki/contract.h34
2 files changed, 48 insertions, 34 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
diff --git a/src/libDDK/DriverKit/dki/contract.h b/src/libDDK/DriverKit/dki/contract.h
deleted file mode 100644
index 7361d792..00000000
--- a/src/libDDK/DriverKit/dki/contract.h
+++ /dev/null
@@ -1,34 +0,0 @@
-/* ========================================
-
- 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_CONTRACT_IMPL final : public ::Kernel::DKI::DKIContract
-
-/// @author Amlal El Mahrouss
-
-namespace Kernel::DKI {
-class DKIContract {
- public:
- explicit DKIContract() = default;
- virtual ~DKIContract() = default;
-
- NE_COPY_DEFAULT(DKIContract);
-
- using PtrType = VoidPtr;
-
- virtual BOOL IsCastable() { return NO; }
- virtual BOOL IsActive() { return NO; }
- virtual VoidPtr Leak() { return nullptr; }
- virtual Int32 Type() { return 0; }
-};
-} // namespace Kernel::DKI