move marshaller to IPC component
This commit is contained in:
@@ -4,9 +4,13 @@
|
||||
#include <ipc/IpcCodec.h>
|
||||
#include <rpc/RpcValue.h>
|
||||
|
||||
class ProxyMarshaller {
|
||||
// Маршаллер, который знает, как превратить типизированный RPC-вызов
|
||||
// в IpcMessage и обратно. Живёт в IPC-слое и опирается на IpcChannel
|
||||
// и IpcCodec, но снаружи предъявляет только callTyped<T>(...).
|
||||
class IpcMarshaller {
|
||||
public:
|
||||
explicit ProxyMarshaller(IpcChannel& ch) : channel(ch) {}
|
||||
explicit IpcMarshaller(IpcChannel& ch)
|
||||
: channel(ch) {}
|
||||
|
||||
// Базовый type-erased вызов: принимает вектор RpcValue и возвращает RpcValue.
|
||||
RpcValue call(const std::string& method, const RpcArgs& args) {
|
||||
@@ -21,7 +25,7 @@ public:
|
||||
return IpcCodec::decodeResponse(resp);
|
||||
}
|
||||
|
||||
// Удобный шаблонный хелпер для сгенерированных прокси.
|
||||
// Типизированный хелпер: контрактом является только наличие этого метода.
|
||||
template<typename Ret, typename... Args>
|
||||
Ret callTyped(const std::string& method, const Args&... args) {
|
||||
RpcArgs packed;
|
||||
@@ -38,3 +42,4 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user