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(lyx::bind(f, lyx::ref(p1)));
75 template<class F, class P1, class P2>
76 R call(F f, P1& p1, P2& p2)
78 return call(lyx::bind(f, lyx::ref(p1), lyx::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(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::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(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::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(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4),
101 lyx::ref(p5), lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
106 void synchronousFunctionCall()
108 return_value_ = func_();
117 // void specialisation
119 class InGuiThread<void> : private IntoGuiThreadMover
132 template<class F, class P1>
133 void call(F f, P1& p1)
135 call(lyx::bind(f, lyx::ref(p1)));
138 template<class F, class P1, class P2>
139 void call(F f, P1& p1, P2& p2)
141 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
144 template<class F, class P1, class P2, class P3>
145 void call(F f, P1& p1, P2& p2, P3& p3)
147 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
150 template<class F, class P1, class P2, class P3, class P4>
151 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
153 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
160 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
161 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
163 call(bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4), lyx::ref(p5),
164 lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
169 void synchronousFunctionCall()
175 function<void()> func_;
179 } // namespace frontend
182 #endif // INGUITHREAD_H