libxr 1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::RamFS::Device Class Reference

设备类,继承自红黑树节点 DeviceNode Device class inheriting from Red-Black tree node DeviceNode More...

#include <ramfs.hpp>

Inheritance diagram for LibXR::RamFS::Device:
Collaboration diagram for LibXR::RamFS::Device:

Public Member Functions

 Device (const char *name, const ReadPort &read_port=ReadPort(), const WritePort &write_port=WritePort())
 设备构造函数 Device constructor
 
template<typename ReadOperation >
ErrorCode Read (ReadOperation &&op, RawData data)
 读取设备数据 Reads data from the device
 
template<typename WriteOperation >
ErrorCode Write (WriteOperation &&op, ConstRawData data)
 向设备写入数据 Writes data to the device
 
- Public Member Functions inherited from LibXR::RBTree< Key >::Node< DeviceNode >
 Node ()
 默认构造函数,初始化数据为空 (Default constructor initializing an empty node).
 
 Node (const DeviceNode &data)
 使用指定数据构造节点 (Constructor initializing a node with the given data).
 
 Node (Args... args)
 通过参数列表构造节点 (Constructor initializing a node using arguments list).
 
 operator DeviceNode & ()
 
Nodeoperator= (const DeviceNode &data)
 
DeviceNode * operator-> ()
 
const DeviceNode * operator-> () const
 
DeviceNode & operator* ()
 

Data Fields

uint32_t device_type
 设备类型 Device type
 
- Data Fields inherited from LibXR::RBTree< Key >::Node< DeviceNode >
DeviceNode data_
 存储的数据 (Stored data).
 
- Data Fields inherited from LibXR::RBTree< Key >::BaseNode
Key key
 节点键值 (Key associated with the node).
 
RbtColor color
 节点颜色 (Color of the node).
 
BaseNodeleft = nullptr
 左子节点 (Left child node).
 
BaseNoderight = nullptr
 右子节点 (Right child node).
 
BaseNodeparent = nullptr
 父节点 (Parent node).
 
size_t size
 节点大小 (Size of the node).
 

Additional Inherited Members

- Protected Member Functions inherited from LibXR::RBTree< Key >::BaseNode
 BaseNode (size_t size)
 基本节点构造函数 (Constructor for BaseNode).
 

Detailed Description

设备类,继承自红黑树节点 DeviceNode Device class inheriting from Red-Black tree node DeviceNode

Definition at line 171 of file ramfs.hpp.

Constructor & Destructor Documentation

◆ Device()

LibXR::RamFS::Device::Device ( const char name,
const ReadPort read_port = ReadPort(),
const WritePort write_port = WritePort() 
)
inline

设备构造函数 Device constructor

Parameters
name设备名称 Device name
read_port读取端口(默认 ReadPort())Read port (default: ReadPort())
write_port写入端口(默认 WritePort())Write port (default: WritePort())

Definition at line 181 of file ramfs.hpp.

183 {
184 char *name_buff = new char[strlen(name) + 1];
185 strcpy(name_buff, name);
186 data_.name = name_buff;
188
189 UNUSED(read_port);
190 UNUSED(write_port);
191 }
DeviceNode data_
存储的数据 (Stored data).
Definition rbt.hpp:99
constexpr auto min(T1 a, T2 b) -> typename std::common_type< T1, T2 >::type
计算两个数的最小值

Member Function Documentation

◆ Read()

template<typename ReadOperation >
ErrorCode LibXR::RamFS::Device::Read ( ReadOperation &&  op,
RawData  data 
)
inline

读取设备数据 Reads data from the device

Template Parameters
ReadOperation读取操作类型 Read operation type
Parameters
op读取操作 Read operation
data读取数据 Data to be read
Returns
ErrorCode 错误码 Error code

Definition at line 202 of file ramfs.hpp.

203 {
204 return data_.read_port(data, std::forward<ReadOperation>(op));
205 }

◆ Write()

ErrorCode LibXR::RamFS::Device::Write ( WriteOperation &&  op,
ConstRawData  data 
)
inline

向设备写入数据 Writes data to the device

Template Parameters
WriteOperation写入操作类型 Write operation type
Parameters
op写入操作 Write operation
data写入数据 Data to be written
Returns
ErrorCode 错误码 Error code

Definition at line 216 of file ramfs.hpp.

217 {
218 return data_.write_port(data, std::forward<WriteOperation>(op));
219 }

Field Documentation

◆ device_type

uint32_t LibXR::RamFS::Device::device_type

设备类型 Device type

Definition at line 221 of file ramfs.hpp.


The documentation for this class was generated from the following file: