4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
9 * Full author contact details are available in file CREDITS.
17 #include <QWaitCondition>
19 #include "support/bind.h"
20 #include "support/functional.h"
22 #if QT_VERSION < 0x040400
30 class IntoGuiThreadMover : public QObject
38 void callInGuiThread();
41 void triggerFunctionCall();
44 void doFunctionCall();
47 virtual void synchronousFunctionCall() = 0;
49 QWaitCondition condition_;
55 class InGuiThread : private IntoGuiThreadMover
69 template<class F, class P1>
72 return call(bind(f, ref(p1)));
75 template<class F, class P1, class P2>
76 R call(F f, P1& p1, P2& p2)
78 return call(bind(f, ref(p1), ref(p2)));
81 template<class F, class P1, class P2, class P3>
82 R call(F f, P1& p1, P2& p2, P3& p3)
84 return call(bind(f, ref(p1), ref(p2), ref(p3)));
87 template<class F, class P1, class P2, class P3, class P4>
88 R call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
90 return call(bind(f, ref(p1), ref(p2), ref(p3), ref(p4)));
97 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
98 R call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
100 return call(bind(f, ref(p1), ref(p2), ref(p3), ref(p4), ref(p5), ref(p6), ref(p7), ref(p8)));
105 void synchronousFunctionCall()
107 return_value_ = func_();
116 // void specialisation
118 class InGuiThread<void> : private IntoGuiThreadMover
131 template<class F, class P1>
132 void call(F f, P1& p1)
134 call(bind(f, ref(p1)));
137 template<class F, class P1, class P2>
138 void call(F f, P1& p1, P2& p2)
140 call(bind(f, ref(p1), ref(p2)));
143 template<class F, class P1, class P2, class P3>
144 void call(F f, P1& p1, P2& p2, P3& p3)
146 call(bind(f, ref(p1), ref(p2), ref(p3)));
149 template<class F, class P1, class P2, class P3, class P4>
150 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
152 call(bind(f, ref(p1), ref(p2), ref(p3), ref(p4)));
159 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
160 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
162 call(bind(f, ref(p1), ref(p2), ref(p3), ref(p4), ref(p5), ref(p6), ref(p7), ref(p8)));
167 void synchronousFunctionCall()
173 function<void()> func_;
177 } // namespace frontend
180 #endif // INGUITHREAD_H