More logging clean-ups. Static type-checking for RPC calls and
[invirt/third/libt4.git] / lock_protocol.h
index 61f0998..5589c07 100644 (file)
@@ -3,29 +3,27 @@
 #ifndef lock_protocol_h
 #define lock_protocol_h
 
+#include "types.h"
 #include "rpc/rpc.h"
-#include <string>
 
-class lock_protocol {
-    public:
-        enum xxstatus { OK, RETRY, RPCERR, NOENT, IOERR };
-        typedef int status;
-        typedef std::string lockid_t;
-        typedef unsigned long long xid_t;
-        enum rpc_numbers {
-            acquire = 0x7001,
-            release,
-            stat
-        };
+typedef string callback_t;
+
+namespace lock_protocol {
+    enum status : rpc_protocol::status { OK, RETRY, RPCERR, NOENT, IOERR };
+    using lockid_t = string;
+    using xid_t = uint64_t;
+    REMOTE_PROCEDURE_BASE(0x7000);
+    REMOTE_PROCEDURE(1, acquire, (int &, lockid_t, callback_t, xid_t));
+    REMOTE_PROCEDURE(2, release, (int &, lockid_t, callback_t, xid_t));
+    REMOTE_PROCEDURE(3, stat, (int &, lockid_t, callback_t));
 };
 
-class rlock_protocol {
-    public:
-        enum xxstatus { OK, RPCERR };
-        typedef int status;
-        enum rpc_numbers {
-            revoke = 0x8001,
-            retry = 0x8002
-        };
+namespace rlock_protocol {
+    using lockid_t = lock_protocol::lockid_t;
+    using xid_t = lock_protocol::xid_t;
+    enum status : rpc_protocol::status { OK, RPCERR };
+    REMOTE_PROCEDURE_BASE(0x8000);
+    REMOTE_PROCEDURE(1, revoke, (int &, lockid_t, xid_t));
+    REMOTE_PROCEDURE(2, retry, (int &, lockid_t, xid_t));
 };
 #endif