NeKernel dev
Loading...
Searching...
No Matches
driver_base.h
Go to the documentation of this file.
1/* ========================================
2
3 Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
4
5 FILE: driver_base.h
6 PURPOSE: IDriverBase and friends.
7
8 ======================================== */
9
10#pragma once
11
14
15#define DKI_DRIVER_IMPL \
16 final: \
17 public \
18 ::Kernel::DDK::IDriverBase
19
21
22namespace Kernel::DDK {
23constexpr auto kInvalidType = 0;
24
26 public:
27 explicit IDriverBase() = default;
28 virtual ~IDriverBase() = default;
29
31
33
34 virtual BOOL IsCastable() { return NO; }
35 virtual constexpr BOOL IsActive() { return NO; }
36 virtual PtrType Leak() { return nullptr; }
37 virtual constexpr Int32 Type() { return kInvalidType; }
38};
39
41template <typename T>
42concept IsValidDriver = requires(T driver_base) {
43 { driver_base.IsActive() && driver_base.Type() > kInvalidType };
44};
45
48template <IsValidDriver T>
49consteval void ce_ddk_is_valid(T) {}
50} // namespace Kernel::DDK
#define NO
#define BOOL
virtual PtrType Leak()
Definition driver_base.h:36
virtual constexpr Int32 Type()
Definition driver_base.h:37
NE_COPY_DEFAULT(IDriverBase)
VoidPtr PtrType
Definition driver_base.h:32
virtual constexpr BOOL IsActive()
Definition driver_base.h:35
virtual BOOL IsCastable()
Definition driver_base.h:34
virtual ~IDriverBase()=default
This concept requires the Driver to be IDriverBase compliant.
Definition driver_base.h:42
Definition driver_base.h:22
consteval void ce_ddk_is_valid(T)
Consteval helper to detect whether a template is truly based on IDriverBase.
Definition driver_base.h:49
constexpr auto kInvalidType
Definition driver_base.h:23
void * VoidPtr
Definition Config.h:33
__INT32_TYPE__ Int32
Definition Config.h:38