[29] | 1 | // Boost.Signals library |
---|
| 2 | |
---|
| 3 | // Copyright Douglas Gregor 2001-2006. Use, modification and |
---|
| 4 | // distribution is subject to the Boost Software License, Version |
---|
| 5 | // 1.0. (See accompanying file LICENSE_1_0.txt or copy at |
---|
| 6 | // http://www.boost.org/LICENSE_1_0.txt) |
---|
| 7 | |
---|
| 8 | // For more information, see http://www.boost.org/libs/signals |
---|
| 9 | |
---|
| 10 | #ifndef BOOST_SIGNAL_HPP |
---|
| 11 | #define BOOST_SIGNAL_HPP |
---|
| 12 | |
---|
| 13 | #ifndef BOOST_SIGNALS_MAX_ARGS |
---|
| 14 | # define BOOST_SIGNALS_MAX_ARGS 10 |
---|
| 15 | #endif |
---|
| 16 | |
---|
| 17 | #include <boost/config.hpp> |
---|
| 18 | #include <boost/type_traits/function_traits.hpp> |
---|
| 19 | #include <boost/signals/signal0.hpp> |
---|
| 20 | #include <boost/signals/signal1.hpp> |
---|
| 21 | #include <boost/signals/signal2.hpp> |
---|
| 22 | #include <boost/signals/signal3.hpp> |
---|
| 23 | #include <boost/signals/signal4.hpp> |
---|
| 24 | #include <boost/signals/signal5.hpp> |
---|
| 25 | #include <boost/signals/signal6.hpp> |
---|
| 26 | #include <boost/signals/signal7.hpp> |
---|
| 27 | #include <boost/signals/signal8.hpp> |
---|
| 28 | #include <boost/signals/signal9.hpp> |
---|
| 29 | #include <boost/signals/signal10.hpp> |
---|
| 30 | #include <boost/function.hpp> |
---|
| 31 | |
---|
| 32 | #ifdef BOOST_HAS_ABI_HEADERS |
---|
| 33 | # include BOOST_ABI_PREFIX |
---|
| 34 | #endif |
---|
| 35 | |
---|
| 36 | namespace boost { |
---|
| 37 | #ifndef BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX |
---|
| 38 | namespace BOOST_SIGNALS_NAMESPACE { |
---|
| 39 | namespace detail { |
---|
| 40 | template<int Arity, |
---|
| 41 | typename Signature, |
---|
| 42 | typename Combiner, |
---|
| 43 | typename Group, |
---|
| 44 | typename GroupCompare, |
---|
| 45 | typename SlotFunction> |
---|
| 46 | class real_get_signal_impl; |
---|
| 47 | |
---|
| 48 | template<typename Signature, |
---|
| 49 | typename Combiner, |
---|
| 50 | typename Group, |
---|
| 51 | typename GroupCompare, |
---|
| 52 | typename SlotFunction> |
---|
| 53 | class real_get_signal_impl<0, Signature, Combiner, Group, GroupCompare, |
---|
| 54 | SlotFunction> |
---|
| 55 | { |
---|
| 56 | typedef function_traits<Signature> traits; |
---|
| 57 | |
---|
| 58 | public: |
---|
| 59 | typedef signal0<typename traits::result_type, |
---|
| 60 | Combiner, |
---|
| 61 | Group, |
---|
| 62 | GroupCompare, |
---|
| 63 | SlotFunction> type; |
---|
| 64 | }; |
---|
| 65 | |
---|
| 66 | template<typename Signature, |
---|
| 67 | typename Combiner, |
---|
| 68 | typename Group, |
---|
| 69 | typename GroupCompare, |
---|
| 70 | typename SlotFunction> |
---|
| 71 | class real_get_signal_impl<1, Signature, Combiner, Group, GroupCompare, |
---|
| 72 | SlotFunction> |
---|
| 73 | { |
---|
| 74 | typedef function_traits<Signature> traits; |
---|
| 75 | |
---|
| 76 | public: |
---|
| 77 | typedef signal1<typename traits::result_type, |
---|
| 78 | typename traits::arg1_type, |
---|
| 79 | Combiner, |
---|
| 80 | Group, |
---|
| 81 | GroupCompare, |
---|
| 82 | SlotFunction> type; |
---|
| 83 | }; |
---|
| 84 | |
---|
| 85 | template<typename Signature, |
---|
| 86 | typename Combiner, |
---|
| 87 | typename Group, |
---|
| 88 | typename GroupCompare, |
---|
| 89 | typename SlotFunction> |
---|
| 90 | class real_get_signal_impl<2, Signature, Combiner, Group, GroupCompare, |
---|
| 91 | SlotFunction> |
---|
| 92 | { |
---|
| 93 | typedef function_traits<Signature> traits; |
---|
| 94 | |
---|
| 95 | public: |
---|
| 96 | typedef signal2<typename traits::result_type, |
---|
| 97 | typename traits::arg1_type, |
---|
| 98 | typename traits::arg2_type, |
---|
| 99 | Combiner, |
---|
| 100 | Group, |
---|
| 101 | GroupCompare, |
---|
| 102 | SlotFunction> type; |
---|
| 103 | }; |
---|
| 104 | |
---|
| 105 | template<typename Signature, |
---|
| 106 | typename Combiner, |
---|
| 107 | typename Group, |
---|
| 108 | typename GroupCompare, |
---|
| 109 | typename SlotFunction> |
---|
| 110 | class real_get_signal_impl<3, Signature, Combiner, Group, GroupCompare, |
---|
| 111 | SlotFunction> |
---|
| 112 | { |
---|
| 113 | typedef function_traits<Signature> traits; |
---|
| 114 | |
---|
| 115 | public: |
---|
| 116 | typedef signal3<typename traits::result_type, |
---|
| 117 | typename traits::arg1_type, |
---|
| 118 | typename traits::arg2_type, |
---|
| 119 | typename traits::arg3_type, |
---|
| 120 | Combiner, |
---|
| 121 | Group, |
---|
| 122 | GroupCompare, |
---|
| 123 | SlotFunction> type; |
---|
| 124 | }; |
---|
| 125 | |
---|
| 126 | template<typename Signature, |
---|
| 127 | typename Combiner, |
---|
| 128 | typename Group, |
---|
| 129 | typename GroupCompare, |
---|
| 130 | typename SlotFunction> |
---|
| 131 | class real_get_signal_impl<4, Signature, Combiner, Group, GroupCompare, |
---|
| 132 | SlotFunction> |
---|
| 133 | { |
---|
| 134 | typedef function_traits<Signature> traits; |
---|
| 135 | |
---|
| 136 | public: |
---|
| 137 | typedef signal4<typename traits::result_type, |
---|
| 138 | typename traits::arg1_type, |
---|
| 139 | typename traits::arg2_type, |
---|
| 140 | typename traits::arg3_type, |
---|
| 141 | typename traits::arg4_type, |
---|
| 142 | Combiner, |
---|
| 143 | Group, |
---|
| 144 | GroupCompare, |
---|
| 145 | SlotFunction> type; |
---|
| 146 | }; |
---|
| 147 | |
---|
| 148 | template<typename Signature, |
---|
| 149 | typename Combiner, |
---|
| 150 | typename Group, |
---|
| 151 | typename GroupCompare, |
---|
| 152 | typename SlotFunction> |
---|
| 153 | class real_get_signal_impl<5, Signature, Combiner, Group, GroupCompare, |
---|
| 154 | SlotFunction> |
---|
| 155 | { |
---|
| 156 | typedef function_traits<Signature> traits; |
---|
| 157 | |
---|
| 158 | public: |
---|
| 159 | typedef signal5<typename traits::result_type, |
---|
| 160 | typename traits::arg1_type, |
---|
| 161 | typename traits::arg2_type, |
---|
| 162 | typename traits::arg3_type, |
---|
| 163 | typename traits::arg4_type, |
---|
| 164 | typename traits::arg5_type, |
---|
| 165 | Combiner, |
---|
| 166 | Group, |
---|
| 167 | GroupCompare, |
---|
| 168 | SlotFunction> type; |
---|
| 169 | }; |
---|
| 170 | |
---|
| 171 | template<typename Signature, |
---|
| 172 | typename Combiner, |
---|
| 173 | typename Group, |
---|
| 174 | typename GroupCompare, |
---|
| 175 | typename SlotFunction> |
---|
| 176 | class real_get_signal_impl<6, Signature, Combiner, Group, GroupCompare, |
---|
| 177 | SlotFunction> |
---|
| 178 | { |
---|
| 179 | typedef function_traits<Signature> traits; |
---|
| 180 | |
---|
| 181 | public: |
---|
| 182 | typedef signal6<typename traits::result_type, |
---|
| 183 | typename traits::arg1_type, |
---|
| 184 | typename traits::arg2_type, |
---|
| 185 | typename traits::arg3_type, |
---|
| 186 | typename traits::arg4_type, |
---|
| 187 | typename traits::arg5_type, |
---|
| 188 | typename traits::arg6_type, |
---|
| 189 | Combiner, |
---|
| 190 | Group, |
---|
| 191 | GroupCompare, |
---|
| 192 | SlotFunction> type; |
---|
| 193 | }; |
---|
| 194 | |
---|
| 195 | template<typename Signature, |
---|
| 196 | typename Combiner, |
---|
| 197 | typename Group, |
---|
| 198 | typename GroupCompare, |
---|
| 199 | typename SlotFunction> |
---|
| 200 | class real_get_signal_impl<7, Signature, Combiner, Group, GroupCompare, |
---|
| 201 | SlotFunction> |
---|
| 202 | { |
---|
| 203 | typedef function_traits<Signature> traits; |
---|
| 204 | |
---|
| 205 | public: |
---|
| 206 | typedef signal7<typename traits::result_type, |
---|
| 207 | typename traits::arg1_type, |
---|
| 208 | typename traits::arg2_type, |
---|
| 209 | typename traits::arg3_type, |
---|
| 210 | typename traits::arg4_type, |
---|
| 211 | typename traits::arg5_type, |
---|
| 212 | typename traits::arg6_type, |
---|
| 213 | typename traits::arg7_type, |
---|
| 214 | Combiner, |
---|
| 215 | Group, |
---|
| 216 | GroupCompare, |
---|
| 217 | SlotFunction> type; |
---|
| 218 | }; |
---|
| 219 | |
---|
| 220 | template<typename Signature, |
---|
| 221 | typename Combiner, |
---|
| 222 | typename Group, |
---|
| 223 | typename GroupCompare, |
---|
| 224 | typename SlotFunction> |
---|
| 225 | class real_get_signal_impl<8, Signature, Combiner, Group, GroupCompare, |
---|
| 226 | SlotFunction> |
---|
| 227 | { |
---|
| 228 | typedef function_traits<Signature> traits; |
---|
| 229 | |
---|
| 230 | public: |
---|
| 231 | typedef signal8<typename traits::result_type, |
---|
| 232 | typename traits::arg1_type, |
---|
| 233 | typename traits::arg2_type, |
---|
| 234 | typename traits::arg3_type, |
---|
| 235 | typename traits::arg4_type, |
---|
| 236 | typename traits::arg5_type, |
---|
| 237 | typename traits::arg6_type, |
---|
| 238 | typename traits::arg7_type, |
---|
| 239 | typename traits::arg8_type, |
---|
| 240 | Combiner, |
---|
| 241 | Group, |
---|
| 242 | GroupCompare, |
---|
| 243 | SlotFunction> type; |
---|
| 244 | }; |
---|
| 245 | |
---|
| 246 | template<typename Signature, |
---|
| 247 | typename Combiner, |
---|
| 248 | typename Group, |
---|
| 249 | typename GroupCompare, |
---|
| 250 | typename SlotFunction> |
---|
| 251 | class real_get_signal_impl<9, Signature, Combiner, Group, GroupCompare, |
---|
| 252 | SlotFunction> |
---|
| 253 | { |
---|
| 254 | typedef function_traits<Signature> traits; |
---|
| 255 | |
---|
| 256 | public: |
---|
| 257 | typedef signal9<typename traits::result_type, |
---|
| 258 | typename traits::arg1_type, |
---|
| 259 | typename traits::arg2_type, |
---|
| 260 | typename traits::arg3_type, |
---|
| 261 | typename traits::arg4_type, |
---|
| 262 | typename traits::arg5_type, |
---|
| 263 | typename traits::arg6_type, |
---|
| 264 | typename traits::arg7_type, |
---|
| 265 | typename traits::arg8_type, |
---|
| 266 | typename traits::arg9_type, |
---|
| 267 | Combiner, |
---|
| 268 | Group, |
---|
| 269 | GroupCompare, |
---|
| 270 | SlotFunction> type; |
---|
| 271 | }; |
---|
| 272 | |
---|
| 273 | template<typename Signature, |
---|
| 274 | typename Combiner, |
---|
| 275 | typename Group, |
---|
| 276 | typename GroupCompare, |
---|
| 277 | typename SlotFunction> |
---|
| 278 | class real_get_signal_impl<10, Signature, Combiner, Group, GroupCompare, |
---|
| 279 | SlotFunction> |
---|
| 280 | { |
---|
| 281 | typedef function_traits<Signature> traits; |
---|
| 282 | |
---|
| 283 | public: |
---|
| 284 | typedef signal10<typename traits::result_type, |
---|
| 285 | typename traits::arg1_type, |
---|
| 286 | typename traits::arg2_type, |
---|
| 287 | typename traits::arg3_type, |
---|
| 288 | typename traits::arg4_type, |
---|
| 289 | typename traits::arg5_type, |
---|
| 290 | typename traits::arg6_type, |
---|
| 291 | typename traits::arg7_type, |
---|
| 292 | typename traits::arg8_type, |
---|
| 293 | typename traits::arg9_type, |
---|
| 294 | typename traits::arg10_type, |
---|
| 295 | Combiner, |
---|
| 296 | Group, |
---|
| 297 | GroupCompare, |
---|
| 298 | SlotFunction> type; |
---|
| 299 | }; |
---|
| 300 | |
---|
| 301 | template<typename Signature, |
---|
| 302 | typename Combiner, |
---|
| 303 | typename Group, |
---|
| 304 | typename GroupCompare, |
---|
| 305 | typename SlotFunction> |
---|
| 306 | struct get_signal_impl : |
---|
| 307 | public real_get_signal_impl<(function_traits<Signature>::arity), |
---|
| 308 | Signature, |
---|
| 309 | Combiner, |
---|
| 310 | Group, |
---|
| 311 | GroupCompare, |
---|
| 312 | SlotFunction> |
---|
| 313 | { |
---|
| 314 | }; |
---|
| 315 | |
---|
| 316 | } // end namespace detail |
---|
| 317 | } // end namespace BOOST_SIGNALS_NAMESPACE |
---|
| 318 | |
---|
| 319 | // Very lightweight wrapper around the signalN classes that allows signals to |
---|
| 320 | // be created where the number of arguments does not need to be part of the |
---|
| 321 | // class name. |
---|
| 322 | template< |
---|
| 323 | typename Signature, // function type R (T1, T2, ..., TN) |
---|
| 324 | typename Combiner = last_value<typename function_traits<Signature>::result_type>, |
---|
| 325 | typename Group = int, |
---|
| 326 | typename GroupCompare = std::less<Group>, |
---|
| 327 | typename SlotFunction = function<Signature> |
---|
| 328 | > |
---|
| 329 | class signal : |
---|
| 330 | public BOOST_SIGNALS_NAMESPACE::detail::get_signal_impl<Signature, |
---|
| 331 | Combiner, |
---|
| 332 | Group, |
---|
| 333 | GroupCompare, |
---|
| 334 | SlotFunction>::type |
---|
| 335 | { |
---|
| 336 | typedef typename BOOST_SIGNALS_NAMESPACE::detail::get_signal_impl< |
---|
| 337 | Signature, |
---|
| 338 | Combiner, |
---|
| 339 | Group, |
---|
| 340 | GroupCompare, |
---|
| 341 | SlotFunction>::type base_type; |
---|
| 342 | |
---|
| 343 | public: |
---|
| 344 | explicit signal(const Combiner& combiner = Combiner(), |
---|
| 345 | const GroupCompare& group_compare = GroupCompare()) : |
---|
| 346 | base_type(combiner, group_compare) |
---|
| 347 | { |
---|
| 348 | } |
---|
| 349 | }; |
---|
| 350 | #endif // ndef BOOST_FUNCTION_NO_FUNCTION_TYPE_SYNTAX |
---|
| 351 | |
---|
| 352 | } // end namespace boost |
---|
| 353 | |
---|
| 354 | #ifdef BOOST_HAS_ABI_HEADERS |
---|
| 355 | # include BOOST_ABI_SUFFIX |
---|
| 356 | #endif |
---|
| 357 | |
---|
| 358 | #endif // BOOST_SIGNAL_HPP |
---|