blob: 44be997eb278ac1e287df3da9f2c1e3372463abe (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
/* ========================================
Copyright Amlal El Mahrouss 2025, licensed under the Apache 2.0 license.
FILE: driver_base.h
PURPOSE: C++ Driver Wrapper.
======================================== */
#pragma once
#include <libDDK/DriverKit/macros.h>
#define DDK_DRIVER_IMPL \
final: \
public \
::Kernel::DDK::IDriverBase
/// @author Amlal El Mahrouss
/// @brief The DDK C++ API.
namespace Kernel::DDK {
inline constexpr auto kInvalidType = 0;
/// @brief Driver interface type.
class IDriverBase {
public:
IDriverBase() = default;
virtual ~IDriverBase() = default;
NE_COPY_DELETE(IDriverBase);
using PtrType = void*;
virtual constexpr bool IsCastable() { return false; }
virtual constexpr bool IsActive() { return false; }
virtual PtrType Leak() { return nullptr; }
virtual constexpr int32_t Type() { return kInvalidType; }
};
/// @brief This concept requires the Driver to be IDriverBase compliant.
/// @author @amlel-el-mahrouss
template <typename Driver>
concept IsValidDriver = requires(Driver drv) {
{ drv.IsActive() && drv.Type() > kInvalidType };
};
} // namespace Kernel::DDK
|