24 #ifndef IS_RPC_CALL_HPP
25 #define IS_RPC_CALL_HPP
26 #include <boost/type_traits/remove_pointer.hpp>
27 #include <boost/type_traits/remove_const.hpp>
28 #include <boost/type_traits/function_traits.hpp>
29 #include <boost/type_traits/is_same.hpp>
30 #include <boost/mpl/if.hpp>
31 #include <boost/mpl/and.hpp>
32 #include <boost/mpl/bool.hpp>
33 #include <boost/mpl/less.hpp>
34 #include <boost/mpl/comparison.hpp>
35 #include <boost/mpl/int.hpp>
37 #include <graphlab/rpc/dc_types.hpp>
38 #include <graphlab/rpc/function_arg_types_def.hpp>
42 class distributed_control;
45 namespace is_rpc_call_detail {
52 struct less_than_2_args {
53 typedef typename boost::mpl::bool_<__GLRPC_FARITY < 2 >::type type;
63 template <
typename F,
size_t nargs>
65 typedef __GLRPC_NIF0 arg1_type;
66 typedef __GLRPC_NIF1 arg2_type;
71 struct get_args<F, 0>{
72 typedef void arg1_type;
73 typedef void arg2_type;
78 struct get_args<F, 1>{
79 typedef __GLRPC_NIF0 arg1_type;
80 typedef void arg2_type;
86 struct check_first_arg {
87 typedef typename boost::is_same<typename get_args<F,__GLRPC_FARITY>::arg1_type, distributed_control>::type type;
91 struct check_second_arg {
92 typedef typename boost::is_integral<typename get_args<F,__GLRPC_FARITY>::arg2_type>::type type;
104 template <
typename F>
106 typedef typename boost::mpl::if_< typename is_rpc_call_detail::less_than_2_args<F>::type,
108 typename boost::mpl::and_<
109 typename is_rpc_call_detail::check_first_arg<F>::type,
110 typename is_rpc_call_detail::check_second_arg<F>::type>::type >::type type;
116 #define BLOCK_VAR_ARGS(Z,N,_) \
117 template <typename RetType BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, typename T)> \
118 struct is_rpc_call<RetType (BOOST_PP_ENUM_PARAMS(N, T) BOOST_PP_COMMA_IF(N) ...)> { \
119 typedef boost::false_type type; \
122 template <typename RetType BOOST_PP_COMMA_IF(N) BOOST_PP_ENUM_PARAMS(N, typename T)> \
123 struct is_rpc_call<RetType (*)(BOOST_PP_ENUM_PARAMS(N, T) BOOST_PP_COMMA_IF(N) ...)> { \
124 typedef boost::false_type type; \
126 BOOST_PP_REPEAT(6, BLOCK_VAR_ARGS, _)
127 #undef BLOCK_VAR_ARGS
129 #define GEN_GET_USER_ARG(Z,N,_) \
130 template <typename F, typename BoolType> \
131 struct BOOST_PP_CAT(get_cleaned_rpc_or_basic_arg, N) { \
132 typedef BOOST_PP_CAT(__GLRPC_NIF, N) arg_type; \
134 template <typename F> \
135 struct BOOST_PP_CAT(get_cleaned_rpc_or_basic_arg, N) <F, boost::mpl::bool_<true> > { \
136 typedef BOOST_PP_CAT(__GLRPC_F, N) arg_type; \
138 template <typename F> \
139 struct BOOST_PP_CAT(get_cleaned_user_arg, N) { \
140 typedef typename BOOST_PP_CAT(get_cleaned_rpc_or_basic_arg, N)<F,typename is_rpc_call<F>::type>::arg_type arg_type; \
143 BOOST_PP_REPEAT(6, GEN_GET_USER_ARG, _)
144 #undef GEN_GET_USER_ARG
149 #include <graphlab/rpc/function_arg_types_undef.hpp>