RPC procedures are now identified via a struct containing a string name.
[invirt/third/libt4.git] / rpc / rpc.h
index ddf15f9..9464e57 100644 (file)
--- a/rpc/rpc.h
+++ b/rpc/rpc.h
@@ -42,8 +42,6 @@ struct is_valid_registration<
 class rpcc : private connection_delegate {
     private:
         using proc_id_t = rpc_protocol::proc_id_t;
-        template <class S>
-        using proc_t = rpc_protocol::proc_t<S>;
         using nonce_t = rpc_protocol::nonce_t;
         using xid_t = rpc_protocol::xid_t;
 
@@ -94,16 +92,7 @@ class rpcc : private connection_delegate {
         request dup_req_;
         int xid_rep_done_ = -1;
 
-        int call_marshalled(proc_id_t proc, milliseconds to, string & rep, marshall & req);
-
-        template<class R>
-        inline int call_m(proc_id_t proc, milliseconds to, R & r, marshall && req) {
-            string rep;
-            int intret = call_marshalled(proc, to, rep, req);
-            if (intret >= 0)
-                VERIFY(unmarshall(rep, true, r).okdone()); // guaranteed by static type checking
-            return intret;
-        }
+        int call_marshalled(const rpc_protocol::proc_t & proc, milliseconds to, string & rep, const marshall & req);
 
         bool got_pdu(const shared_ptr<connection> & c, const string & b);
 
@@ -127,14 +116,19 @@ class rpcc : private connection_delegate {
         void cancel(lock & m_lock);
 
         template<class P, class R, typename ...Args>
-        inline int call(proc_t<P> proc, R & r, const Args & ... args) {
+        inline int call(const rpc_protocol::proc_checked_t<P> & proc, R & r, const Args & ... args) {
             return call_timeout(proc, rpc::to_max, r, args...);
         }
 
         template<class P, class R, typename ...Args>
-        inline int call_timeout(proc_t<P> proc, milliseconds to, R & r, const Args & ... args) {
+        inline int call_timeout(const rpc_protocol::proc_checked_t<P> & proc, milliseconds to, R & r, const Args & ... args) {
             static_assert(is_valid_call<P, R, Args...>::value, "RPC called with incorrect argument types");
-            return call_m(proc.id, to, r, std::forward<marshall>(marshall(args...)));
+            string rep;
+            int intret = call_marshalled(proc, to, rep, marshall(args...));
+            if (intret >= 0) {
+                VERIFY(unmarshall(rep, true, r).okdone()); // guaranteed by static type checking
+            }
+            return intret;
         }
 };
 
@@ -142,8 +136,6 @@ class rpcc : private connection_delegate {
 class rpcs : private connection_delegate {
     private:
         using proc_id_t = rpc_protocol::proc_id_t;
-        template <class S>
-        using proc_t = rpc_protocol::proc_t<S>;
         using nonce_t = rpc_protocol::nonce_t;
         using xid_t = rpc_protocol::xid_t;
 
@@ -208,7 +200,8 @@ class rpcs : private connection_delegate {
 
         void set_reachable(bool r) { reachable_ = r; }
 
-        template<class P, class F, class C=void> inline void reg(proc_t<P> proc, F f, C *c=nullptr) {
+        template<class P, class F, class C=void>
+        inline void reg(const rpc_protocol::proc_checked_t<P> & proc, F f, C *c=nullptr) {
             static_assert(is_valid_registration<P, F>::value, "RPC handler registered with incorrect argument types");
             struct ReturnOnFailure {
                 static inline int unmarshall_args_failure() {