34 lines
717 B
C++
34 lines
717 B
C++
#pragma once
|
|
#include <expected>
|
|
#include <string>
|
|
|
|
/**
|
|
* @brief 发布,订阅
|
|
*
|
|
*/
|
|
class IpcPubSubInterface {
|
|
public:
|
|
virtual ~IpcPubSubInterface() = default;
|
|
|
|
virtual std::expected<void, std::string> publish(
|
|
const std::string& topic, const std::string& message) = 0;
|
|
virtual std::expected<void, std::string> subscribe(
|
|
const std::string& topic) = 0;
|
|
};
|
|
|
|
/**
|
|
* @brief 请求,回复
|
|
*
|
|
*/
|
|
class IpcRequestReplyInterface {
|
|
public:
|
|
virtual ~IpcRequestReplyInterface() = default;
|
|
|
|
virtual std::expected<void, std::string> send(const std::string& message) = 0;
|
|
virtual std::expected<std::string, std::string> receive() = 0;
|
|
};
|
|
|
|
|
|
// 缓冲区大小
|
|
constexpr size_t BUFFER_SIZE = 4096;
|