log0.3
This commit is contained in:
34
src/hardware/interfaces/IStreamDriver.h
Normal file
34
src/hardware/interfaces/IStreamDriver.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
#include <cstdint>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace softbus::hardware::interfaces
|
||||
{
|
||||
|
||||
// 面向字节流设备的统一驱动接口:串口 / TCP / UDP 等
|
||||
class IStreamDriver
|
||||
{
|
||||
public:
|
||||
using ReadCallback = std::function<void(const std::vector<std::uint8_t>&)>;
|
||||
using ErrorCallback = std::function<void(const std::string& message)>;
|
||||
|
||||
virtual ~IStreamDriver() = default;
|
||||
|
||||
virtual bool Open(const std::string& endpoint) = 0;
|
||||
virtual void Close() = 0;
|
||||
|
||||
virtual bool Write(const std::vector<std::uint8_t>& data) = 0;
|
||||
|
||||
virtual void SetReadCallback(ReadCallback cb) = 0;
|
||||
virtual void SetErrorCallback(ErrorCallback cb) = 0;
|
||||
};
|
||||
|
||||
} // namespace softbus::hardware::interfaces
|
||||
|
||||
#endif // __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user