Orocos Real-Time Toolkit  2.6.0
Collect.hpp
00001 /***************************************************************************
00002   tag: The SourceWorks  Tue Sep 7 00:55:18 CEST 2010  Collect.hpp
00003 
00004                         Collect.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_COLLECT_HPP
00040 #define ORO_COLLECT_HPP
00041 
00042 #include "CollectSignature.hpp"
00043 #include "../SendStatus.hpp"
00044 #include <boost/function.hpp>
00045 #include <boost/type_traits.hpp>
00046 
00047 namespace RTT
00048 {
00049     namespace internal
00050     {
00051         template<int, class Ft, class BaseImpl>
00052         struct CollectImpl;
00053 
00059         template<class F, class BaseImpl>
00060         struct Collect
00061             : public CollectImpl< boost::function_traits< typename CollectType<F>::Ft >::arity, typename CollectType<F>::Ft, BaseImpl >
00062         {
00063             typedef typename boost::function_traits< F >::result_type result_type;
00064             using CollectImpl< boost::function_traits< typename CollectType<F>::Ft >::arity, typename CollectType<F>::Ft, BaseImpl >::collectIfDone;
00065 
00066                 SendStatus collect()
00067                 {
00068                     return BaseImpl::collect_impl();
00069                 }
00070 
00071                 SendStatus collectIfDone()
00072                 {
00073                     return BaseImpl::collectIfDone_impl();
00074                 }
00075 
00076             result_type ret()
00077             {
00078                 return BaseImpl::ret_impl();
00079             }
00080 
00081         };
00082 
00083         template<class Ft, class BaseImpl>
00084         struct CollectImpl<0,Ft,BaseImpl>
00085             : public BaseImpl
00086         {
00087             virtual ~CollectImpl() {}
00088         };
00089 
00090         template<class Ft, class BaseImpl>
00091         struct CollectImpl<1,Ft,BaseImpl>
00092         : public BaseImpl
00093         {
00094             typedef typename boost::function<Ft>::arg1_type arg1_type;
00095             virtual ~CollectImpl() {}
00096 
00101             virtual SendStatus collect()
00102             {
00103                 return BaseImpl::collect_impl();
00104             }
00110             virtual SendStatus collect(arg1_type a1)
00111             {
00112                 return BaseImpl::collect_impl(a1);
00113             }
00114             virtual SendStatus collectIfDone(arg1_type a1)
00115             {
00116                 return BaseImpl::collectIfDone_impl(a1);
00117             }
00118         };
00119 
00120         template<class Ft, class BaseImpl>
00121         struct CollectImpl<2,Ft,BaseImpl>
00122         : public BaseImpl
00123         {
00124             typedef typename boost::function<Ft>::arg1_type arg1_type;
00125             typedef typename boost::function<Ft>::arg2_type arg2_type;
00126             virtual ~CollectImpl() {}
00127 
00132             virtual SendStatus collect()
00133             {
00134                 return BaseImpl::collect_impl();
00135             }
00141             virtual SendStatus collect(arg1_type a1, arg2_type a2)
00142             {
00143                 return BaseImpl::collect_impl(a1,a2);
00144             }
00145             virtual SendStatus collectIfDone(arg1_type a1, arg2_type a2)
00146             {
00147                 return BaseImpl::collectIfDone_impl(a1,a2);
00148             }
00149         };
00150 
00151         template<class Ft, class BaseImpl>
00152         struct CollectImpl<3,Ft,BaseImpl>
00153         : public BaseImpl
00154         {
00155             typedef typename boost::function<Ft>::arg1_type arg1_type;
00156             typedef typename boost::function<Ft>::arg2_type arg2_type;
00157             typedef typename boost::function<Ft>::arg3_type arg3_type;
00158             virtual ~CollectImpl() {}
00159 
00164             virtual SendStatus collect()
00165             {
00166                 return BaseImpl::collect_impl();
00167             }
00173             virtual SendStatus collect(arg1_type a1, arg2_type a2, arg3_type a3)
00174             {
00175                 return BaseImpl::collect_impl(a1,a2,a3);
00176             }
00177             virtual SendStatus collectIfDone(arg1_type a1, arg2_type a2, arg3_type a3)
00178             {
00179                 return BaseImpl::collectIfDone_impl(a1,a2,a3);
00180             }
00181         };
00182 
00183         template<class Ft, class BaseImpl>
00184         struct CollectImpl<4,Ft,BaseImpl>
00185         : public BaseImpl
00186         {
00187             typedef typename boost::function<Ft>::arg1_type arg1_type;
00188             typedef typename boost::function<Ft>::arg2_type arg2_type;
00189             typedef typename boost::function<Ft>::arg3_type arg3_type;
00190             typedef typename boost::function<Ft>::arg4_type arg4_type;
00191             virtual ~CollectImpl() {}
00192 
00197             virtual SendStatus collect()
00198             {
00199                 return BaseImpl::collect_impl();
00200             }
00206             virtual SendStatus collect(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
00207             {
00208                 return BaseImpl::collect_impl(a1,a2,a3,a4);
00209             }
00210             virtual SendStatus collectIfDone(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4)
00211             {
00212                 return BaseImpl::collectIfDone_impl(a1,a2,a3,a4);
00213             }
00214         };
00215 
00216         template<class Ft, class BaseImpl>
00217         struct CollectImpl<6,Ft,BaseImpl>
00218         : public BaseImpl
00219         {
00220             typedef typename boost::function<Ft>::arg1_type arg1_type;
00221             typedef typename boost::function<Ft>::arg2_type arg2_type;
00222             typedef typename boost::function<Ft>::arg3_type arg3_type;
00223             typedef typename boost::function<Ft>::arg4_type arg4_type;
00224             typedef typename boost::function<Ft>::arg5_type arg5_type;
00225             typedef typename boost::function<Ft>::arg6_type arg6_type;
00226             virtual ~CollectImpl() {}
00227 
00232             virtual SendStatus collect()
00233             {
00234                 return BaseImpl::collect_impl();
00235             }
00241             virtual SendStatus collect(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6)
00242             {
00243                 return BaseImpl::collect_impl(a1,a2,a3,a4,a5,a6);
00244             }
00245             virtual SendStatus collectIfDone(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5, arg6_type a6)
00246             {
00247                 return BaseImpl::collectIfDone_impl(a1,a2,a3,a4,a5,a6);
00248             }
00249         };
00250 
00251         template<class Ft, class BaseImpl>
00252         struct CollectImpl<5,Ft,BaseImpl>
00253         : public BaseImpl
00254         {
00255             typedef typename boost::function<Ft>::arg1_type arg1_type;
00256             typedef typename boost::function<Ft>::arg2_type arg2_type;
00257             typedef typename boost::function<Ft>::arg3_type arg3_type;
00258             typedef typename boost::function<Ft>::arg4_type arg4_type;
00259             typedef typename boost::function<Ft>::arg5_type arg5_type;
00260             virtual ~CollectImpl() {}
00261 
00266             virtual SendStatus collect()
00267             {
00268                 return BaseImpl::collect_impl();
00269             }
00275             virtual SendStatus collect(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5)
00276             {
00277                 return BaseImpl::collect_impl(a1,a2,a3,a4,a5);
00278             }
00279             virtual SendStatus collectIfDone(arg1_type a1, arg2_type a2, arg3_type a3, arg4_type a4, arg5_type a5)
00280             {
00281                 return BaseImpl::collectIfDone_impl(a1,a2,a3,a4,a5);
00282             }
00283         };
00284 
00285     }
00286 }
00287 #endif