Signal.hpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 #ifndef ORO_CORELIB_SIGNAL_HPP
00040 #define ORO_CORELIB_SIGNAL_HPP
00041
00042 #define OROCOS_SIGNAL_MAX_ARGS 4
00043
00044 #include <boost/type_traits/function_traits.hpp>
00045 #include <boost/function.hpp>
00046 #include "Handle.hpp"
00047 #include "impl/signal0.hpp"
00048 #include "impl/signal1.hpp"
00049 #include "impl/signal2.hpp"
00050 #include "impl/signal3.hpp"
00051 #include "impl/signal4.hpp"
00052
00053 namespace RTT {
00054 namespace detail {
00055 template<int Arity,
00056 typename Signature,
00057 typename SlotFunction>
00058 class real_get_signal_impl;
00059
00060 template<typename Signature,
00061 typename SlotFunction>
00062 class real_get_signal_impl<0, Signature,
00063 SlotFunction>
00064 {
00065 typedef boost::function_traits<Signature> traits;
00066
00067 public:
00068 typedef signal0<typename traits::result_type,
00069 SlotFunction> type;
00070 };
00071
00072 template<typename Signature,
00073 typename SlotFunction>
00074 class real_get_signal_impl<1, Signature,
00075 SlotFunction>
00076 {
00077 typedef boost::function_traits<Signature> traits;
00078
00079 public:
00080 typedef signal1<typename traits::result_type,
00081 typename traits::arg1_type,
00082 SlotFunction> type;
00083 };
00084
00085 template<typename Signature,
00086 typename SlotFunction>
00087 class real_get_signal_impl<2, Signature,
00088 SlotFunction>
00089 {
00090 typedef boost::function_traits<Signature> traits;
00091
00092 public:
00093 typedef signal2<typename traits::result_type,
00094 typename traits::arg1_type,
00095 typename traits::arg2_type,
00096 SlotFunction> type;
00097 };
00098
00099 template<typename Signature,
00100 typename SlotFunction>
00101 class real_get_signal_impl<3, Signature,
00102 SlotFunction>
00103 {
00104 typedef boost::function_traits<Signature> traits;
00105
00106 public:
00107 typedef signal3<typename traits::result_type,
00108 typename traits::arg1_type,
00109 typename traits::arg2_type,
00110 typename traits::arg3_type,
00111 SlotFunction> type;
00112 };
00113
00114 template<typename Signature,
00115 typename SlotFunction>
00116 class real_get_signal_impl<4, Signature,
00117 SlotFunction>
00118 {
00119 typedef boost::function_traits<Signature> traits;
00120
00121 public:
00122 typedef signal4<typename traits::result_type,
00123 typename traits::arg1_type,
00124 typename traits::arg2_type,
00125 typename traits::arg3_type,
00126 typename traits::arg4_type,
00127 SlotFunction> type;
00128 };
00129
00130 template<typename Signature,
00131 typename SlotFunction>
00132 struct get_signal_impl :
00133 public real_get_signal_impl<(boost::function_traits<Signature>::arity),
00134 Signature,
00135 SlotFunction>
00136 {
00137 };
00138
00144 template<
00145 typename Signature,
00146 typename SlotFunction = boost::function<Signature>
00147 >
00148 class signal :
00149 public detail::get_signal_impl<Signature,
00150 SlotFunction>::type
00151 {
00152 protected:
00153 typedef typename detail::get_signal_impl< Signature,
00154 SlotFunction>::type base_type;
00155
00156 public:
00157 signal() {}
00158 };
00159
00160 }
00161
00162 }
00163
00164
00165 #endif
00166