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"
26 class IntoGuiThreadMover : public QObject
34 void callInGuiThread();
37 void triggerFunctionCall();
40 void doFunctionCall();
43 virtual void synchronousFunctionCall() = 0;
45 QWaitCondition condition_;
51 class InGuiThread : private IntoGuiThreadMover
65 template<class F, class P1>
68 return call(lyx::bind(f, lyx::ref(p1)));
71 template<class F, class P1, class P2>
72 R call(F f, P1& p1, P2& p2)
74 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
77 template<class F, class P1, class P2, class P3>
78 R call(F f, P1& p1, P2& p2, P3& p3)
80 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
83 template<class F, class P1, class P2, class P3, class P4>
84 R call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
86 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
93 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
94 R call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
96 return call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4),
97 lyx::ref(p5), lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
102 void synchronousFunctionCall()
104 return_value_ = func_();
113 // void specialisation
115 class InGuiThread<void> : private IntoGuiThreadMover
128 template<class F, class P1>
129 void call(F f, P1& p1)
131 call(lyx::bind(f, lyx::ref(p1)));
134 template<class F, class P1, class P2>
135 void call(F f, P1& p1, P2& p2)
137 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2)));
140 template<class F, class P1, class P2, class P3>
141 void call(F f, P1& p1, P2& p2, P3& p3)
143 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3)));
146 template<class F, class P1, class P2, class P3, class P4>
147 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
149 call(lyx::bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4)));
156 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
157 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
159 call(bind(f, lyx::ref(p1), lyx::ref(p2), lyx::ref(p3), lyx::ref(p4), lyx::ref(p5),
160 lyx::ref(p6), lyx::ref(p7), lyx::ref(p8)));
165 void synchronousFunctionCall()
171 function<void()> func_;
175 } // namespace frontend
178 #endif // INGUITHREAD_H