31 lines
657 B
C++
31 lines
657 B
C++
#pragma once
|
|
#include "core.h"
|
|
#include <memory>
|
|
|
|
/**
|
|
* @brief
|
|
*
|
|
*/
|
|
class IpcRequestReplyContext {
|
|
private:
|
|
std::unique_ptr<IpcRequestReplyInterface> strategy;
|
|
|
|
public:
|
|
void setStrategy(std::unique_ptr<IpcRequestReplyInterface> newStrategy) {
|
|
strategy = std::move(newStrategy);
|
|
}
|
|
|
|
std::expected<void, std::string> send(const std::string& message) {
|
|
if (strategy) {
|
|
return strategy->send(message);
|
|
}
|
|
return std::unexpected("Not Found Strategy");
|
|
}
|
|
|
|
std::expected<std::string, std::string> receive() {
|
|
if (strategy) {
|
|
return strategy->receive();
|
|
}
|
|
return std::unexpected("Not Found Strategy");
|
|
}
|
|
}; |