portable.hpp

00001 /*
00002 This file is part of GraphLab.
00003 
00004 GraphLab is free software: you can redistribute it and/or modify
00005 it under the terms of the GNU Lesser General Public License as 
00006 published by the Free Software Foundation, either version 3 of 
00007 the License, or (at your option) any later version.
00008 
00009 GraphLab is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU Lesser General Public License for more details.
00013 
00014 You should have received a copy of the GNU Lesser General Public 
00015 License along with GraphLab.  If not, see <http://www.gnu.org/licenses/>.
00016 */
00017 
00018 #ifndef PORTABLE_HPP
00019 #define PORTABLE_HPP
00020 
00021 #include <string>
00022 #include <graphlab/util/generics/any.hpp>
00023 #include <graphlab/rpc/function_arg_types_def.hpp>
00024 #include <boost/preprocessor.hpp>
00025 
00026 namespace graphlab {
00027   
00028 /**
00029 \ingroup rpc
00030 Defines a simple macro called PORTABLE which is used to wrap
00031 a function name when issuing a portable call. 
00032 */  
00033 #define PORTABLE(f) graphlab::portable_call<typeof(f)*>(BOOST_PP_STRINGIZE(f)) 
00034 
00035 template <typename F>
00036 struct portable_call{
00037   typedef F f_type;
00038   portable_call(){}
00039   portable_call(std::string c): fname(c) {}
00040   std::string fname;
00041 };
00042 
00043 } // makespace graphlab
00044 
00045 /**
00046 \ingroup rpc_internal
00047 Make the portable call have the right return type
00048 */
00049 namespace boost {
00050 template <typename F>
00051 struct function_traits<graphlab::portable_call<F> > {
00052   typedef __GLRPC_FRESULT result_type;
00053 };
00054 
00055 
00056 template <typename F>
00057 struct function<graphlab::portable_call<F> > {
00058   typedef __GLRPC_FRESULT result_type;
00059 };
00060 
00061 }
00062 
00063 #include <graphlab/rpc/function_arg_types_undef.hpp>
00064 #endif
00065