39 #ifndef CGU_CALLBACK_H
40 #define CGU_CALLBACK_H
454 #include <functional>
457 #include <type_traits>
556 template <
class... FreeArgs>
596 #ifdef CGU_USE_GLIB_MEMORY_SLICES_NO_COMPAT
617 template <
class... T>
619 return (f1.cb_s.get() == f2.cb_s.get());
627 template <
class... T>
645 template <
class... T>
647 return std::less<
const CallbackArg<T...>*>()(f1.cb_s.get(), f2.cb_s.get());
655 template <
class... T>
657 return (f1.cb_s.get() == f2.cb_s.get());
665 template <
class... T>
678 template <
class... T>
680 return std::less<
const CallbackArg<T...>*>()(f1.cb_s.get(), f2.cb_s.get());
689 #ifndef DOXYGEN_PARSING
694 template <
class... T>
695 struct hash<Cgu::Callback::FunctorArg<T...>> {
696 typedef std::size_t result_type;
698 result_type operator()(
const argument_type& f)
const {
705 template <
class... T>
706 struct hash<Cgu::Callback::SafeFunctorArg<T...>> {
707 typedef std::size_t result_type;
709 result_type operator()(
const argument_type& f)
const {
718 #endif // DOXYGEN_PARSING
773 template <
class... FreeArgs>
775 SharedPtr<
const CallbackArg<FreeArgs...>> cb_s;
798 if (cb_s.get()) cb_s->dispatch(args...);
830 friend
bool operator< <>(const
FunctorArg&, const FunctorArg&);
832 friend struct std::hash<FunctorArg>;
891 template <
class... FreeArgs>
892 class SafeFunctorArg {
907 if (cb_s.get()) cb_s->dispatch(args...);
939 friend
bool operator< <>(const
SafeFunctorArg&, const SafeFunctorArg&);
941 friend struct std::hash<SafeFunctorArg>;
990 template <
class T,
class... FreeArgs>
999 (obj->*func)(free_args...);
1004 template <
bool unref,
class T,
class BoundArg,
class... FreeArgs>
1007 typedef void (T::*
MemFunc)(BoundArg, FreeArgs...);
1014 (obj->*func)(arg, free_args...);
1016 template <
class Arg>
1018 Arg&& arg_): obj(&obj_), func(func_), arg(std::forward<Arg>(arg_)) {}
1021 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1024 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, FreeArgs...);
1032 (obj->*func)(arg1, arg2, free_args...);
1034 template <
class Arg1,
class Arg2>
1037 Arg2&& arg2_): obj(&obj_), func(func_),
1038 arg1(std::forward<Arg1>(arg1_)),
1039 arg2(std::forward<Arg2>(arg2_)) {}
1042 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1045 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...);
1054 (obj->*func)(arg1, arg2, arg3, free_args...);
1056 template <
class Arg1,
class Arg2,
class Arg3>
1061 obj(&obj_), func(func_),
1062 arg1(std::forward<Arg1>(arg1_)),
1063 arg2(std::forward<Arg2>(arg2_)),
1064 arg3(std::forward<Arg3>(arg3_)) {}
1067 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1068 class BoundArg4,
class... FreeArgs>
1071 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...);
1081 (obj->*func)(arg1, arg2, arg3, arg4, free_args...);
1083 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1089 obj(&obj_), func(func_),
1090 arg1(std::forward<Arg1>(arg1_)),
1091 arg2(std::forward<Arg2>(arg2_)),
1092 arg3(std::forward<Arg3>(arg3_)),
1093 arg4(std::forward<Arg4>(arg4_)) {}
1096 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1097 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1100 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3,
1101 BoundArg4, BoundArg5, FreeArgs...);
1112 (obj->*func)(arg1, arg2, arg3, arg4, arg5, free_args...);
1114 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1121 obj(&obj_), func(func_),
1122 arg1(std::forward<Arg1>(arg1_)),
1123 arg2(std::forward<Arg2>(arg2_)),
1124 arg3(std::forward<Arg3>(arg3_)),
1125 arg4(std::forward<Arg4>(arg4_)),
1126 arg5(std::forward<Arg5>(arg5_)) {}
1131 template <
class T,
class... FreeArgs>
1140 (obj->*func)(free_args...);
1145 template <
bool unref,
class T,
class BoundArg,
class... FreeArgs>
1148 typedef void (T::*
MemFunc)(BoundArg, FreeArgs...)
const;
1155 (obj->*func)(arg, free_args...);
1157 template <
class Arg>
1159 Arg&& arg_): obj(&obj_), func(func_), arg(std::forward<Arg>(arg_)) {}
1162 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1165 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, FreeArgs...)
const;
1173 (obj->*func)(arg1, arg2, free_args...);
1175 template <
class Arg1,
class Arg2>
1178 Arg2&& arg2_): obj(&obj_), func(func_),
1179 arg1(std::forward<Arg1>(arg1_)),
1180 arg2(std::forward<Arg2>(arg2_)) {}
1183 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1186 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const;
1195 (obj->*func)(arg1, arg2, arg3, free_args...);
1197 template <
class Arg1,
class Arg2,
class Arg3>
1202 obj(&obj_), func(func_),
1203 arg1(std::forward<Arg1>(arg1_)),
1204 arg2(std::forward<Arg2>(arg2_)),
1205 arg3(std::forward<Arg3>(arg3_)) {}
1208 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1209 class BoundArg4,
class... FreeArgs>
1212 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...)
const;
1222 (obj->*func)(arg1, arg2, arg3, arg4, free_args...);
1224 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1230 obj(&obj_), func(func_),
1231 arg1(std::forward<Arg1>(arg1_)),
1232 arg2(std::forward<Arg2>(arg2_)),
1233 arg3(std::forward<Arg3>(arg3_)),
1234 arg4(std::forward<Arg4>(arg4_)) {}
1237 template <
bool unref,
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1238 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1241 typedef void (T::*
MemFunc)(BoundArg1, BoundArg2, BoundArg3,
1242 BoundArg4, BoundArg5, FreeArgs...)
const;
1253 (obj->*func)(arg1, arg2, arg3, arg4, arg5, free_args...);
1255 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1262 obj(&obj_), func(func_),
1263 arg1(std::forward<Arg1>(arg1_)),
1264 arg2(std::forward<Arg2>(arg2_)),
1265 arg3(std::forward<Arg3>(arg3_)),
1266 arg4(std::forward<Arg4>(arg4_)),
1267 arg5(std::forward<Arg5>(arg5_)) {}
1272 template <
class... FreeArgs>
1285 template <
bool unref,
class BoundArg,
class... FreeArgs>
1288 typedef void (*
Func)(BoundArg, FreeArgs...);
1294 func(arg, free_args...);
1296 template <
class Arg>
1300 template <
bool unref,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1303 typedef void (*
Func)(BoundArg1, BoundArg2, FreeArgs...);
1310 func(arg1, arg2, free_args...);
1312 template <
class Arg1,
class Arg2>
1314 Arg2&& arg2_): func(func_),
1315 arg1(std::forward<Arg1>(arg1_)),
1316 arg2(std::forward<Arg2>(arg2_)) {}
1319 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1322 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...);
1330 func(arg1, arg2, arg3, free_args...);
1332 template <
class Arg1,
class Arg2,
class Arg3>
1338 arg1(std::forward<Arg1>(arg1_)),
1339 arg2(std::forward<Arg2>(arg2_)),
1340 arg3(std::forward<Arg3>(arg3_)) {}
1343 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1344 class BoundArg4,
class... FreeArgs>
1347 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3, BoundArg4, FreeArgs...);
1356 func(arg1, arg2, arg3, arg4, free_args...);
1358 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4>
1365 arg1(std::forward<Arg1>(arg1_)),
1366 arg2(std::forward<Arg2>(arg2_)),
1367 arg3(std::forward<Arg3>(arg3_)),
1368 arg4(std::forward<Arg4>(arg4_)) {}
1371 template <
bool unref,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1372 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1375 typedef void (*
Func)(BoundArg1, BoundArg2, BoundArg3,
1376 BoundArg4, BoundArg5, FreeArgs...);
1386 func(arg1, arg2, arg3, arg4, arg5, free_args...);
1388 template <
class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5>
1396 arg1(std::forward<Arg1>(arg1_)),
1397 arg2(std::forward<Arg2>(arg2_)),
1398 arg3(std::forward<Arg3>(arg3_)),
1399 arg4(std::forward<Arg4>(arg4_)),
1400 arg5(std::forward<Arg5>(arg5_)) {}
1404 template <
class Lambda,
class... FreeArgs>
1429 template <
class T,
class... FreeArgs>
1431 void (T::*func)(FreeArgs...)) {
1432 return new Callback0<T, FreeArgs...>{t, func};
1447 template <
class T,
class... FreeArgs>
1449 void (T::*func)(FreeArgs...)) {
1450 return new Callback0<T, FreeArgs...>{t, func};
1464 template <
class T,
class BoundArg,
class... FreeArgs>
1466 void (T::*func)(BoundArg, FreeArgs...),
1468 return new Callback1<
false, T, BoundArg, FreeArgs...>{t, func, arg};
1488 template <
class T,
class BoundArg,
class Arg,
class... FreeArgs>
1490 void (T::*func)(BoundArg, FreeArgs...),
1492 return new Callback1<
true, T, BoundArg, FreeArgs...>{t, func, std::forward<Arg>(arg)};
1506 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1508 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
1511 return new Callback2<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
1531 template <
class T,
class BoundArg1,
class BoundArg2,
1532 class Arg1,
class Arg2,
class... FreeArgs>
1534 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
1537 return new Callback2<
true, T, BoundArg1, BoundArg2, FreeArgs...>{t, func,
1538 std::forward<Arg1>(arg1),
1539 std::forward<Arg2>(arg2)};
1553 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1555 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
1559 return new Callback3<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
1579 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1580 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
1582 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
1586 return new Callback3<
true, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func,
1587 std::forward<Arg1>(arg1),
1588 std::forward<Arg2>(arg2),
1589 std::forward<Arg3>(arg3)};
1603 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1604 class BoundArg4,
class... FreeArgs>
1606 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1607 BoundArg4, FreeArgs...),
1612 return new Callback4<
false, T, BoundArg1, BoundArg2, BoundArg3,
1613 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
1633 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
1634 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
1636 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1637 BoundArg4, FreeArgs...),
1642 return new Callback4<
true, T, BoundArg1, BoundArg2, BoundArg3,
1643 BoundArg4, FreeArgs...>{t, func,
1644 std::forward<Arg1>(arg1),
1645 std::forward<Arg2>(arg2),
1646 std::forward<Arg3>(arg3),
1647 std::forward<Arg4>(arg4)};
1661 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1662 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1664 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1665 BoundArg4, BoundArg5, FreeArgs...),
1671 return new Callback5<
false, T, BoundArg1, BoundArg2, BoundArg3,
1672 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
1692 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
1693 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
1695 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1696 BoundArg4, BoundArg5, FreeArgs...),
1702 return new Callback5<
true, T, BoundArg1, BoundArg2, BoundArg3,
1703 BoundArg4, BoundArg5, FreeArgs...>{t, func,
1704 std::forward<Arg1>(arg1),
1705 std::forward<Arg2>(arg2),
1706 std::forward<Arg3>(arg3),
1707 std::forward<Arg4>(arg4),
1708 std::forward<Arg5>(arg5)};
1722 template <
class T,
class... FreeArgs>
1724 void (T::*func)(FreeArgs...)
const) {
1740 template <
class T,
class... FreeArgs>
1742 void (T::*func)(FreeArgs...)
const) {
1757 template <
class T,
class BoundArg,
class... FreeArgs>
1759 void (T::*func)(BoundArg, FreeArgs...)
const,
1761 return new Callback1_const<
false, T, BoundArg, FreeArgs...>{t, func, arg};
1781 template <
class T,
class BoundArg,
class Arg,
class... FreeArgs>
1783 void (T::*func)(BoundArg, FreeArgs...)
const,
1785 return new Callback1_const<
true, T, BoundArg, FreeArgs...>{t, func, std::forward<Arg>(arg)};
1799 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
1801 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
1804 return new Callback2_const<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
1824 template <
class T,
class BoundArg1,
class BoundArg2,
1825 class Arg1,
class Arg2,
class... FreeArgs>
1827 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
1830 return new Callback2_const<
true, T, BoundArg1, BoundArg2, FreeArgs...>{t, func,
1831 std::forward<Arg1>(arg1),
1832 std::forward<Arg2>(arg2)};
1846 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
1848 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
1852 return new Callback3_const<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
1872 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1873 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
1875 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
1879 return new Callback3_const<
true, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func,
1880 std::forward<Arg1>(arg1),
1881 std::forward<Arg2>(arg2),
1882 std::forward<Arg3>(arg3)};
1896 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1897 class BoundArg4,
class... FreeArgs>
1899 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1900 BoundArg4, FreeArgs...)
const,
1906 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
1926 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
1927 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
1929 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1930 BoundArg4, FreeArgs...)
const,
1936 BoundArg4, FreeArgs...>{t, func,
1937 std::forward<Arg1>(arg1),
1938 std::forward<Arg2>(arg2),
1939 std::forward<Arg3>(arg3),
1940 std::forward<Arg4>(arg4)};
1954 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
1955 class BoundArg4,
class BoundArg5,
class... FreeArgs>
1957 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1958 BoundArg4, BoundArg5, FreeArgs...)
const,
1965 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
1985 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
1986 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
1988 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
1989 BoundArg4, BoundArg5, FreeArgs...)
const,
1996 BoundArg4, BoundArg5, FreeArgs...>{t, func,
1997 std::forward<Arg1>(arg1),
1998 std::forward<Arg2>(arg2),
1999 std::forward<Arg3>(arg3),
2000 std::forward<Arg4>(arg4),
2001 std::forward<Arg5>(arg5)};
2015 template <
class... FreeArgs>
2032 template <
class... FreeArgs>
2048 template <
class BoundArg,
class... FreeArgs>
2071 template <
class BoundArg,
class Arg,
class... FreeArgs>
2074 return new Callback1_static<
true, BoundArg, FreeArgs...>{func, std::forward<Arg>(arg)};
2088 template <
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2092 return new Callback2_static<
false, BoundArg1, BoundArg2, FreeArgs...>{func, arg1, arg2};
2112 template <
class BoundArg1,
class BoundArg2,
class Arg1,
class Arg2,
class... FreeArgs>
2117 std::forward<Arg1>(arg1),
2118 std::forward<Arg2>(arg2)};
2132 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2133 CallbackArg<FreeArgs...>*
make(
void (*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2137 return new Callback3_static<
false, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func, arg1, arg2, arg3};
2157 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2158 class Arg1,
class Arg2,
class Arg3,
class... FreeArgs>
2163 return new Callback3_static<
true, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func,
2164 std::forward<Arg1>(arg1),
2165 std::forward<Arg2>(arg2),
2166 std::forward<Arg3>(arg3)};
2180 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2181 class BoundArg4,
class... FreeArgs>
2183 BoundArg4, FreeArgs...),
2189 BoundArg4, FreeArgs...>{func, arg1, arg2, arg3, arg4};
2209 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
2210 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class... FreeArgs>
2212 BoundArg4, FreeArgs...),
2218 BoundArg4, FreeArgs...>{func,
2219 std::forward<Arg1>(arg1),
2220 std::forward<Arg2>(arg2),
2221 std::forward<Arg3>(arg3),
2222 std::forward<Arg4>(arg4)};
2236 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2237 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2239 BoundArg4, BoundArg5, FreeArgs...),
2246 BoundArg4, BoundArg5, FreeArgs...>{func, arg1, arg2, arg3, arg4, arg5};
2266 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class BoundArg4,
class BoundArg5,
2267 class Arg1,
class Arg2,
class Arg3,
class Arg4,
class Arg5,
class... FreeArgs>
2269 BoundArg4, BoundArg5, FreeArgs...),
2276 BoundArg4, BoundArg5, FreeArgs...>{func,
2277 std::forward<Arg1>(arg1),
2278 std::forward<Arg2>(arg2),
2279 std::forward<Arg3>(arg3),
2280 std::forward<Arg4>(arg4),
2281 std::forward<Arg5>(arg5)};
2298 template <
class... FreeArgs>
2300 typedef std::function<void(FreeArgs...)> LType;
2318 template <
class... FreeArgs>
2320 typedef std::function<void(FreeArgs...)> LType;
2336 template <
class... FreeArgs>
2338 typedef std::function<void(FreeArgs...)> LType;
2356 template <
class... FreeArgs>
2358 typedef std::function<void(FreeArgs...)> LType;
2402 template <
class... FreeArgs,
class Lambda>
2404 typedef typename std::remove_const<typename std::remove_reference<Lambda>::type>::type LType;
2405 return new Callback_lambda<LType, FreeArgs...>{std::forward<Lambda>(l)};
2408 #ifndef DOXYGEN_PARSING
2414 template <
class T,
class... FreeArgs>
2416 void (T::*func)(FreeArgs...)) {
2417 return new Callback0<T, FreeArgs...>{t, func};
2419 template <
class T,
class BoundArg,
class... FreeArgs>
2421 void (T::*func)(BoundArg, FreeArgs...),
2422 const BoundArg& arg) {
2423 return new Callback1<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2425 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2427 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...),
2428 const BoundArg1& arg1,
2429 const BoundArg2& arg2) {
2430 return new Callback2<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2432 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2434 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2435 const BoundArg1& arg1,
2436 const BoundArg2& arg2,
2437 const BoundArg3& arg3) {
2438 return new Callback3<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2440 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2441 class BoundArg4,
class... FreeArgs>
2443 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2444 BoundArg4, FreeArgs...),
2445 const BoundArg1& arg1,
2446 const BoundArg2& arg2,
2447 const BoundArg3& arg3,
2448 const BoundArg4& arg4) {
2449 return new Callback4<
false, T, BoundArg1, BoundArg2, BoundArg3,
2450 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2452 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2453 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2455 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2456 BoundArg4, BoundArg5, FreeArgs...),
2457 const BoundArg1& arg1,
2458 const BoundArg2& arg2,
2459 const BoundArg3& arg3,
2460 const BoundArg4& arg4,
2461 const BoundArg5& arg5) {
2462 return new Callback5<
false, T, BoundArg1, BoundArg2, BoundArg3,
2463 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2465 template <
class T,
class... FreeArgs>
2467 void (T::*func)(FreeArgs...)
const) {
2470 template <
class T,
class BoundArg,
class... FreeArgs>
2472 void (T::*func)(BoundArg, FreeArgs...)
const,
2473 const BoundArg& arg) {
2474 return new Callback1_const<
false, T, BoundArg, FreeArgs...>{t, func, arg};
2476 template <
class T,
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2478 void (T::*func)(BoundArg1, BoundArg2, FreeArgs...)
const,
2479 const BoundArg1& arg1,
2480 const BoundArg2& arg2) {
2481 return new Callback2_const<
false, T, BoundArg1, BoundArg2, FreeArgs...>{t, func, arg1, arg2};
2483 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2485 void (T::*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...)
const,
2486 const BoundArg1& arg1,
2487 const BoundArg2& arg2,
2488 const BoundArg3& arg3) {
2489 return new Callback3_const<
false, T, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{t, func, arg1, arg2, arg3};
2491 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2492 class BoundArg4,
class... FreeArgs>
2494 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2495 BoundArg4, FreeArgs...)
const,
2496 const BoundArg1& arg1,
2497 const BoundArg2& arg2,
2498 const BoundArg3& arg3,
2499 const BoundArg4& arg4) {
2501 BoundArg4, FreeArgs...>{t, func, arg1, arg2, arg3, arg4};
2503 template <
class T,
class BoundArg1,
class BoundArg2,
class BoundArg3,
2504 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2506 void (T::*func)(BoundArg1, BoundArg2, BoundArg3,
2507 BoundArg4, BoundArg5, FreeArgs...)
const,
2508 const BoundArg1& arg1,
2509 const BoundArg2& arg2,
2510 const BoundArg3& arg3,
2511 const BoundArg4& arg4,
2512 const BoundArg5& arg5) {
2514 BoundArg4, BoundArg5, FreeArgs...>{t, func, arg1, arg2, arg3, arg4, arg5};
2516 template <
class... FreeArgs>
2517 CallbackArg<FreeArgs...>* make_val(
void (*func)(FreeArgs...)) {
2520 template <
class BoundArg,
class... FreeArgs>
2521 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg, FreeArgs...),
2522 const BoundArg& arg) {
2525 template <
class BoundArg1,
class BoundArg2,
class... FreeArgs>
2526 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, FreeArgs...),
2527 const BoundArg1& arg1,
2528 const BoundArg2& arg2) {
2529 return new Callback2_static<
false, BoundArg1, BoundArg2, FreeArgs...>{func, arg1, arg2};
2531 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
class... FreeArgs>
2532 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3, FreeArgs...),
2533 const BoundArg1& arg1,
2534 const BoundArg2& arg2,
2535 const BoundArg3& arg3) {
2536 return new Callback3_static<
false, BoundArg1, BoundArg2, BoundArg3, FreeArgs...>{func, arg1, arg2, arg3};
2538 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2539 class BoundArg4,
class... FreeArgs>
2540 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3,
2541 BoundArg4, FreeArgs...),
2542 const BoundArg1& arg1,
2543 const BoundArg2& arg2,
2544 const BoundArg3& arg3,
2545 const BoundArg4& arg4) {
2547 BoundArg4, FreeArgs...>{func, arg1, arg2, arg3, arg4};
2549 template <
class BoundArg1,
class BoundArg2,
class BoundArg3,
2550 class BoundArg4,
class BoundArg5,
class... FreeArgs>
2551 CallbackArg<FreeArgs...>* make_val(
void (*func)(BoundArg1, BoundArg2, BoundArg3,
2552 BoundArg4, BoundArg5, FreeArgs...),
2553 const BoundArg1& arg1,
2554 const BoundArg2& arg2,
2555 const BoundArg3& arg3,
2556 const BoundArg4& arg4,
2557 const BoundArg5& arg5) {
2559 BoundArg4, BoundArg5, FreeArgs...>{func, arg1, arg2, arg3, arg4, arg5};
2561 template <
class... FreeArgs>
2562 CallbackArg<FreeArgs...>* make_val(
const std::function<
void(FreeArgs...)>& f) {
2563 typedef std::function<void(FreeArgs...)> LType;
2566 template <
class... FreeArgs>
2567 CallbackArg<FreeArgs...>* make_val(std::function<
void(FreeArgs...)>&& f) {
2568 typedef std::function<void(FreeArgs...)> LType;
2571 #endif // DOXYGEN_PARSING
2600 void post(
const Callback* cb, gint priority = G_PRIORITY_DEFAULT_IDLE,
2601 GMainContext* context = 0);
2649 gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0);
2684 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
2686 void post(F&& func, gint priority = G_PRIORITY_DEFAULT_IDLE,
2687 GMainContext* context = 0) {
2688 post(lambda<>(std::forward<F>(func)), priority, context);
2746 class =
typename std::enable_if<!std::is_convertible<typename std::remove_reference<F>::type,
2749 gint priority = G_PRIORITY_DEFAULT_IDLE, GMainContext* context = 0) {
2750 post(lambda<>(std::forward<F>(func)), r, priority, context);