39 #ifndef CGU_CALLBACK_H
40 #define CGU_CALLBACK_H
450 #include <functional>
453 #include <type_traits>
552 template <
class... FreeArgs>
592 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
613 template <
class... T>
615 return (f1.cb_s.get() == f2.cb_s.get());
623 template <
class... T>
639 template <
class... T>
641 return std::less<
const CallbackArg<T...>*>()(f1.cb_s.get(), f2.cb_s.get());
649 template <
class... T>
651 return (f1.cb_s.get() == f2.cb_s.get());
659 template <
class... T>
670 template <
class... T>
672 return std::less<
const CallbackArg<T...>*>()(f1.cb_s.get(), f2.cb_s.get());
681 #ifndef DOXYGEN_PARSING
686 template <
class... T>
687 struct hash<Cgu::Callback::FunctorArg<T...>> {
688 typedef std::size_t result_type;
690 result_type operator()(
const argument_type& f)
const {
697 template <
class... T>
698 struct hash<Cgu::Callback::SafeFunctorArg<T...>> {
699 typedef std::size_t result_type;
701 result_type operator()(
const argument_type& f)
const {
710 #endif // DOXYGEN_PARSING
765 template <
class... FreeArgs>
767 SharedPtr<
const CallbackArg<FreeArgs...>> cb_s;
790 if (cb_s.get()) cb_s->dispatch(args...);
881 template <
class... FreeArgs>
882 class SafeFunctorArg {
897 if (cb_s.get()) cb_s->dispatch(args...);
978 template <
class T,
class... FreeArgs>
987 (obj->*func)(free_args...);
992 template <
bool unref,
class T,
class BoundArg,
class... FreeArgs>
995 typedef void (T::*
MemFunc)(BoundArg, FreeArgs...);
1002 (obj->*func)(arg, free_args...);
1004 template <
class Arg>
1006 Arg&& arg_): obj(&obj_), func(func_), arg(std::forward<Arg>(arg_)) {}
1009 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1012 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, FreeArgs...);
1020 (obj->*func)(arg1, arg2, free_args...);
1022 template <
class Arg1,
class Arg2>
1025 Arg2&& arg2_): obj(&obj_), func(func_),
1026 arg1(std::forward<Arg1>(arg1_)),
1027 arg2(std::forward<Arg2>(arg2_)) {}
1030 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1033 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...);
1042 (obj->*func)(arg1, arg2, arg3, free_args...);
1044 template <
class Arg1,
class Arg2,
class Arg3>
1049 obj(&obj_), func(func_),
1050 arg1(std::forward<Arg1>(arg1_)),
1051 arg2(std::forward<Arg2>(arg2_)),
1052 arg3(std::forward<Arg3>(arg3_)) {}
1055 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1056 class BoundArg4,
class... FreeArgs>
1059 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...);
1069 (obj->*func)(arg1, arg2, arg3, arg4, free_args...);
1071 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1077 obj(&obj_), func(func_),
1078 arg1(std::forward<Arg1>(arg1_)),
1079 arg2(std::forward<Arg2>(arg2_)),
1080 arg3(std::forward<Arg3>(arg3_)),
1081 arg4(std::forward<Arg4>(arg4_)) {}
1084 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1085 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1088 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3,
1089 BoundArg4, BoundArg5, FreeArgs...);
1100 (obj->*func)(arg1, arg2, arg3, arg4, arg5, free_args...);
1102 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1109 obj(&obj_), func(func_),
1110 arg1(std::forward<Arg1>(arg1_)),
1111 arg2(std::forward<Arg2>(arg2_)),
1112 arg3(std::forward<Arg3>(arg3_)),
1113 arg4(std::forward<Arg4>(arg4_)),
1114 arg5(std::forward<Arg5>(arg5_)) {}
1119 template <
class T,
class... FreeArgs>
1128 (obj->*func)(free_args...);
1133 template <
bool unref,
class T,
class BoundArg,
class... FreeArgs>
1136 typedef void (T::*
MemFunc)(BoundArg, FreeArgs...)
const;
1143 (obj->*func)(arg, free_args...);
1145 template <
class Arg>
1147 Arg&& arg_): obj(&obj_), func(func_), arg(std::forward<Arg>(arg_)) {}
1150 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1153 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, FreeArgs...)
const;
1161 (obj->*func)(arg1, arg2, free_args...);
1163 template <
class Arg1,
class Arg2>
1166 Arg2&& arg2_): obj(&obj_), func(func_),
1167 arg1(std::forward<Arg1>(arg1_)),
1168 arg2(std::forward<Arg2>(arg2_)) {}
1171 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1174 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const;
1183 (obj->*func)(arg1, arg2, arg3, free_args...);
1185 template <
class Arg1,
class Arg2,
class Arg3>
1190 obj(&obj_), func(func_),
1191 arg1(std::forward<Arg1>(arg1_)),
1192 arg2(std::forward<Arg2>(arg2_)),
1193 arg3(std::forward<Arg3>(arg3_)) {}
1196 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1197 class BoundArg4,
class... FreeArgs>
1200 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...)
const;
1210 (obj->*func)(arg1, arg2, arg3, arg4, free_args...);
1212 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1218 obj(&obj_), func(func_),
1219 arg1(std::forward<Arg1>(arg1_)),
1220 arg2(std::forward<Arg2>(arg2_)),
1221 arg3(std::forward<Arg3>(arg3_)),
1222 arg4(std::forward<Arg4>(arg4_)) {}
1225 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1226 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1229 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3,
1230 BoundArg4, BoundArg5, FreeArgs...)
const;
1241 (obj->*func)(arg1, arg2, arg3, arg4, arg5, free_args...);
1243 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1250 obj(&obj_), func(func_),
1251 arg1(std::forward<Arg1>(arg1_)),
1252 arg2(std::forward<Arg2>(arg2_)),
1253 arg3(std::forward<Arg3>(arg3_)),
1254 arg4(std::forward<Arg4>(arg4_)),
1255 arg5(std::forward<Arg5>(arg5_)) {}
1260 template <
class... FreeArgs>
1273 template <
bool unref,
class BoundArg,
class... FreeArgs>
1276 typedef void (*
Func)(BoundArg, FreeArgs...);
1282 func(arg, free_args...);
1284 template <
class Arg>
1288 template <
bool unref,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1291 typedef void (*
Func)(BoundArg1, BoundArg2, FreeArgs...);
1298 func(arg1, arg2, free_args...);
1300 template <
class Arg1,
class Arg2>
1302 Arg2&& arg2_): func(func_),
1303 arg1(std::forward<Arg1>(arg1_)),
1304 arg2(std::forward<Arg2>(arg2_)) {}
1307 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1310 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...);
1318 func(arg1, arg2, arg3, free_args...);
1320 template <
class Arg1,
class Arg2,
class Arg3>
1326 arg1(std::forward<Arg1>(arg1_)),
1327 arg2(std::forward<Arg2>(arg2_)),
1328 arg3(std::forward<Arg3>(arg3_)) {}
1331 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1332 class BoundArg4,
class... FreeArgs>
1335 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...);
1344 func(arg1, arg2, arg3, arg4, free_args...);
1346 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1353 arg1(std::forward<Arg1>(arg1_)),
1354 arg2(std::forward<Arg2>(arg2_)),
1355 arg3(std::forward<Arg3>(arg3_)),
1356 arg4(std::forward<Arg4>(arg4_)) {}
1359 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1360 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1363 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3,
1364 BoundArg4, BoundArg5, FreeArgs...);
1374 func(arg1, arg2, arg3, arg4, arg5, free_args...);
1376 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1384 arg1(std::forward<Arg1>(arg1_)),
1385 arg2(std::forward<Arg2>(arg2_)),
1386 arg3(std::forward<Arg3>(arg3_)),
1387 arg4(std::forward<Arg4>(arg4_)),
1388 arg5(std::forward<Arg5>(arg5_)) {}
1392 template <
class Lambda,
class... FreeArgs>
1417 template <
class T,
class... FreeArgs>
1419 void (T::*func)(FreeArgs...)) {
1420 return new Callback0<T, FreeArgs...>{t, func};
1435 template <
class T,
class... FreeArgs>
1437 void (T::*func)(FreeArgs...)) {
1438 return new Callback0<T, FreeArgs...>{t, func};
1452 template <
class T,
class BoundArg,
class... FreeArgs>
1454 void (T::*func)(BoundArg, FreeArgs...),
1456 return new Callback1<
false, T, BoundArg, FreeArgs...>{t, func, arg};
1476 template <
class T,
class BoundArg,
class Arg,
class... FreeArgs>
1478 void (T::*func)(BoundArg, FreeArgs...),
1480 return new Callback1<
true, T, BoundArg, FreeArgs...>{t, func, std::forward<Arg>(arg)};
1494 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1496 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
1499 return new Callback2<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
1519 template <
class T,
class BoundArg1,
class BoundArg2,
1520 class Arg1,
class Arg2,
class... FreeArgs>
1522 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
1525 return new Callback2<
true, T, BoundArg1, BoundArg2, FreeArgs...>{t, func,
1526 std::forward<Arg1>(arg1),
1527 std::forward<Arg2>(arg2)};
1541 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1543 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
1547 return new Callback3<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
1567 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1568 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
1570 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
1574 return new Callback3<
true, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func,
1575 std::forward<Arg1>(arg1),
1576 std::forward<Arg2>(arg2),
1577 std::forward<Arg3>(arg3)};
1591 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1592 class BoundArg4,
class... FreeArgs>
1594 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1595 BoundArg4, FreeArgs...),
1600 return new Callback4<
false, T, BoundArg1, BoundArg2, BoundArg3,
1601 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
1621 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
1622 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
1624 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1625 BoundArg4, FreeArgs...),
1630 return new Callback4<
true, T, BoundArg1, BoundArg2, BoundArg3,
1631 BoundArg4, FreeArgs...>{t, func,
1632 std::forward<Arg1>(arg1),
1633 std::forward<Arg2>(arg2),
1634 std::forward<Arg3>(arg3),
1635 std::forward<Arg4>(arg4)};
1649 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1650 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1652 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1653 BoundArg4, BoundArg5, FreeArgs...),
1659 return new Callback5<
false, T, BoundArg1, BoundArg2, BoundArg3,
1660 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
1680 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
1681 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
1683 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1684 BoundArg4, BoundArg5, FreeArgs...),
1690 return new Callback5<
true, T, BoundArg1, BoundArg2, BoundArg3,
1691 BoundArg4, BoundArg5, FreeArgs...>{t, func,
1692 std::forward<Arg1>(arg1),
1693 std::forward<Arg2>(arg2),
1694 std::forward<Arg3>(arg3),
1695 std::forward<Arg4>(arg4),
1696 std::forward<Arg5>(arg5)};
1710 template <
class T,
class... FreeArgs>
1712 void (T::*func)(FreeArgs...)
const) {
1728 template <
class T,
class... FreeArgs>
1730 void (T::*func)(FreeArgs...)
const) {
1745 template <
class T,
class BoundArg,
class... FreeArgs>
1747 void (T::*func)(BoundArg, FreeArgs...)
const,
1749 return new Callback1_const<
false, T, BoundArg, FreeArgs...>{t, func, arg};
1769 template <
class T,
class BoundArg,
class Arg,
class... FreeArgs>
1771 void (T::*func)(BoundArg, FreeArgs...)
const,
1773 return new Callback1_const<
true, T, BoundArg, FreeArgs...>{t, func, std::forward<Arg>(arg)};
1787 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1789 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
1792 return new Callback2_const<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
1812 template <
class T,
class BoundArg1,
class BoundArg2,
1813 class Arg1,
class Arg2,
class... FreeArgs>
1815 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
1818 return new Callback2_const<
true, T, BoundArg1, BoundArg2, FreeArgs...>{t, func,
1819 std::forward<Arg1>(arg1),
1820 std::forward<Arg2>(arg2)};
1834 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1836 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
1840 return new Callback3_const<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
1860 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1861 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
1863 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
1867 return new Callback3_const<
true, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func,
1868 std::forward<Arg1>(arg1),
1869 std::forward<Arg2>(arg2),
1870 std::forward<Arg3>(arg3)};
1884 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1885 class BoundArg4,
class... FreeArgs>
1887 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1888 BoundArg4, FreeArgs...)
const,
1894 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
1914 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
1915 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
1917 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1918 BoundArg4, FreeArgs...)
const,
1924 BoundArg4, FreeArgs...>{t, func,
1925 std::forward<Arg1>(arg1),
1926 std::forward<Arg2>(arg2),
1927 std::forward<Arg3>(arg3),
1928 std::forward<Arg4>(arg4)};
1942 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1943 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1945 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1946 BoundArg4, BoundArg5, FreeArgs...)
const,
1953 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
1973 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
1974 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
1976 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1977 BoundArg4, BoundArg5, FreeArgs...)
const,
1984 BoundArg4, BoundArg5, FreeArgs...>{t, func,
1985 std::forward<Arg1>(arg1),
1986 std::forward<Arg2>(arg2),
1987 std::forward<Arg3>(arg3),
1988 std::forward<Arg4>(arg4),
1989 std::forward<Arg5>(arg5)};
2003 template <
class... FreeArgs>
2020 template <
class... FreeArgs>
2036 template <
class BoundArg,
class... FreeArgs>
2059 template <
class BoundArg,
class Arg,
class... FreeArgs>
2062 return new Callback1_static<
true, BoundArg, FreeArgs...>{func, std::forward<Arg>(arg)};
2076 template <
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2080 return new Callback2_static<
false, BoundArg1, BoundArg2, FreeArgs...>{func, arg1, arg2};
2100 template <
class BoundArg1,
class BoundArg2,
class Arg1,
class Arg2,
class... FreeArgs>
2105 std::forward<Arg1>(arg1),
2106 std::forward<Arg2>(arg2)};
2120 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2121 CallbackArg<FreeArgs...>*
make(
void (*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2125 return new Callback3_static<
false, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func, arg1, arg2, arg3};
2145 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2146 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
2151 return new Callback3_static<
true, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func,
2152 std::forward<Arg1>(arg1),
2153 std::forward<Arg2>(arg2),
2154 std::forward<Arg3>(arg3)};
2168 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2169 class BoundArg4,
class... FreeArgs>
2171 BoundArg4, FreeArgs...),
2177 BoundArg4, FreeArgs...>{func, arg1, arg2, arg3, arg4};
2197 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
2198 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
2200 BoundArg4, FreeArgs...),
2206 BoundArg4, FreeArgs...>{func,
2207 std::forward<Arg1>(arg1),
2208 std::forward<Arg2>(arg2),
2209 std::forward<Arg3>(arg3),
2210 std::forward<Arg4>(arg4)};
2224 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2225 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2227 BoundArg4, BoundArg5, FreeArgs...),
2234 BoundArg4, BoundArg5, FreeArgs...>{func, arg1, arg2, arg3, arg4, arg5};
2254 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
2255 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
2257 BoundArg4, BoundArg5, FreeArgs...),
2264 BoundArg4, BoundArg5, FreeArgs...>{func,
2265 std::forward<Arg1>(arg1),
2266 std::forward<Arg2>(arg2),
2267 std::forward<Arg3>(arg3),
2268 std::forward<Arg4>(arg4),
2269 std::forward<Arg5>(arg5)};
2286 template <
class... FreeArgs>
2288 typedef std::function<void(FreeArgs...)> LType;
2306 template <
class... FreeArgs>
2308 typedef std::function<void(FreeArgs...)> LType;
2324 template <
class... FreeArgs>
2326 typedef std::function<void(FreeArgs...)> LType;
2344 template <
class... FreeArgs>
2346 typedef std::function<void(FreeArgs...)> LType;
2390 template <
class... FreeArgs,
class Lambda>
2392 typedef typename std::remove_const<typename std::remove_reference<Lambda>::type>::type LType;
2393 return new Callback_lambda<LType, FreeArgs...>{std::forward<Lambda>(l)};
2396 #ifndef DOXYGEN_PARSING
2402 template <
class T,
class... FreeArgs>
2404 void (T::*func)(FreeArgs...)) {
2405 return new Callback0<T, FreeArgs...>{t, func};
2407 template <
class T,
class BoundArg,
class... FreeArgs>
2409 void (T::*func)(BoundArg, FreeArgs...),
2410 const BoundArg& arg) {
2411 return new Callback1<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2413 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2415 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
2416 const BoundArg1& arg1,
2417 const BoundArg2& arg2) {
2418 return new Callback2<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2420 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2422 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2423 const BoundArg1& arg1,
2424 const BoundArg2& arg2,
2425 const BoundArg3& arg3) {
2426 return new Callback3<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2428 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2429 class BoundArg4,
class... FreeArgs>
2431 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2432 BoundArg4, FreeArgs...),
2433 const BoundArg1& arg1,
2434 const BoundArg2& arg2,
2435 const BoundArg3& arg3,
2436 const BoundArg4& arg4) {
2437 return new Callback4<
false, T, BoundArg1, BoundArg2, BoundArg3,
2438 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2440 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2441 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2443 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2444 BoundArg4, BoundArg5, FreeArgs...),
2445 const BoundArg1& arg1,
2446 const BoundArg2& arg2,
2447 const BoundArg3& arg3,
2448 const BoundArg4& arg4,
2449 const BoundArg5& arg5) {
2450 return new Callback5<
false, T, BoundArg1, BoundArg2, BoundArg3,
2451 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2453 template <
class T,
class... FreeArgs>
2455 void (T::*func)(FreeArgs...)
const) {
2458 template <
class T,
class BoundArg,
class... FreeArgs>
2460 void (T::*func)(BoundArg, FreeArgs...)
const,
2461 const BoundArg& arg) {
2462 return new Callback1_const<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2464 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2466 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
2467 const BoundArg1& arg1,
2468 const BoundArg2& arg2) {
2469 return new Callback2_const<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2471 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2473 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
2474 const BoundArg1& arg1,
2475 const BoundArg2& arg2,
2476 const BoundArg3& arg3) {
2477 return new Callback3_const<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2479 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2480 class BoundArg4,
class... FreeArgs>
2482 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2483 BoundArg4, FreeArgs...)
const,
2484 const BoundArg1& arg1,
2485 const BoundArg2& arg2,
2486 const BoundArg3& arg3,
2487 const BoundArg4& arg4) {
2489 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2491 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2492 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2494 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2495 BoundArg4, BoundArg5, FreeArgs...)
const,
2496 const BoundArg1& arg1,
2497 const BoundArg2& arg2,
2498 const BoundArg3& arg3,
2499 const BoundArg4& arg4,
2500 const BoundArg5& arg5) {
2502 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2504 template <
class... FreeArgs>
2505 CallbackArg<FreeArgs...>* make_val(
void (*func)(FreeArgs...)) {
2508 template <
class BoundArg,
class... FreeArgs>
2509 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg, FreeArgs...),
2510 const BoundArg& arg) {
2513 template <
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2514 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, FreeArgs...),
2515 const BoundArg1& arg1,
2516 const BoundArg2& arg2) {
2517 return new Callback2_static<
false, BoundArg1, BoundArg2, FreeArgs...>{func, arg1, arg2};
2519 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2520 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2521 const BoundArg1& arg1,
2522 const BoundArg2& arg2,
2523 const BoundArg3& arg3) {
2524 return new Callback3_static<
false, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func, arg1, arg2, arg3};
2526 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2527 class BoundArg4,
class... FreeArgs>
2528 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3,
2529 BoundArg4, FreeArgs...),
2530 const BoundArg1& arg1,
2531 const BoundArg2& arg2,
2532 const BoundArg3& arg3,
2533 const BoundArg4& arg4) {
2535 BoundArg4, FreeArgs...>{func, arg1, arg2, arg3, arg4};
2537 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2538 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2539 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3,
2540 BoundArg4, BoundArg5, FreeArgs...),
2541 const BoundArg1& arg1,
2542 const BoundArg2& arg2,
2543 const BoundArg3& arg3,
2544 const BoundArg4& arg4,
2545 const BoundArg5& arg5) {
2547 BoundArg4, BoundArg5, FreeArgs...>{func, arg1, arg2, arg3, arg4, arg5};
2549 template <
class... FreeArgs>
2550 CallbackArg<FreeArgs...>* make_val(
const std::function<
void(FreeArgs...)>& f) {
2551 typedef std::function<void(FreeArgs...)> LType;
2554 template <
class... FreeArgs>
2555 CallbackArg<FreeArgs...>* make_val(std::function<
void(FreeArgs...)>&& f) {
2556 typedef std::function<void(FreeArgs...)> LType;
2559 #endif // DOXYGEN_PARSING
2588 void post(
const Callback* cb, gint priority = G_PRIORITY_DEFAULT_IDLE,
2589 GMainContext* context = 0);
2637 gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0);
2672 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
2674 void post(F&& func, gint priority = G_PRIORITY_DEFAULT_IDLE,
2675 GMainContext* context = 0) {
2676 post(lambda<>(std::forward<F>(func)), priority, context);
2734 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
2737 gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0) {
2738 post(lambda<>(std::forward<F>(func)), r, priority, context);