acadia/yunq/server.h.jinja

45 lines
1.5 KiB
Plaintext
Raw Normal View History

// Generated File -- DO NOT MODIFY.
#pragma once
#include <glacier/status/error_or.h>
#include <mammoth/proc/thread.h>
#include <ztypes.h>
#include "{{file}}.h"
#include "{{file}}.client.h"
{% for interface in interfaces %}
class {{interface.name}}ServerBase {
public:
{{interface.name}}ServerBase(z_cap_t {{interface.name}}_cap) : endpoint_({{interface.name}}_cap) {}
{{interface.name}}ServerBase(const {{interface.name}}ServerBase&) = delete;
{{interface.name}}ServerBase({{interface.name}}ServerBase&&) = delete;
glcr::ErrorOr<{{interface.name}}Client> CreateClient();
[[nodiscard]] Thread RunServer();
{% for method in interface.methods %}
{% if method.request == None %}
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}({{method.response}}&) = 0;
{% elif method.response == None %}
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&) = 0;
{% else %}
[[nodiscard]] virtual glcr::ErrorCode Handle{{method.name}}(const {{method.request}}&, {{method.response}}&) = 0;
{% endif %}
{% endfor %}
private:
z_cap_t endpoint_;
friend void {{interface.name}}ServerBaseThreadBootstrap(void*);
void ServerThread();
[[nodiscard]] glcr::ErrorCode HandleRequest(const glcr::ByteBuffer& request, const glcr::CapBuffer& req_caps,
glcr::ByteBuffer& response, uint64_t& resp_length,
glcr::CapBuffer& resp_caps);
};
{% endfor %}