More clean-ups and cool template stuff
[invirt/third/libt4.git] / paxos_protocol.h
index 734ca51..f2bdb3f 100644 (file)
 #include "rpc/rpc.h"
 
 struct prop_t {
-  unsigned n;
-  std::string m;
+    unsigned n;
+    std::string m;
 };
 
 class paxos_protocol {
- public:
-  enum xxstatus { OK, ERR };
-  typedef int status;
-  enum rpc_numbers {
-    preparereq = 0x11001,
-    acceptreq,
-    decidereq,
-    heartbeat,
-  };
-
-  struct preparearg {
-    unsigned instance;
-    prop_t n;
-  };
-
-  struct prepareres {
-    bool oldinstance;
-    bool accept;
-    prop_t n_a;
-    std::string v_a;
-  };
-
-  struct acceptarg {
-    unsigned instance;
-    prop_t n;
-    std::string v;
-  };
-
-  struct decidearg {
-    unsigned instance;
-    std::string v;
-  };
-
+    public:
+        enum status : status_t { OK, ERR };
+        enum rpc_numbers : proc_t {
+            preparereq = 0x11001,
+            acceptreq,
+            decidereq,
+            heartbeat,
+        };
+
+        struct preparearg {
+            unsigned instance;
+            prop_t n;
+        };
+
+        struct prepareres {
+            bool oldinstance;
+            bool accept;
+            prop_t n_a;
+            std::string v_a;
+        };
+
+        struct acceptarg {
+            unsigned instance;
+            prop_t n;
+            std::string v;
+        };
+
+        struct decidearg {
+            unsigned instance;
+            std::string v;
+        };
 };
 
-inline unmarshall &
-operator>>(unmarshall &u, prop_t &a)
-{
-  u >> a.n;
-  u >> a.m;
-  return u;
+inline unmarshall & operator>>(unmarshall &u, prop_t &a) {
+    return u >> a.n >> a.m;
 }
 
-inline marshall &
-operator<<(marshall &m, prop_t a)
-{
-  m << a.n;
-  m << a.m;
-  return m;
+inline marshall & operator<<(marshall &m, prop_t a) {
+    return m << a.n << a.m;
 }
 
-inline unmarshall &
-operator>>(unmarshall &u, paxos_protocol::preparearg &a)
-{
-  u >> a.instance;
-  u >> a.n;
-  return u;
+inline unmarshall & operator>>(unmarshall &u, paxos_protocol::preparearg &a) {
+    return u >> a.instance >> a.n;
 }
 
-inline marshall &
-operator<<(marshall &m, paxos_protocol::preparearg a)
-{
-  m << a.instance;
-  m << a.n;
-  return m;
+inline marshall & operator<<(marshall &m, paxos_protocol::preparearg a) {
+    return m << a.instance << a.n;
 }
 
-inline unmarshall &
-operator>>(unmarshall &u, paxos_protocol::prepareres &r)
-{
-  u >> r.oldinstance;
-  u >> r.accept;
-  u >> r.n_a;
-  u >> r.v_a;
-  return u;
+inline unmarshall & operator>>(unmarshall &u, paxos_protocol::prepareres &r) {
+    return u >> r.oldinstance >> r.accept >> r.n_a >> r.v_a;
 }
 
-inline marshall &
-operator<<(marshall &m, paxos_protocol::prepareres r)
-{
-  m << r.oldinstance;
-  m << r.accept;
-  m << r.n_a;
-  m << r.v_a;
-  return m;
+inline marshall & operator<<(marshall &m, paxos_protocol::prepareres r) {
+    return m << r.oldinstance << r.accept << r.n_a << r.v_a;
 }
 
-inline unmarshall &
-operator>>(unmarshall &u, paxos_protocol::acceptarg &a)
-{
-  u >> a.instance;
-  u >> a.n;
-  u >> a.v;
-  return u;
+inline unmarshall & operator>>(unmarshall &u, paxos_protocol::acceptarg &a) {
+    return u >> a.instance >> a.n >> a.v;
 }
 
-inline marshall &
-operator<<(marshall &m, paxos_protocol::acceptarg a)
-{
-  m << a.instance;
-  m << a.n;
-  m << a.v;
-  return m;
+inline marshall & operator<<(marshall &m, paxos_protocol::acceptarg a) {
+    return m << a.instance << a.n << a.v;
 }
 
-inline unmarshall &
-operator>>(unmarshall &u, paxos_protocol::decidearg &a)
-{
-  u >> a.instance;
-  u >> a.v;
-  return u;
+inline unmarshall & operator>>(unmarshall &u, paxos_protocol::decidearg &a) {
+    return u >> a.instance >> a.v;
 }
 
-inline marshall &
-operator<<(marshall &m, paxos_protocol::decidearg a)
-{
-  m << a.instance;
-  m << a.v;
-  return m;
+inline marshall & operator<<(marshall &m, paxos_protocol::decidearg a) {
+    return m << a.instance << a.v;
 }
 
 #endif