[Mammoth] Move ipc calls to separate folder mammoth.

This commit is contained in:
Drew Galbraith 2023-11-22 13:41:14 -08:00
parent 19e394ae7b
commit ad5b55bf37
19 changed files with 21 additions and 27 deletions

View file

@ -0,0 +1,31 @@
#pragma once
#include <glacier/status/error_or.h>
#include <glacier/string/string.h>
#include <stdint.h>
#include <zcall.h>
class PortClient {
public:
PortClient() {}
static PortClient AdoptPort(z_cap_t port_cap);
template <typename T>
z_err_t WriteMessage(const T& obj, z_cap_t cap);
glcr::ErrorCode WriteString(glcr::String str, z_cap_t cap);
z_cap_t cap() { return port_cap_; }
bool empty() { return port_cap_ == 0; }
private:
z_cap_t port_cap_ = 0;
PortClient(z_cap_t port_cap);
};
template <typename T>
z_err_t PortClient::WriteMessage(const T& obj, z_cap_t cap) {
return ZPortSend(port_cap_, sizeof(obj), &obj, 1, &cap);
}