Orocos Real-Time Toolkit
2.6.0
|
00001 /*************************************************************************** 00002 tag: The SourceWorks Tue Sep 7 00:55:18 CEST 2010 ReturnBase.hpp 00003 00004 ReturnBase.hpp - description 00005 ------------------- 00006 begin : Tue September 07 2010 00007 copyright : (C) 2010 The SourceWorks 00008 email : peter@thesourceworks.com 00009 00010 *************************************************************************** 00011 * This library is free software; you can redistribute it and/or * 00012 * modify it under the terms of the GNU General Public * 00013 * License as published by the Free Software Foundation; * 00014 * version 2 of the License. * 00015 * * 00016 * As a special exception, you may use this file as part of a free * 00017 * software library without restriction. Specifically, if other files * 00018 * instantiate templates or use macros or inline functions from this * 00019 * file, or you compile this file and link it with other files to * 00020 * produce an executable, this file does not by itself cause the * 00021 * resulting executable to be covered by the GNU General Public * 00022 * License. This exception does not however invalidate any other * 00023 * reasons why the executable file might be covered by the GNU General * 00024 * Public License. * 00025 * * 00026 * This library is distributed in the hope that it will be useful, * 00027 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00028 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00029 * Lesser General Public License for more details. * 00030 * * 00031 * You should have received a copy of the GNU General Public * 00032 * License along with this library; if not, write to the Free Software * 00033 * Foundation, Inc., 59 Temple Place, * 00034 * Suite 330, Boston, MA 02111-1307 USA * 00035 * * 00036 ***************************************************************************/ 00037 00038 00039 #ifndef ORO_RETURN_BASE_HPP 00040 #define ORO_RETURN_BASE_HPP 00041 00042 #include <boost/type_traits.hpp> 00043 00044 namespace RTT 00045 { 00046 namespace internal 00047 { 00052 template<int, class F> 00053 struct ReturnBaseImpl; 00054 00059 template<class F> 00060 struct ReturnBase 00061 : public ReturnBaseImpl<boost::function_traits<F>::arity, F> 00062 {}; 00063 00064 00065 template<class F> 00066 struct ReturnBaseImpl<0,F> 00067 { 00068 typedef typename boost::function_traits<F>::result_type result_type; 00069 virtual ~ReturnBaseImpl() {} 00070 00071 virtual result_type ret() = 0; 00072 }; 00073 00074 template<class F> 00075 struct ReturnBaseImpl<1,F> 00076 { 00077 typedef typename boost::function_traits<F>::result_type result_type; 00078 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00079 virtual ~ReturnBaseImpl() {} 00080 00081 virtual result_type ret(arg1_type a1) = 0; 00082 virtual result_type ret() = 0; 00083 }; 00084 00085 template<class F> 00086 struct ReturnBaseImpl<2,F> 00087 { 00088 typedef typename boost::function_traits<F>::result_type result_type; 00089 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00090 typedef typename boost::function_traits<F>::arg2_type arg2_type; 00091 virtual ~ReturnBaseImpl() {} 00092 00093 virtual result_type ret(arg1_type a1, arg2_type a2) = 0; 00094 virtual result_type ret() = 0; 00095 }; 00096 00097 template<class F> 00098 struct ReturnBaseImpl<3,F> 00099 { 00100 typedef typename boost::function_traits<F>::result_type result_type; 00101 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00102 typedef typename boost::function_traits<F>::arg2_type arg2_type; 00103 typedef typename boost::function_traits<F>::arg3_type arg3_type; 00104 virtual ~ReturnBaseImpl() {} 00105 00106 virtual result_type ret(arg1_type a1, arg2_type a2, arg3_type a3) = 0; 00107 virtual result_type ret() = 0; 00108 }; 00109 00110 template<class F> 00111 struct ReturnBaseImpl<4,F> 00112 { 00113 typedef typename boost::function_traits<F>::result_type result_type; 00114 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00115 typedef typename boost::function_traits<F>::arg2_type arg2_type; 00116 typedef typename boost::function_traits<F>::arg3_type arg3_type; 00117 typedef typename boost::function_traits<F>::arg4_type arg4_type; 00118 virtual ~ReturnBaseImpl() {} 00119 00120 virtual result_type ret(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4) = 0; 00121 virtual result_type ret() = 0; 00122 }; 00123 00124 template<class F> 00125 struct ReturnBaseImpl<5,F> 00126 { 00127 typedef typename boost::function_traits<F>::result_type result_type; 00128 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00129 typedef typename boost::function_traits<F>::arg2_type arg2_type; 00130 typedef typename boost::function_traits<F>::arg3_type arg3_type; 00131 typedef typename boost::function_traits<F>::arg4_type arg4_type; 00132 typedef typename boost::function_traits<F>::arg5_type arg5_type; 00133 virtual ~ReturnBaseImpl() {} 00134 00135 virtual result_type ret(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5) = 0; 00136 virtual result_type ret() = 0; 00137 }; 00138 00139 template<class F> 00140 struct ReturnBaseImpl<6,F> 00141 { 00142 typedef typename boost::function_traits<F>::result_type result_type; 00143 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00144 typedef typename boost::function_traits<F>::arg2_type arg2_type; 00145 typedef typename boost::function_traits<F>::arg3_type arg3_type; 00146 typedef typename boost::function_traits<F>::arg4_type arg4_type; 00147 typedef typename boost::function_traits<F>::arg5_type arg5_type; 00148 typedef typename boost::function_traits<F>::arg6_type arg6_type; 00149 virtual ~ReturnBaseImpl() {} 00150 00151 virtual result_type ret(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6) = 0; 00152 virtual result_type ret() = 0; 00153 }; 00154 00155 template<class F> 00156 struct ReturnBaseImpl<7,F> 00157 { 00158 typedef typename boost::function_traits<F>::result_type result_type; 00159 typedef typename boost::function_traits<F>::arg1_type arg1_type; 00160 typedef typename boost::function_traits<F>::arg2_type arg2_type; 00161 typedef typename boost::function_traits<F>::arg3_type arg3_type; 00162 typedef typename boost::function_traits<F>::arg4_type arg4_type; 00163 typedef typename boost::function_traits<F>::arg5_type arg5_type; 00164 typedef typename boost::function_traits<F>::arg6_type arg6_type; 00165 typedef typename boost::function_traits<F>::arg7_type arg7_type; 00166 virtual ~ReturnBaseImpl() {} 00167 00168 virtual result_type ret(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6, arg7_type a7) = 0; 00169 virtual result_type ret() = 0; 00170 }; 00171 } 00172 } 00173 #endif