Derecho  0.9
Distributed systems toolkit for RDMA
register_rpc_functions.hpp
Go to the documentation of this file.
1 #pragma once
2 #include "detail/rpc_utils.hpp"
3 #include <mutils/macro_utils.hpp>
4 #include <tuple>
5 
14 #define REGISTER_RPC_FUNCTIONS2(classname, a) \
15  static auto register_functions() { \
16  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a)); \
17  }
18 #define REGISTER_RPC_FUNCTIONS3(classname, a, b) \
19  static auto register_functions() { \
20  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
21  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b)); \
22  }
23 #define REGISTER_RPC_FUNCTIONS4(classname, a, b, c) \
24  static auto register_functions() { \
25  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
26  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
27  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c)); \
28  }
29 #define REGISTER_RPC_FUNCTIONS5(classname, a, b, c, d) \
30  static auto register_functions() { \
31  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
32  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
33  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
34  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d)); \
35  }
36 #define REGISTER_RPC_FUNCTIONS6(classname, a, b, c, d, e) \
37  static auto register_functions() { \
38  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
39  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
40  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
41  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
42  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e)); \
43  }
44 #define REGISTER_RPC_FUNCTIONS7(classname, a, b, c, d, e, f) \
45  static auto register_functions() { \
46  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
47  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
48  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
49  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
50  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
51  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f)); \
52  }
53 #define REGISTER_RPC_FUNCTIONS8(classname, a, b, c, d, e, f, g) \
54  static auto register_functions() { \
55  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
56  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
57  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
58  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
59  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
60  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
61  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g)); \
62  }
63 #define REGISTER_RPC_FUNCTIONS9(classname, a, b, c, d, e, f, g, h) \
64  static auto register_functions() { \
65  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
66  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
67  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
68  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
69  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
70  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
71  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
72  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h)); \
73  }
74 #define REGISTER_RPC_FUNCTIONS10(classname, a, b, c, d, e, f, g, h, i) \
75  static auto register_functions() { \
76  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
77  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
78  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
79  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
80  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
81  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
82  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
83  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
84  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i)); \
85  }
86 #define REGISTER_RPC_FUNCTIONS11(classname, a, b, c, d, e, f, g, h, i, j) \
87  static auto register_functions() { \
88  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
89  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
90  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
91  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
92  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
93  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
94  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
95  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
96  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i), \
97  derecho::rpc::tag<CT_STRING(j)::hash()>(&classname::j)); \
98  }
99 #define REGISTER_RPC_FUNCTIONS12(classname, a, b, c, d, e, f, g, h, i, j, k) \
100  static auto register_functions() { \
101  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
102  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
103  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
104  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
105  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
106  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
107  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
108  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
109  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i), \
110  derecho::rpc::tag<CT_STRING(j)::hash()>(&classname::j), \
111  derecho::rpc::tag<CT_STRING(k)::hash()>(&classname::k)); \
112  }
113 #define REGISTER_RPC_FUNCTIONS13(classname, a, b, c, d, e, f, g, h, i, j, k, l) \
114  static auto register_functions() { \
115  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
116  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
117  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
118  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
119  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
120  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
121  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
122  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
123  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i), \
124  derecho::rpc::tag<CT_STRING(j)::hash()>(&classname::j), \
125  derecho::rpc::tag<CT_STRING(k)::hash()>(&classname::k), \
126  derecho::rpc::tag<CT_STRING(l)::hash()>(&classname::l)); \
127  }
128 #define REGISTER_RPC_FUNCTIONS14(classname, a, b, c, d, e, f, g, h, i, j, k, l, m) \
129  static auto register_functions() { \
130  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
131  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
132  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
133  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
134  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
135  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
136  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
137  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
138  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i), \
139  derecho::rpc::tag<CT_STRING(j)::hash()>(&classname::j), \
140  derecho::rpc::tag<CT_STRING(k)::hash()>(&classname::k), \
141  derecho::rpc::tag<CT_STRING(l)::hash()>(&classname::l), \
142  derecho::rpc::tag<CT_STRING(m)::hash()>(&classname::m)); \
143  }
144 #define REGISTER_RPC_FUNCTIONS15(classname, a, b, c, d, e, f, g, h, i, j, k, l, m, n) \
145  static auto register_functions() { \
146  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
147  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
148  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
149  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
150  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
151  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
152  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
153  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
154  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i), \
155  derecho::rpc::tag<CT_STRING(j)::hash()>(&classname::j), \
156  derecho::rpc::tag<CT_STRING(k)::hash()>(&classname::k), \
157  derecho::rpc::tag<CT_STRING(l)::hash()>(&classname::l), \
158  derecho::rpc::tag<CT_STRING(m)::hash()>(&classname::m), \
159  derecho::rpc::tag<CT_STRING(n)::hash()>(&classname::n)); \
160  }
161 #define REGISTER_RPC_FUNCTIONS16(classname, a, b, c, d, e, f, g, h, i, j, k, l, m, n, o) \
162  static auto register_functions() { \
163  return std::make_tuple(derecho::rpc::tag<CT_STRING(a)::hash()>(&classname::a), \
164  derecho::rpc::tag<CT_STRING(b)::hash()>(&classname::b), \
165  derecho::rpc::tag<CT_STRING(c)::hash()>(&classname::c), \
166  derecho::rpc::tag<CT_STRING(d)::hash()>(&classname::d), \
167  derecho::rpc::tag<CT_STRING(e)::hash()>(&classname::e), \
168  derecho::rpc::tag<CT_STRING(f)::hash()>(&classname::f), \
169  derecho::rpc::tag<CT_STRING(g)::hash()>(&classname::g), \
170  derecho::rpc::tag<CT_STRING(h)::hash()>(&classname::h), \
171  derecho::rpc::tag<CT_STRING(i)::hash()>(&classname::i), \
172  derecho::rpc::tag<CT_STRING(j)::hash()>(&classname::j), \
173  derecho::rpc::tag<CT_STRING(k)::hash()>(&classname::k), \
174  derecho::rpc::tag<CT_STRING(l)::hash()>(&classname::l), \
175  derecho::rpc::tag<CT_STRING(m)::hash()>(&classname::m), \
176  derecho::rpc::tag<CT_STRING(n)::hash()>(&classname::n), \
177  derecho::rpc::tag<CT_STRING(o)::hash()>(&classname::o)); \
178  }
179 
180 #define REGISTER_RPC_FUNCTIONS_IMPL2(count, ...) REGISTER_RPC_FUNCTIONS##count(__VA_ARGS__)
181 #define REGISTER_RPC_FUNCTIONS_IMPL(count, ...) REGISTER_RPC_FUNCTIONS_IMPL2(count, __VA_ARGS__)
182 
192 #define REGISTER_RPC_FUNCTIONS(...) REGISTER_RPC_FUNCTIONS_IMPL(VA_NARGS(__VA_ARGS__), __VA_ARGS__)
193 
203 #define RPC_NAME(...) \
204  CT_STRING(__VA_ARGS__) \
205  ::hash()