设备基类

[English]

公共头文件: #include "brookesia/hal_interface/device.hpp"

API 参考

Header File

Classes

class Device

Base class for HAL devices.

A concrete device can publish one or more interface instances through interfaces_ during initialization, then those interfaces can be queried from the global registry.

Subclassed by esp_brookesia::hal::AudioDevice, esp_brookesia::hal::DisplayDevice, esp_brookesia::hal::StorageDevice

Public Functions

virtual bool probe() = 0

Check whether the device is supported on current runtime conditions.

返回

true if the device can be initialized; otherwise false.

inline const std::string &get_name() const

Get the registry name of this device.

返回

Device name.

template<typename T> inline requires IsInterface< T > std::shared_ptr< T > get_interface (const std::string &name) const

Retrieve a typed interface owned by this device by interface registry name.

模板参数

TInterface type that derives from Interface.

参数

name[in] Fully-qualified interface name in the registry.

返回

Matching typed interface pointer, or nullptr if the name is missing or the type does not match.

Type Aliases

using esp_brookesia::hal::DeviceRegistry = lib_utils::PluginRegistry<Device>

Registry alias for HAL devices.