X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5fd8cc8409d0efadc07dfe8d6774ad9ff477663d..2546a41ad36fdc9ef6471cb35a1d56930ae1b527:/rsm_protocol.h diff --git a/rsm_protocol.h b/rsm_protocol.h index a27ef83..6b508d8 100644 --- a/rsm_protocol.h +++ b/rsm_protocol.h @@ -1,116 +1,87 @@ #ifndef rsm_protocol_h #define rsm_protocol_h -#include "rpc.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, - }; + public: + enum status : status_t {OK, ERR, NOTPRIMARY, BUSY}; + enum rpc_numbers : proc_t { + invoke = 0x9001, + members, + }; }; - 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++; - }; + 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, - }; - - struct transferres { - std::string state; - viewstamp last; - }; - - struct joinres { - std::string log; - }; + public: + enum status : status_t { OK, ERR, BUSY}; + enum rpc_numbers : proc_t { + invoke = 0x10001, + transferreq, + transferdonereq, + joinreq, + }; + + struct transferres { + std::string state; + viewstamp last; + }; + + struct joinres { + std::string log; + }; }; inline bool operator==(viewstamp a, viewstamp b) { - return a.vid == b.vid && a.seqno == b.seqno; + return a.vid == b.vid && a.seqno == b.seqno; } inline bool operator>(viewstamp a, viewstamp b) { - return (a.vid > b.vid) || ((a.vid == b.vid) && a.seqno > b.seqno); + return (a.vid > b.vid) || ((a.vid == b.vid) && a.seqno > b.seqno); } inline bool operator!=(viewstamp a, viewstamp b) { - return a.vid != b.vid || a.seqno != b.seqno; + return a.vid != b.vid || a.seqno != b.seqno; } -inline marshall& operator<<(marshall &m, viewstamp v) -{ - m << v.vid; - m << v.seqno; - return m; +inline marshall& operator<<(marshall &m, viewstamp v) { + return m << v.vid << v.seqno; } inline unmarshall& operator>>(unmarshall &u, viewstamp &v) { - u >> v.vid; - u >> v.seqno; - return u; + return u >> v.vid >> v.seqno; } -inline marshall & -operator<<(marshall &m, rsm_protocol::transferres r) -{ - m << r.state; - m << r.last; - return m; +inline marshall & operator<<(marshall &m, rsm_protocol::transferres r) { + return m << r.state << r.last; } -inline unmarshall & -operator>>(unmarshall &u, rsm_protocol::transferres &r) -{ - u >> r.state; - u >> r.last; - return u; +inline unmarshall & operator>>(unmarshall &u, rsm_protocol::transferres &r) { + return u >> r.state >> r.last; } -inline marshall & -operator<<(marshall &m, rsm_protocol::joinres r) -{ - m << r.log; - return m; +inline marshall & operator<<(marshall &m, rsm_protocol::joinres r) { + return m << r.log; } -inline unmarshall & -operator>>(unmarshall &u, rsm_protocol::joinres &r) -{ - u >> r.log; - return u; +inline unmarshall & operator>>(unmarshall &u, rsm_protocol::joinres &r) { + return u >> r.log; } class rsm_test_protocol { - public: - enum xxstatus { OK, ERR}; - typedef int status; - enum rpc_numbers { - net_repair = 0x12001, - breakpoint = 0x12002, - }; + public: + enum status : status_t {OK, ERR}; + enum rpc_numbers : proc_t { + net_repair = 0x12001, + breakpoint = 0x12002, + }; }; #endif