X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5a5c578e2e358a121cdb9234a6cb11c4ecfbf323..d54215aea2a7321ab0f2dc7b0042fea2b7ff5df5:/rsm_protocol.h diff --git a/rsm_protocol.h b/rsm_protocol.h index 53908f3..d64c0af 100644 --- a/rsm_protocol.h +++ b/rsm_protocol.h @@ -4,65 +4,48 @@ #include "types.h" #include "rpc/rpc.h" -class rsm_client_protocol { - public: - enum status : status_t {OK, ERR, NOTPRIMARY, BUSY}; - enum rpc_numbers : proc_t { - invoke = 0x9001, - members, - }; +namespace rsm_client_protocol { + enum status : rpc_protocol::status {OK, ERR, NOTPRIMARY, BUSY}; + REMOTE_PROCEDURE_BASE(0x9000); + REMOTE_PROCEDURE(1, invoke, (string &, rpc_protocol::proc_id_t, string)); + REMOTE_PROCEDURE(2, members, (vector &, int)); }; struct viewstamp { - viewstamp (unsigned int _vid = 0, unsigned int _seqno = 0) : vid(_vid), seqno(_seqno) {} unsigned int vid; unsigned int seqno; inline void operator++(int) { seqno++; } -}; - -class rsm_protocol { - public: - enum status : status_t { OK, ERR, BUSY}; - enum rpc_numbers : proc_t { - invoke = 0xa001, - transferreq, - transferdonereq, - joinreq, - }; - struct transferres { - string state; - viewstamp last; - }; + MEMBERS(vid, seqno) + LEXICOGRAPHIC_COMPARISON(viewstamp) }; -inline bool operator==(viewstamp a, viewstamp b) { return tie(a.vid, a.seqno) == tie(b.vid, b.seqno); } -inline bool operator>(viewstamp a, viewstamp b) { return tie(a.vid, a.seqno) > tie(b.vid, b.seqno); } -inline bool operator!=(viewstamp a, viewstamp b) { return tie(a.vid, a.seqno) != tie(b.vid, b.seqno); } +MARSHALLABLE(viewstamp) -inline marshall& operator<<(marshall &m, viewstamp v) { - return m << v.vid << v.seqno; -} +namespace rsm_protocol { + enum status : rpc_protocol::status { OK, ERR, BUSY}; -inline unmarshall& operator>>(unmarshall &u, viewstamp &v) { - return u >> v.vid >> v.seqno; -} + struct transferres { + string state; + viewstamp last; -inline marshall & operator<<(marshall &m, rsm_protocol::transferres r) { - return m << r.state << r.last; -} + MEMBERS(state, last) + }; + + REMOTE_PROCEDURE_BASE(0xa000); + REMOTE_PROCEDURE(1, invoke, (int &, rpc_protocol::proc_id_t, viewstamp, string)); + REMOTE_PROCEDURE(2, transferreq, (transferres &, string, viewstamp, unsigned)); + REMOTE_PROCEDURE(3, transferdonereq, (int &, string, unsigned)); + REMOTE_PROCEDURE(4, joinreq, (string &, string, viewstamp)); +}; -inline unmarshall & operator>>(unmarshall &u, rsm_protocol::transferres &r) { - return u >> r.state >> r.last; -} +MARSHALLABLE(rsm_protocol::transferres) -class rsm_test_protocol { - public: - enum status : status_t {OK, ERR}; - enum rpc_numbers : proc_t { - net_repair = 0x12001, - breakpoint = 0x12002, - }; +namespace rsm_test_protocol { + enum status : rpc_protocol::status {OK, ERR}; + REMOTE_PROCEDURE_BASE(0x12000); + REMOTE_PROCEDURE(1, net_repair, (status &, int)); + REMOTE_PROCEDURE(2, breakpoint, (status &, int)); }; #endif