blob: 82e5bd441f5ce56962fb34e1c1ae58a45d44b40e (
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
|
// Copyright 2024-2025, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel
#ifndef DRIVERKIT_DRIVER_BASE_H
#define DRIVERKIT_DRIVER_BASE_H
#include <CompilerKit/CompilerKit.h>
#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
#endif
|