Partially fixed a bug in the test suite that led to test runs randomly failing.
[invirt/third/libt4.git] / rsm_protocol.h
index 53908f3..a2d13c2 100644 (file)
@@ -14,12 +14,16 @@ class rsm_client_protocol {
 };
 
 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++; }
+
+    MEMBERS(vid, seqno)
+    LEXICOGRAPHIC_COMPARISON(viewstamp)
 };
 
+MARSHALLABLE(viewstamp)
+
 class rsm_protocol {
     public:
         enum status : status_t { OK, ERR, BUSY};
@@ -33,28 +37,12 @@ class rsm_protocol {
         struct transferres {
             string state;
             viewstamp last;
+
+            MEMBERS(state, last)
         };
 };
 
-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); }
-
-inline marshall& operator<<(marshall &m, viewstamp v) {
-    return m << v.vid << v.seqno;
-}
-
-inline unmarshall& operator>>(unmarshall &u, viewstamp &v) {
-    return u >> v.vid >> v.seqno;
-}
-
-inline marshall & operator<<(marshall &m, rsm_protocol::transferres r) {
-    return m << r.state << r.last;
-}
-
-inline unmarshall & operator>>(unmarshall &u, rsm_protocol::transferres &r) {
-    return u >> r.state >> r.last;
-}
+MARSHALLABLE(rsm_protocol::transferres)
 
 class rsm_test_protocol {
     public: