move marshaller out of template

master
Сергей Маринкевич 2 months ago
parent 785fca07f1
commit 9f48a74677

@ -1,5 +1,6 @@
#include "MyService.proxy.h"
#include "ipc/IpcPipeChannel.h"
#include "proxy/ProxyMarshaller.h"
#include <sys/stat.h>
@ -15,8 +16,9 @@ int main() {
// и читает из fifo, в который пишет сервер (fifo_to_client).
IpcPipeChannel ch("/tmp/fifo_to_client", "/tmp/fifo_to_server");
// RPCуровень: прокси поверх канала.
MyServiceProxy proxy(ch);
// RPCуровень: создаём marshaller поверх канала и передаём его в прокси.
ProxyMarshaller marshaller(ch);
MyServiceProxy proxy(marshaller);
int r = proxy.add(7, 8);
std::cout << "RESULT: " << r << std::endl;

@ -1,16 +1,15 @@
#include "{{ cls.name }}.proxy.h"
#include "proxy/ProxyMarshaller.h"
class {{ cls.name }}Proxy::Impl {
public:
explicit Impl(IpcChannel& ch)
: client(ch) {}
explicit Impl(ProxyMarshaller& m)
: client(m) {}
ProxyMarshaller client;
ProxyMarshaller& client;
};
{{ cls.name }}Proxy::{{ cls.name }}Proxy(IpcChannel& ch)
: impl(new Impl(ch)) {}
{{ cls.name }}Proxy::{{ cls.name }}Proxy(ProxyMarshaller& marshaller)
: impl(new Impl(marshaller)) {}
{% 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 %}) {

@ -1,10 +1,10 @@
#pragma once
#include "ipc/IpcChannel.h"
#include "proxy/ProxyMarshaller.h"
class {{ cls.name }}Proxy {
public:
explicit {{ cls.name }}Proxy(IpcChannel& ch);
explicit {{ cls.name }}Proxy(ProxyMarshaller& marshaller);
{% 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 %});
{% endfor %}

Loading…
Cancel
Save