X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/eeab3e6cade87c1fe0a5f3d93522e12ccb9ec2ab..f0dcb6b97d6d40f67698d1f71ac26970f1776f82:/rsm_protocol.h?ds=inline diff --git a/rsm_protocol.h b/rsm_protocol.h index 68ff061..9cd60bd 100644 --- a/rsm_protocol.h +++ b/rsm_protocol.h @@ -1,112 +1,51 @@ #ifndef rsm_protocol_h #define rsm_protocol_h +#include "types.h" #include "rpc/rpc.h" - -class rsm_client_protocol { - public: - enum xxstatus { OK, ERR, NOTPRIMARY, BUSY}; - typedef int status; - enum rpc_numbers { - 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 xxstatus { OK, ERR, BUSY}; - typedef int status; - enum rpc_numbers { - invoke = 0x10001, - transferreq, - transferdonereq, - joinreq, - }; + unsigned int vid; + unsigned int seqno; + inline void operator++(int) { seqno++; } - struct transferres { - std::string state; - viewstamp last; - }; - - struct joinres { - std::string log; - }; + MEMBERS(vid, seqno) + LEXICOGRAPHIC_COMPARISON(viewstamp) }; -inline bool operator==(viewstamp a, viewstamp b) { - return a.vid == b.vid && a.seqno == b.seqno; -} +MARSHALLABLE_STRUCT(viewstamp) -inline bool operator>(viewstamp a, viewstamp b) { - return (a.vid > b.vid) || ((a.vid == b.vid) && a.seqno > b.seqno); -} +namespace rsm_protocol { + enum status : rpc_protocol::status { OK, ERR, BUSY}; -inline bool operator!=(viewstamp a, viewstamp b) { - return a.vid != b.vid || a.seqno != b.seqno; -} + struct transferres { + string state; + viewstamp last; -inline marshall& operator<<(marshall &m, viewstamp v) -{ - m << v.vid; - m << v.seqno; - return m; -} + MEMBERS(state, last) + }; -inline unmarshall& operator>>(unmarshall &u, viewstamp &v) { - u >> v.vid; - u >> v.seqno; - return u; -} - -inline marshall & -operator<<(marshall &m, rsm_protocol::transferres r) -{ - m << r.state; - m << r.last; - return m; -} - -inline unmarshall & -operator>>(unmarshall &u, rsm_protocol::transferres &r) -{ - u >> r.state; - u >> r.last; - return u; -} - -inline marshall & -operator<<(marshall &m, rsm_protocol::joinres r) -{ - m << r.log; - return m; -} + 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::joinres &r) -{ - u >> r.log; - return u; -} +MARSHALLABLE_STRUCT(rsm_protocol::transferres) -class rsm_test_protocol { - public: - enum xxstatus { OK, ERR}; - typedef int status; - enum rpc_numbers { - 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