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 "frontends/Application.h"
20 #include "support/bind.h"
21 #include "support/functional.h"
27 class IntoGuiThreadMover : public QObject
35 void callInGuiThread();
38 void triggerFunctionCall();
41 void doFunctionCall();
44 virtual void synchronousFunctionCall() = 0;
46 QWaitCondition condition_;
52 class InGuiThread : private IntoGuiThreadMover
63 synchronousFunctionCall();
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
129 synchronousFunctionCall();
134 template<class F, class P1>
135 void call(F f, P1& p1)
137 call(bind(f, ref(p1)));
140 template<class F, class P1, class P2>
141 void call(F f, P1& p1, P2& p2)
143 call(bind(f, ref(p1), ref(p2)));
146 template<class F, class P1, class P2, class P3>
147 void call(F f, P1& p1, P2& p2, P3& p3)
149 call(bind(f, ref(p1), ref(p2), ref(p3)));
152 template<class F, class P1, class P2, class P3, class P4>
153 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4)
155 call(bind(f, ref(p1), ref(p2), ref(p3), ref(p4)));
162 template<class F, class P1, class P2, class P3, class P4, class P5, class P6, class P7, class P8>
163 void call(F f, P1& p1, P2& p2, P3& p3, P4& p4, P5& p5, P6& p6, P7& p7, P8& p8)
165 call(bind(f, ref(p1), ref(p2), ref(p3), ref(p4), ref(p5), ref(p6), ref(p7), ref(p8)));
170 void synchronousFunctionCall()
176 function<void()> func_;
180 } // namespace frontend
183 #endif // INGUITHREAD_H