node_communication/include/shm.h
2025-07-30 09:38:43 +08:00

37 lines
843 B
C++

#pragma once
#include "core.h"
/**
* @brief 共享内存 请求,回复 实现
*
*/
class ShmRequestReply : public IpcRequestReplyInterface {
public:
ShmRequestReply();
~ShmRequestReply();
std::expected<std::string, std::string> receive() override;
std::expected<void, std::string> send(const std::string& message) override;
};
/**
* @brief 共享内存 发布,订阅 实现
*
*/
class ShmPubSub : public IpcPubSubInterface {
public:
ShmPubSub();
~ShmPubSub();
std::expected<void, std::string> publish(const std::string& topic,
const std::string& message) override;
std::expected<void, std::string> subscribe(const std::string& topic) override;
};
/**
* @brief 共享内存 请求,回复 地址
*
*/
constexpr const char* SHM_REQUEST_REPLY_NAME = "/shm_req";