move marshaller out of template
This commit is contained in:
+4
-2
@@ -1,5 +1,6 @@
|
|||||||
#include "MyService.proxy.h"
|
#include "MyService.proxy.h"
|
||||||
#include "ipc/IpcPipeChannel.h"
|
#include "ipc/IpcPipeChannel.h"
|
||||||
|
#include "proxy/ProxyMarshaller.h"
|
||||||
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@@ -15,8 +16,9 @@ int main() {
|
|||||||
// и читает из fifo, в который пишет сервер (fifo_to_client).
|
// и читает из fifo, в который пишет сервер (fifo_to_client).
|
||||||
IpcPipeChannel ch("/tmp/fifo_to_client", "/tmp/fifo_to_server");
|
IpcPipeChannel ch("/tmp/fifo_to_client", "/tmp/fifo_to_server");
|
||||||
|
|
||||||
// RPC‑уровень: прокси поверх канала.
|
// RPC‑уровень: создаём marshaller поверх канала и передаём его в прокси.
|
||||||
MyServiceProxy proxy(ch);
|
ProxyMarshaller marshaller(ch);
|
||||||
|
MyServiceProxy proxy(marshaller);
|
||||||
|
|
||||||
int r = proxy.add(7, 8);
|
int r = proxy.add(7, 8);
|
||||||
std::cout << "RESULT: " << r << std::endl;
|
std::cout << "RESULT: " << r << std::endl;
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
#include "{{ cls.name }}.proxy.h"
|
#include "{{ cls.name }}.proxy.h"
|
||||||
#include "proxy/ProxyMarshaller.h"
|
|
||||||
|
|
||||||
class {{ cls.name }}Proxy::Impl {
|
class {{ cls.name }}Proxy::Impl {
|
||||||
public:
|
public:
|
||||||
explicit Impl(IpcChannel& ch)
|
explicit Impl(ProxyMarshaller& m)
|
||||||
: client(ch) {}
|
: client(m) {}
|
||||||
|
|
||||||
ProxyMarshaller client;
|
ProxyMarshaller& client;
|
||||||
};
|
};
|
||||||
|
|
||||||
{{ cls.name }}Proxy::{{ cls.name }}Proxy(IpcChannel& ch)
|
{{ cls.name }}Proxy::{{ cls.name }}Proxy(ProxyMarshaller& marshaller)
|
||||||
: impl(new Impl(ch)) {}
|
: impl(new Impl(marshaller)) {}
|
||||||
|
|
||||||
{% for m in cls.methods %}
|
{% for m in cls.methods %}
|
||||||
{{ m.return_type }} {{ cls.name }}Proxy::{{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %}) {
|
{{ m.return_type }} {{ cls.name }}Proxy::{{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %}) {
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "ipc/IpcChannel.h"
|
#include "proxy/ProxyMarshaller.h"
|
||||||
|
|
||||||
class {{ cls.name }}Proxy {
|
class {{ cls.name }}Proxy {
|
||||||
public:
|
public:
|
||||||
explicit {{ cls.name }}Proxy(IpcChannel& ch);
|
explicit {{ cls.name }}Proxy(ProxyMarshaller& marshaller);
|
||||||
{% for m in cls.methods %}
|
{% for m in cls.methods %}
|
||||||
{{ m.return_type }} {{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %});
|
{{ m.return_type }} {{ m.name }}({% for a in m.args %}{{ a.type }} {{ a.name }}{% if not loop.last %}, {% endif %}{% endfor %});
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
Reference in New Issue
Block a user