Mercurial > projects > qtd
annotate generator/typesystem_core-java.java @ 248:7664de4a55e5
Fixed #23.
QtD_QObjectEntity is not created dynamically for shell classes any more.
Class initialization is now performed by static constructors.
When wrapping QObjects returned from functions, their run-time types are now taken into account.
QObjects are allocated on GC heap, a doubly-linked list is used to prevent them from been collected (arguably a better solution than allocating on C heap and adding GC ranges)
Minor changes (including unnecessary).
author | maxter |
---|---|
date | Thu, 20 Aug 2009 14:47:17 +0000 |
parents | 7dd099050621 |
children | 37eed70de029 |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
3 ** Copyright (C) 1992-2008 Nokia. All rights reserved. | |
4 ** | |
5 ** This file is part of Qt Jambi. | |
6 ** | |
7 ** * Commercial Usage | |
8 * Licensees holding valid Qt Commercial licenses may use this file in | |
9 * accordance with the Qt Commercial License Agreement provided with the | |
10 * Software or, alternatively, in accordance with the terms contained in | |
11 * a written agreement between you and Nokia. | |
12 * | |
13 * | |
14 * GNU General Public License Usage | |
15 * Alternatively, this file may be used under the terms of the GNU | |
16 * General Public License versions 2.0 or 3.0 as published by the Free | |
17 * Software Foundation and appearing in the file LICENSE.GPL included in | |
18 * the packaging of this file. Please review the following information | |
19 * to ensure GNU General Public Licensing requirements will be met: | |
20 * http://www.fsf.org/licensing/licenses/info/GPLv2.html and | |
21 * http://www.gnu.org/copyleft/gpl.html. In addition, as a special | |
22 * exception, Nokia gives you certain additional rights. These rights | |
23 * are described in the Nokia Qt GPL Exception version 1.2, included in | |
24 * the file GPL_EXCEPTION.txt in this package. | |
248 | 25 * |
1 | 26 * Qt for Windows(R) Licensees |
27 * As a special exception, Nokia, as the sole copyright holder for Qt | |
28 * Designer, grants users of the Qt/Eclipse Integration plug-in the | |
29 * right for the Qt/Eclipse Integration to link to functionality | |
30 * provided by Qt Designer and its related libraries. | |
31 * | |
32 * | |
33 * If you are unsure which license is appropriate for your use, please | |
34 * contact the sales department at qt-sales@nokia.com. | |
35 | |
36 ** | |
37 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
38 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
39 ** | |
40 ****************************************************************************/ | |
41 | |
42 package generator; | |
43 | |
44 import qt.*; | |
45 import qt.core.*; | |
46 | |
47 class QObject___ extends QObject { | |
183 | 48 |
248 | 49 /* TODO: test whether the linked list is really a better solution |
183 | 50 public bool __stackAllocated = false; |
51 | |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
52 new(size_t size, void* p = null) |
183 | 53 { |
54 if (!p) | |
55 { | |
56 p = malloc(size); | |
57 if (!p) | |
58 assert(false, "Out of memory"); | |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
59 GC.addRange(p, size); |
183 | 60 } |
61 return p; | |
62 } | |
63 | |
64 delete(void* p) | |
65 { | |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
66 if(p) |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
67 { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
68 if (!(cast(typeof(this))p).__stackAllocated) { |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
69 free(p); |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
70 GC.removeRange(p); |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
71 } |
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
72 } |
183 | 73 } |
248 | 74 */ |
184
7d9db724ee1d
QObject is now non GC'ed, to better integrate to Qt memory management
eldar
parents:
183
diff
changeset
|
75 |
248 | 76 private |
77 { | |
78 static QObject __root; | |
79 QObject __next; | |
80 QObject __prev; | |
81 } | |
82 | |
83 ~this() | |
84 { | |
85 if (__prev) | |
86 __prev.__next = __next; | |
87 else | |
88 __root = __next; | |
89 | |
90 if (__next) | |
91 __next.__prev = __prev; | |
92 } | |
1 | 93 |
248 | 94 /** |
95 */ | |
96 T findChild(T : QObject = QObject)(string name = null) | |
97 { | |
98 foreach (obj; children) | |
99 { | |
100 auto tmp = cast(T)obj; | |
101 if (tmp && (!name.length || tmp.objectName == name)) | |
102 return tmp; | |
103 | |
104 tmp = obj.findChild!(T)(name); | |
105 if (tmp) | |
106 return tmp; | |
107 } | |
108 | |
109 return null; | |
110 } | |
111 | |
112 /** | |
113 */ | |
114 T[] findChildren(T : QObject = QObject)(string name = null) | |
115 { | |
116 T[] result; | |
117 | |
118 void find(QObject[] objects) | |
119 { | |
120 foreach (obj; objects) | |
121 { | |
122 auto tmp = cast(T)obj; | |
123 if (tmp && (!name.length || tmp.objectName == name)) | |
124 result ~= tmp; | |
125 find(obj.children); | |
126 } | |
127 } | |
128 | |
129 find(children); | |
130 return result; | |
131 } | |
1 | 132 }// class |
133 | |
134 abstract class QAbstractItemModel___ extends QAbstractItemModel { | |
135 /* private native boolean setData_native(long id, int row, int col, Object value, int role); | |
136 | |
137 public final boolean setData(int row, int col, Object value) { | |
138 return setData_native(nativeId(), row, col, value, qt.core.Qt.ItemDataRole.DisplayRole); | |
139 } | |
140 | |
141 public final boolean setData(int row, int col, Object value, int role) { | |
142 return setData_native(nativeId(), row, col, value, role); | |
143 } | |
144 | |
145 private native Object data_native(long id, int row, int col, int role); | |
146 | |
147 public final Object data(int row, int col, int role) { | |
148 return data_native(nativeId(), row, col, role); | |
149 } | |
150 | |
151 public final Object data(int row, int col) { | |
152 return data_native(nativeId(), row, col, Qt.ItemDataRole.DisplayRole); | |
153 }*/ | |
154 }// class | |
155 | |
156 class QTimer___ extends QTimer { | |
157 static private class QSingleShotTimer extends QObject { | |
158 private int timerId = -1; | |
159 public Signal0 timeout = new Signal0(); | |
160 | |
161 public QSingleShotTimer(int msec, QObject obj, String method) { | |
162 super(obj); | |
163 timeout.connect(obj, method); | |
164 timerId = startTimer(msec); | |
165 } | |
166 | |
167 protected void disposed() { | |
168 if (timerId > 0) | |
169 killTimer(timerId); | |
170 super.disposed(); | |
171 } | |
172 | |
173 protected void timerEvent(QTimerEvent e) { | |
174 if (timerId > 0) | |
175 killTimer(timerId); | |
176 timerId = -1; | |
177 timeout.emit(); | |
178 disposeLater(); | |
179 } | |
180 } | |
181 | |
182 public static void singleShot(int msec, QObject obj, String method) { | |
183 new QSingleShotTimer(msec, obj, method); | |
184 } | |
185 }// class | |
186 | |
187 class QCoreApplication___ extends QCoreApplication { | |
188 | |
189 protected static QCoreApplication m_instance = null; | |
190 | |
188 | 191 this(string[] args) |
1 | 192 { |
193 // if (m_instance != null) | |
194 // throw new RuntimeException("QCoreApplication can only be initialized once"); | |
248 | 195 |
1 | 196 argc = args.length; |
197 argv = toStringzArray(args); | |
198 this(&argc, argv); | |
199 | |
200 // m_instance.aboutToQuit.connect(m_instance, "disposeOfMyself()"); | |
201 } | |
248 | 202 |
1 | 203 private int argc; |
204 private char **argv; | |
56
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
205 /* |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
206 public static string translate(string context, string key, string disambiguation, QCoreApplication_Encoding encoding) { |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
207 string res; |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
208 qtd_QCoreApplication_translate_nativepointerchar_nativepointerchar_nativepointerchar_Encoding(&res, toStringz(context), toStringz(key), toStringz(disambiguation), encoding); |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
209 return res; |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
210 } |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
211 |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
212 public static string translate(string context, string key, string disambiguation, QCoreApplication_Encoding encoding, int n) { |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
213 string res; |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
214 qtd_QCoreApplication_translate_nativepointerchar_nativepointerchar_nativepointerchar_Encoding_int(&res, toStringz(context), toStringz(key), toStringz(disambiguation), encoding, n); |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
215 return res; |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
216 } |
d5a6b6269f44
duic is working now on the first testcase, if there are any issues with it please report
eldar
parents:
1
diff
changeset
|
217 */ |
1 | 218 }// class |
219 | |
220 class QTranslator___ extends QTranslator { | |
221 public final bool load(ubyte[] data) { | |
222 return load(data.ptr, data.length); | |
223 } | |
224 }// class | |
225 | |
226 class QProcess___ extends QProcess { | |
227 | |
228 public static class DetachedProcessInfo { | |
229 public DetachedProcessInfo(boolean success, long pid) { | |
230 this.success = success; | |
231 this.pid = pid; | |
232 } | |
233 | |
234 public boolean success; | |
235 public long pid; | |
236 } | |
237 | |
238 public static DetachedProcessInfo startDetached(String program, java.util.List<String> arguments, String workingDirectory) { | |
239 QNativePointer pid = new QNativePointer(QNativePointer.Type.Long); | |
240 boolean success = startDetached(program, arguments, workingDirectory, pid); | |
241 return new DetachedProcessInfo(success, pid.longValue()); | |
242 } | |
243 }// class | |
244 | |
245 class QDataStream___ extends QDataStream { | |
246 | |
247 public final bool readBoolean() { | |
248 bool res; | |
249 operator_shift_right_boolean(&res); | |
250 return res; | |
251 } | |
252 | |
253 public final byte readByte() { | |
254 byte res; | |
255 operator_shift_right_byte(&res); | |
256 return res; | |
257 } | |
258 | |
259 public final short readShort() { | |
260 short res; | |
261 operator_shift_right_short(&res); | |
262 return res; | |
263 } | |
264 | |
265 public final int readInt() { | |
266 int res; | |
267 operator_shift_right_int(&res); | |
268 return res; | |
269 } | |
270 | |
271 public final long readLong() { | |
272 long res; | |
273 operator_shift_right_long(&res); | |
274 return res; | |
275 } | |
276 | |
277 public final ushort readChar() { | |
278 ushort res; | |
279 operator_shift_right_char(&res); | |
280 return res; | |
281 } | |
282 | |
283 public final float readFloat() { | |
284 float res; | |
285 operator_shift_right_float(&res); | |
286 return res; | |
287 } | |
288 | |
289 public final double readDouble() { | |
290 double res; | |
291 operator_shift_right_double(&res); | |
292 return res; | |
293 } | |
294 | |
295 public final QDataStream writeShort(short s) { | |
296 writeShort_char(s); | |
297 return this; | |
298 } | |
299 /* | |
300 private static extern(C) void qtd_QDataStream_readString_private(void* __this_nativeId); | |
301 | |
302 private native void writeString_private(long nativeId, String string); | |
303 | |
304 public final String readString() { | |
305 if (nativeId() == 0) | |
306 throw new QNoNativeResourcesException("Function call on incomplete object of type: " + getClass().getName()); | |
307 return readString_private(nativeId()); | |
308 } | |
309 | |
310 public final void writeString(String string) { | |
311 if (nativeId() == 0) | |
312 throw new QNoNativeResourcesException("Function call on incomplete object of type: " + getClass().getName()); | |
313 writeString_private(nativeId(), string); | |
314 } | |
315 | |
316 private native int writeBytes(long id, byte buffer[], int length); | |
317 | |
318 private native int readBytes(long id, byte buffer[], int length); | |
319 | |
320 public final int writeBytes(byte buffer[]) { | |
321 return writeBytes(buffer, buffer.length); | |
322 } | |
323 | |
324 public final int writeBytes(byte buffer[], int length) { | |
325 return writeBytes(nativeId(), buffer, length); | |
326 } | |
327 | |
328 public final int readBytes(byte buffer[]) { | |
329 return readBytes(buffer, buffer.length); | |
330 } | |
331 | |
332 public final int readBytes(byte buffer[], int length) { | |
333 return readBytes(nativeId(), buffer, length); | |
334 } | |
335 */ | |
336 }// class | |
337 | |
338 class QTextStream___ extends QTextStream { | |
339 /* public final void setCodec(String codecName) { | |
340 setCodec(QNativePointer.createCharPointer(codecName)); | |
341 if (codec() != __rcCodec) | |
342 __rcCodec = null; | |
343 } | |
344 | |
345 private QNativePointer srb = new QNativePointer(QNativePointer.Type.Byte, 32) { | |
346 { | |
347 setVerificationEnabled(false); | |
348 } | |
349 }; | |
350 | |
351 public final byte readByte() { | |
352 operator_shift_right_byte(srb); | |
353 return srb.byteValue(); | |
354 } | |
355 | |
356 public final short readShort() { | |
357 operator_shift_right_short(srb); | |
358 return srb.shortValue(); | |
359 } | |
360 | |
361 public final int readInt() { | |
362 operator_shift_right_int(srb); | |
363 return srb.intValue(); | |
364 } | |
365 | |
366 public final long readLong() { | |
367 operator_shift_right_long(srb); | |
368 return srb.longValue(); | |
369 } | |
370 | |
371 public final float readFloat() { | |
372 operator_shift_right_float(srb); | |
373 return srb.floatValue(); | |
374 } | |
375 | |
376 public final double readDouble() { | |
377 operator_shift_right_double(srb); | |
378 return srb.doubleValue(); | |
379 } | |
380 | |
381 public final QTextStream writeShort(short s) { | |
382 writeShort_char((char) s); | |
383 return this; | |
384 } | |
385 | |
386 public final QTextStream writeChar(char c) { | |
387 writeShort_char(c); | |
388 return this; | |
389 } | |
390 | |
391 public final char readChar() { | |
392 operator_shift_right_short(srb); | |
393 return srb.charValue(); | |
394 } | |
395 | |
396 public final String readString() { | |
397 return readString_native(nativeId()); | |
398 } | |
399 | |
400 public final void writeString(String string) { | |
401 writeString_native(nativeId(), string); | |
402 } | |
403 | |
404 private final native String readString_native(long id); | |
405 | |
406 private final native void writeString_native(long id, String string); | |
407 */ | |
408 }// class | |
409 | |
410 class QBitArray___ extends QBitArray { | |
411 /* | |
412 @qt.QtBlockedSlot | |
413 public final void xor(QBitArray other) { | |
414 operator_xor_assign(other); | |
415 } | |
416 | |
417 @qt.QtBlockedSlot | |
418 public final void and(QBitArray other) { | |
419 operator_and_assign(other); | |
420 } | |
421 | |
422 @qt.QtBlockedSlot | |
423 public final void or(QBitArray other) { | |
424 operator_or_assign(other); | |
425 } | |
426 | |
427 @qt.QtBlockedSlot | |
428 public final void set(QBitArray other) { | |
429 operator_assign(other); | |
430 } | |
431 | |
432 @qt.QtBlockedSlot | |
433 public final QBitArray inverted() { | |
434 return operator_negate(); | |
435 } | |
436 */ | |
437 }// class | |
438 | |
439 // hfr | |
440 | |
441 class QDate___ extends QDate { | |
442 | |
443 public final int weekNumber() { | |
444 return weekNumber(null); | |
445 } | |
446 | |
447 public final int yearOfWeekNumber() { | |
448 int np; | |
449 weekNumber(&np); | |
450 return np; | |
451 } | |
452 | |
453 }// class | |
454 | |
455 class QDir___ extends QDir { | |
456 /* | |
457 @qt.QtBlockedSlot | |
458 public String at(int i) { | |
459 return operator_subscript(i); | |
460 } | |
461 */ | |
462 }// class | |
463 | |
464 class QByteArray___ extends QByteArray { | |
465 public QByteArray(String s) { | |
466 this(); | |
467 append(s); | |
468 } | |
469 | |
470 public QByteArray(byte data[]) { | |
471 this(qt.internal.QtJambiInternal.byteArrayToNativePointer(data), data.length); | |
472 } | |
473 | |
474 public final boolean contains(String str) { | |
475 return contains(new QByteArray(str)); | |
476 } | |
477 | |
478 public final int count(String str) { | |
479 return count(new QByteArray(str)); | |
480 } | |
481 | |
482 public final boolean endsWith(String str) { | |
483 return endsWith(new QByteArray(str)); | |
484 } | |
485 | |
486 public final QByteArray prepend(String str) { | |
487 return prepend(new QByteArray(str)); | |
488 } | |
489 | |
490 public final QByteArray replace(QByteArray before, String after) { | |
491 return replace(before, new QByteArray(after)); | |
492 } | |
493 | |
494 public final QByteArray replace(String before, String after) { | |
495 return replace(new QByteArray(before), new QByteArray(after)); | |
496 } | |
497 | |
498 public final boolean startsWith(String str) { | |
499 return startsWith(new QByteArray(str)); | |
500 } | |
501 | |
502 public final byte[] toByteArray() { | |
503 byte[] res = new byte[size()]; | |
504 | |
505 for (int i = 0; i < size(); i++) { | |
506 res[i] = at(i); | |
507 } | |
508 return res; | |
509 } | |
510 | |
511 @qt.QtBlockedSlot | |
512 public final QByteArray set(QByteArray other) { | |
513 operator_assign(other); | |
514 return this; | |
515 } | |
516 | |
517 }// class | |
518 | |
519 class QFile___ extends QFile { | |
520 /* | |
521 public static String decodeName(String localFileName) { | |
522 return decodeName(qt.QNativePointer.createCharPointer(localFileName)); | |
523 } | |
524 */ | |
525 }// class | |
526 | |
527 class QIODevice___ extends QIODevice { | |
528 | |
529 /** | |
530 * Gets a byte from the device. | |
531 * | |
532 * @return -1 on failure, or the value of the byte on success | |
533 */ | |
534 /* public final int getByte() { | |
535 QNativePointer np = new QNativePointer(QNativePointer.Type.Byte); | |
536 boolean success = getByte(np); | |
537 return success ? np.byteValue() : -1; | |
538 } | |
539 */ | |
180 | 540 |
541 public final long write(string str) { | |
542 return write(str.ptr, str.length); | |
248 | 543 } |
1 | 544 }// class |
545 | |
546 class QCryptographicHash___ extends QCryptographicHash { | |
547 | |
548 public final void addData(byte data[]) { | |
549 QNativePointer np = qt.internal.QtJambiInternal.byteArrayToNativePointer(data); | |
550 addData(np, data.length); | |
551 } | |
552 | |
553 }// class | |
554 | |
555 class QTextCodec___ extends QTextCodec { | |
556 /* | |
557 static { | |
558 setCodecForTr(QTextCodec.codecForName("UTF-8")); | |
559 } | |
560 | |
561 public static QTextCodec codecForName(String name) { | |
562 return codecForName(qt.QNativePointer.createCharPointer(name)); | |
563 } | |
564 */ | |
565 }// class | |
566 | |
567 class QBuffer___ extends QBuffer { | |
568 | |
569 // retain a reference to avoid gc | |
570 private Object strongDataReference = null; | |
571 public final void setBuffer(QByteArray byteArray) { | |
90 | 572 setBuffer_private(byteArray); |
1 | 573 strongDataReference = byteArray; |
574 } | |
575 | |
576 public final void setData(byte data[]) { | |
90 | 577 setData(cast(char*)data.ptr, data.length); |
1 | 578 } |
579 | |
580 }// class | |
581 | |
582 class QSignalMapper___ extends QSignalMapper { | |
583 | |
584 private java.util.Hashtable<QObject, QObject> __rcObjectForObject = new java.util.Hashtable<QObject, QObject>(); | |
585 | |
586 private java.util.Hashtable<QObject, Object> __rcWidgetForObject = new java.util.Hashtable<QObject, Object>(); | |
587 | |
588 }// class | |
589 | |
590 class QAbstractFileEngine_MapExtensionReturn___ extends QAbstractFileEngine_MapExtensionReturn { | |
591 /* private QNativePointer currentAddressNativePointer; // don't garbage collect while in use | |
592 public final void setAddress(String address) { | |
593 currentAddressNativePointer = address != null ? QNativePointer.createCharPointer(address) : null; | |
594 address_private(currentAddressNativePointer); | |
595 } | |
596 | |
597 public final String address() { | |
598 QNativePointer np = address_private(); | |
599 return np != null ? qt.internal.QtJambiInternal.charPointerToString(np) : null; | |
600 }*/ | |
601 }// class | |
602 | |
603 class QAbstractFileEngine___ extends QAbstractFileEngine { | |
604 /** | |
605 * Adds <tt>path</tt> to the set of paths in which Qt Jambi should search for resources. Resources | |
606 * can be accessed using the "classpath:" scheme. | |
607 */ | |
608 /* public static void addSearchPathForResourceEngine(String path) | |
609 { | |
610 qt.internal.QClassPathEngine.addSearchPath(path); | |
611 } | |
612 */ | |
613 /** | |
614 * Removes <tt>path</tt> from the set of paths in which Qt Jambi searches | |
615 * for resources. | |
616 */ | |
617 /* public static void removeSearchPathForResourceEngine(String path) | |
618 { | |
619 qt.internal.QClassPathEngine.removeSearchPath(path); | |
620 } | |
621 */ | |
622 }// class | |
623 | |
624 class QAbstractFileEngine_UnMapExtensionOption___ extends QAbstractFileEngine_UnMapExtensionOption { | |
625 private QNativePointer currentAddressNativePointer; // don't garbage collect while in use | |
626 public final void setAddress(String address) { | |
627 currentAddressNativePointer = address != null ? QNativePointer.createCharPointer(address) : null; | |
628 address_private(currentAddressNativePointer); | |
629 } | |
630 | |
631 public final String address() { | |
632 QNativePointer np = address_private(); | |
633 return np != null ? qt.internal.QtJambiInternal.charPointerToString(np) : null; | |
634 } | |
635 }// class | |
636 | |
637 class QFutureWatcher___ extends QFutureWatcher { | |
638 | |
639 public final QFuture<T> future() { | |
640 if (nativeId() == 0) | |
641 throw new QNoNativeResourcesException("Function call on incomplete object of type: " +getClass().getName()); | |
642 return __qt_future(nativeId()); | |
643 } | |
644 private native QFuture<T> __qt_future(long nativeId); | |
645 | |
646 }// class | |
647 | |
648 class QFutureWatcherVoid___ extends QFutureWatcherVoid { | |
649 | |
650 public final QFutureVoid future() { | |
651 if (nativeId() == 0) | |
652 throw new QNoNativeResourcesException("Function call on incomplete object of type: " +getClass().getName()); | |
653 return __qt_future(nativeId()); | |
654 } | |
655 | |
656 private native QFutureVoid __qt_future(long nativeId); | |
657 | |
658 }// class | |
659 | |
660 class QFutureSynchronizer___ extends QFutureSynchronizer { | |
661 | |
662 public final java.util.List<QFuture<T>> futures() { | |
663 if (nativeId() == 0) | |
664 throw new QNoNativeResourcesException("Function call on incomplete object of type: " +getClass().getName()); | |
665 return __qt_futures(nativeId()); | |
666 } | |
667 private native java.util.List<QFuture<T>> __qt_futures(long nativeId); | |
668 | |
669 }// class | |
670 | |
671 class QFutureSynchronizerVoid___ extends QFutureSynchronizerVoid { | |
672 | |
673 public final java.util.List<QFutureVoid> futures() { | |
674 if (nativeId() == 0) | |
675 throw new QNoNativeResourcesException("Function call on incomplete object of type: " +getClass().getName()); | |
676 return __qt_futures(nativeId()); | |
677 } | |
678 private native java.util.List<QFutureVoid> __qt_futures(long nativeId); | |
679 | |
680 }// class | |
681 | |
682 class QLineF___ extends QLineF { | |
683 /* | |
684 public final QLineF.IntersectType intersect(QLineF line, qt.core.QPointF intersectionPoint) { | |
685 return intersect(line, intersectionPoint != null ? intersectionPoint.nativePointer() : null); | |
686 } | |
687 */ | |
688 }// class | |
689 | |
690 /** | |
691 The QtConcurrent class contains static methods for running computations in parallel (using separate threads) | |
692 on the items in a java.util.Collection, such as a Vector or LinkedList. We will now describe these methods. | |
693 | |
694 The QtConcurrent::map(), QtConcurrent::mapped() and QtConcurrent::mappedReduced() functions run computations in parallel on the items in a sequence such as a QList or a QVector. QtConcurrent::map() modifies a sequence in-place, QtConcurrent::mapped() returns a new sequence containing the modified content, and QtConcurrent::mappedReduced() returns a single result. | |
695 Concurrent Map | |
696 <p> | |
697 QtConcurrent::mapped() takes an input sequence and a map function. This map function is then called for each item in the sequence, and a new sequence containing the return values from the map function is returned. | |
698 <p> | |
699 The map function must be of the form: | |
700 <pre> | |
701 U function(const T &t); | |
702 </pre> | |
703 T and U can be any type (and they can even be the same type), but T must match the type stored in the sequence. The function returns the modified or mapped content. | |
704 <p> | |
705 This example shows how to apply a scale function to all the items in a sequence: | |
706 <pre> | |
707 QImage scaled(const QImage &image) | |
708 { | |
709 return image.scaled(100, 100); | |
710 } | |
711 | |
712 QList <QImage> images = ...; | |
713 QFuture<QImage> thumbnails = QtConcurrent::mapped(images, scaled); | |
714 </pre> | |
715 The results of the map are made available through QFuture. See the QFuture and QFutureWatcher documentation for more information on how to use QFuture in your applications. | |
716 <p> | |
717 If you want to modify a sequence in-place, use QtConcurrent::map(). The map function must then be of the form: | |
718 <pre> | |
719 U function(T &t); | |
720 </pre> | |
721 Note that the return value and return type of the map function are not used. | |
722 <p> | |
723 Using QtConcurrent::map() is similar to using QtConcurrent::mapped(): | |
724 <pre> | |
725 void scale(QImage &image) | |
726 { | |
727 image = image.scaled(100, 100); | |
728 } | |
729 | |
730 QList<QImage> images = ...; | |
731 QFuture<void> future = QtConcurrent::map(images, scale); | |
732 </pre> | |
733 Since the sequence is modified in place, QtConcurrent::map() does not return any results via QFuture. However, you can still use QFuture and QFutureWatcher to monitor the status of the map. | |
734 Concurrent Map-Reduce | |
735 <p> | |
736 QtConcurrent::mappedReduced() is similar to QtConcurrent::mapped(), but instead of returning a sequence with the new results, the results are combined into a single value using a reduce function. | |
737 <p> | |
738 The reduce function must be of the form: | |
739 <pre> | |
740 V function(T &result, const U &intermediate) | |
741 </pre> | |
742 T is the type of the final result, U is the return type of the map function. Note that the return value and return type of the reduce function are not used. | |
743 <p> | |
744 Call QtConcurrent::mappedReduced() like this: | |
745 <pre> | |
746 void addToCollage(QImage &collage, const QImage &thumbnail) | |
747 { | |
748 QPainter p(&collage); | |
749 static QPoint offset = QPoint(0, 0); | |
750 p.drawImage(offset, thumbnail); | |
751 offset += ...; | |
752 } | |
753 | |
754 QList<QImage> images = ...; | |
755 QFuture<QImage> collage = QtConcurrent::mappedReduced(images, scaled, addToCollage); | |
756 </pre> | |
757 The reduce function will be called once for each result returned by the map function, and should merge the intermediate into the result variable. QtConcurrent::mappedReduced() guarantees that only one thread will call reduce at a time, so using a mutex to lock the result variable is not neccesary. The QtConcurrent::ReduceOptions enum provides a way to control the order in which the reduction is done. If QtConcurrent::UnorderedReduce is used (the default), the order is undefined, while QtConcurrent::OrderedReduce ensures that the reduction is done in the order of the original sequence. | |
758 Additional API Features | |
759 Using Iterators instead of Sequence | |
760 <p> | |
761 Each of the above functions has a variant that takes an iterator range instead of a sequence. You use them in the same way as the sequence variants: | |
762 <pre> | |
763 QList<QImage> images = ...; | |
764 | |
765 QFuture<QImage> thumbnails = QtConcurrent::mapped(images.constBegin(), images.constEnd(), scaled); | |
766 | |
767 // map in-place only works on non-const iterators | |
768 QFuture<void> future = QtConcurrent::map(images.begin(), images.end(), scale); | |
769 | |
770 QFuture<QImage> collage = QtConcurrent::mappedReduced(images.constBegin(), images.constEnd(), scaled, addToCollage); | |
771 </pre> | |
772 Blocking Variants | |
773 <p> | |
774 Each of the above functions has a blocking variant that returns the final result instead of a QFuture. You use them in the same way as the asynchronous variants. | |
775 <pre> | |
776 QList<QImage> images = ...; | |
777 | |
778 // each call blocks until the entire operation is finished | |
779 QList<QImage> future = QtConcurrent::blockingMapped(images, scaled); | |
780 | |
781 QtConcurrent::blockingMap(images, scale); | |
782 | |
783 QImage collage = QtConcurrent::blockingMappedReduced(images, scaled, addToCollage); | |
784 </pre> | |
785 Note that the result types above are not QFuture objects, but real result types (in this case, QList<QImage> and QImage). | |
786 Using Member Functions | |
787 <p> | |
788 QtConcurrent::map(), QtConcurrent::mapped(), and QtConcurrent::mappedReduced() accept pointers to member functions. The member function class type must match the type stored in the sequence: | |
789 <pre> | |
790 // squeeze all strings in a QStringList | |
791 QStringList strings = ...; | |
792 QFuture<void> squeezedStrings = QtConcurrent::map(strings, &QString::squeeze); | |
793 | |
794 // swap the rgb values of all pixels on a list of images | |
795 QList<QImage> images = ...; | |
796 QFuture<QImage> bgrImages = QtConcurrent::mapped(images, &QImage::rgbSwapped); | |
797 | |
798 // create a set of the lengths of all strings in a list | |
799 QStringList strings = ...; | |
800 QFuture<QSet<int> > wordLengths = QtConcurrent::mappedReduced(string, &QString::length, &QSet<int>::insert); | |
801 </pre> | |
802 Note that when using QtConcurrent::mappedReduced(), you can mix the use of normal and member functions freely: | |
803 <p> | |
804 <pre> | |
805 // can mix normal functions and member functions with QtConcurrent::mappedReduced() | |
806 | |
807 // compute the average length of a list of strings | |
808 extern void computeAverage(int &average, int length); | |
809 QStringList strings = ...; | |
810 QFuture<int> averageWordLength = QtConcurrent::mappedReduced(strings, &QString::length, computeAverage); | |
811 | |
812 // create a set of the color distribution of all images in a list | |
813 extern int colorDistribution(const QImage &string); | |
814 QList<QImage> images = ...; | |
815 QFuture<QSet<int> > totalColorDistribution = QtConcurrent::mappedReduced(images, colorDistribution, QSet<int>::insert); | |
816 </pre> | |
817 Using Function Objects | |
818 <p> | |
819 QtConcurrent::map(), QtConcurrent::mapped(), and QtConcurrent::mappedReduced() accept function objects, which can be used to add state to a function call. The result_type typedef must define the result type of the function call operator: | |
820 <pre> | |
821 struct Scaled | |
822 { | |
823 Scaled(int size) | |
824 : m_size(size) { } | |
825 | |
826 typedef QImage result_type; | |
827 | |
828 QImage operator()(const QImage &image) | |
829 { | |
830 return image.scaled(m_size, m_size); | |
831 } | |
832 | |
833 int m_size; | |
834 }; | |
835 | |
836 QList<QImage> images = ...; | |
837 QFuture<QImage> thumbnails = QtConcurrent::mapped(images, Scaled(100)); | |
838 </pre> | |
839 Using Bound Function Arguments | |
840 <p> | |
841 Note that Qt does not provide support for bound functions. This is provided by 3rd party libraries like Boost or C++ TR1 Library Extensions. | |
842 <p> | |
843 If you want to use a map function that takes more than one argument you can use boost::bind() or std::tr1::bind() to transform it onto a function that takes one argument. | |
844 <p> | |
845 As an example, we'll use QImage::scaledToWidth(): | |
846 <pre> | |
847 QImage QImage::scaledToWidth(int width, Qt::TransformationMode) const; | |
848 </pre> | |
849 scaledToWidth takes three arguments (including the "this" pointer) and can't be used with QtConcurrent::mapped() directly, because QtConcurrent::mapped() expects a function that takes one argument. To use QImage::scaledToWidth() with QtConcurrent::mapped() we have to provide a value for the width and the transformation mode: | |
850 <pre> | |
851 boost::bind(&QImage::scaledToWidth, 100 Qt::SmoothTransformation) | |
852 </pre> | |
853 The return value from boost::bind() is a function object (functor) with the following signature: | |
854 <pre> | |
855 QImage scaledToWith(const QImage &image) | |
856 </pre> | |
857 This matches what QtConcurrent::mapped() expects, and the complete example becomes: | |
858 <pre> | |
859 QList>QImage< images = ...; | |
860 QFuture>QImage< thumbnails = QtConcurrent::mapped(images, boost::bind(&QImage::scaledToWidth, 100 Qt::SmoothTransformation)); | |
861 </pre> | |
862 */ | |
863 class QtConcurrent___ extends QtConcurrent { | |
864 | |
865 static { | |
866 qt.QtJambi_LibraryInitializer.init(); | |
867 qt.core.QtJambi_LibraryInitializer.init(); | |
868 } | |
869 | |
870 /** | |
871 * An implemetation of this interface is given one to QtConcurrent's map() methods. | |
872 * The map() method of this interface is called for each object in a java.util.Collection. | |
873 * | |
874 */ | |
875 public interface MapFunctor<T> { | |
876 | |
877 /** | |
878 * This function is called for each item in the Collection. The function is then free to alter <tt>object</tt> as it see fit. | |
879 */ | |
880 public void map(T object); | |
881 } | |
882 /** | |
883 * Calls function once for each item in sequence. The function is passed a reference to the item, so that any modifications done to the item will appear in sequence. | |
884 */ | |
885 public static native <T> QFutureVoid map(java.util.Collection<T> sequence, MapFunctor<T> functor); | |
886 | |
887 /** | |
888 * Calls function once for each item in sequence. The function is passed a reference to the item, so that any modifications done to the item will appear in sequence. | |
889 */ | |
890 public static native <T> void blockingMap(java.util.Collection<T> sequence, MapFunctor<T> functor); | |
891 | |
892 /** | |
893 * Implement this interface to perform a mapped operation. An implementation of the interface is sendt | |
894 * to ome of the mapped methods of QtConcurrent, which applies the MappedFunctor.map() method to all elements in a collection, | |
895 * and returns the result. | |
896 */ | |
897 public interface MappedFunctor<U, T> { | |
898 | |
899 /** | |
900 * This method is called for each object in a collection. It should returned a new altered | |
901 * object. | |
902 */ | |
903 public U map(T object); | |
904 } | |
905 | |
906 /** | |
907 * Calls function once for each item in sequence and returns a future with each mapped item as a result. You can QFutureIterator to iterate through the results. | |
908 * | |
909 */ | |
910 public static native <U, T> QFuture<U> mapped(java.util.Collection<T> sequence, MappedFunctor<U, T> functor); | |
911 | |
912 /** | |
913 * Calls function once for each item in sequence and returns a future with each mapped item as a result. You can QFutureIterator to iterate through the results. | |
914 */ | |
915 public static native <U, T> java.util.List<U> blockingMapped(java.util.Collection<T> sequence, MappedFunctor<U, T> functor); | |
916 | |
917 /** | |
918 * Implement this interface in order to perform a reduce operation. | |
919 * <p> | |
920 * The reduce method will be called once per intermediate result (the result of the mapping of the data) | |
921 * and the very first time the reduce() method is called for the particular data set, the result is set to | |
922 * the returned value of the defaultResult() method. | |
923 */ | |
924 public interface ReducedFunctor<U, T> { | |
925 public U defaultResult(); | |
926 | |
927 /** | |
928 * Performs a reduce operation on <tt>intermediate</tt>. <tt>result</tt> is the result of the reduction. | |
929 */ | |
930 public void reduce(U result, T intermediate); | |
931 } | |
932 | |
933 /** | |
934 * This is an overloaded method provided for convenience. | |
935 * <p> | |
936 * It is equivalent of mappedReduced(sequence, functor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce) | |
937 */ | |
938 public static <U, V, T> QFuture<U> mappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor) { | |
939 return mappedReduced(sequence, functor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce); | |
940 } | |
941 | |
942 | |
943 /** | |
944 * This is an overloaded method provided for convenience. | |
945 * <p> | |
946 * Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions. | |
947 * | |
948 */ | |
949 public static <U, V, T> QFuture<U> mappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor, ReduceOption ... options) { | |
950 return mappedReduced(sequence, functor, reducedFunctor, new ReduceOptions(options)); | |
951 } | |
952 | |
953 /** | |
954 * Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction. | |
955 * <p> | |
956 * Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions. | |
957 * | |
958 */ | |
959 public static <U, V, T> QFuture<U> mappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor, ReduceOptions options) { | |
960 return mappedReduced(sequence, functor, reducedFunctor, options.value()); | |
961 } | |
962 | |
963 private native static <U, V, T> QFuture<U> mappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor, int options); | |
964 | |
965 | |
966 /** | |
967 * This is an overloaded method provided for convenience. | |
968 * <p> | |
969 * It is equivalent of calling blockingMappedReduced(sequence, functor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce) | |
970 * | |
971 */ | |
972 public static <U, V, T> U blockingMappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor) { | |
973 return blockingMappedReduced(sequence, functor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce); | |
974 } | |
975 | |
976 /** | |
977 * Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction. | |
978 * <p> | |
979 * Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions. | |
980 * <p> | |
981 * Note: This function will block until all items in the sequence have been processed. | |
982 */ | |
983 public static <U, V, T> U blockingMappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor, ReduceOption ... options) { | |
984 return blockingMappedReduced(sequence, functor, reducedFunctor, new ReduceOptions(options)); | |
985 } | |
986 | |
987 /** | |
988 * Calls mapFunction once for each item in sequence. The return value of each mapFunction is passed to reduceFunction. | |
989 * <p> | |
990 * Note that while mapFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is determined by reduceOptions. | |
991 * <p> | |
992 * Note: This function will block until all items in the sequence have been processed. | |
993 */ | |
994 public static <U, V, T> U blockingMappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor, ReduceOptions options) { | |
995 return blockingMappedReduced(sequence, functor, reducedFunctor, options.value()); | |
996 } | |
997 | |
998 private native static <U, V, T> U blockingMappedReduced(java.util.Collection<T> sequence, MappedFunctor<V, T> functor, ReducedFunctor<U, V> reducedFunctor, int options); | |
999 | |
1000 /** | |
1001 * An implementation of this interface is given to one of QtConcurrent's filtered() methods. | |
1002 * The filter method if this interface is called for each item in a java.util.Collection. | |
1003 * | |
1004 */ | |
1005 public interface FilteredFunctor<T> { | |
1006 | |
1007 /** | |
1008 * This method is called for each item in a java.util.Collection. The items for which | |
1009 * this method returns true are removed from the collection. | |
1010 */ | |
1011 public boolean filter(T object); | |
1012 } | |
1013 | |
1014 /** | |
1015 * Calls filterFunctor's filtered() method once for each item in sequence and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence. | |
1016 */ | |
1017 public native static <T> QFuture<T> filtered(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor); | |
1018 | |
1019 /** | |
1020 * Calls filterFunctor's filtered() method once for each item in sequence and returns a new Sequence of kept items. If filterFunction returns true, a copy of the item is put in the new Sequence. Otherwise, the item will not appear in the new Sequence. | |
1021 */ | |
1022 public native static <T> java.util.List<T> blockingFiltered(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor); | |
1023 | |
1024 | |
1025 /** | |
1026 * This is an overloaded method provided for convenience. It is equivalent of calling filteredReduced(sequence, filteredFunctor, ReduceOption.UnorderedReduce, ReduceOption.Seq This is an overloaded method provided for convenience. It is equivalent of calling filteredReduced) | |
1027 */ | |
1028 public static <U, T> QFuture<U> filteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor) { | |
1029 return filteredReduced(sequence, filteredFunctor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce); | |
1030 } | |
1031 | |
1032 /** | |
1033 * Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. | |
1034 * <p> | |
1035 * Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence. | |
1036 */ | |
1037 public static <U, T> QFuture<U> filteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor, ReduceOption ... options) { | |
1038 return filteredReduced(sequence, filteredFunctor, reducedFunctor, new ReduceOptions(options)); | |
1039 } | |
1040 | |
1041 /** | |
1042 * Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. | |
1043 * <p> | |
1044 * Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence. | |
1045 */ | |
1046 public static <U, T> QFuture<U> filteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor, ReduceOptions options) { | |
1047 return filteredReduced(sequence, filteredFunctor, reducedFunctor, options.value()); | |
1048 } | |
1049 private native static <U, T> QFuture<U> filteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor, int options); | |
1050 | |
1051 /** | |
1052 * This is an overloaded method provided for convenience. It is the equivalent of calling blockingFilteredReduced(sequence, filteredFunctor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce) | |
1053 */ | |
1054 public static <U, T> U blockingFilteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor) { | |
1055 return blockingFilteredReduced(sequence, filteredFunctor, reducedFunctor, ReduceOption.UnorderedReduce, ReduceOption.SequentialReduce); | |
1056 } | |
1057 | |
1058 /** | |
1059 * Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. | |
1060 * <p> | |
1061 * Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence. | |
1062 */ | |
1063 public static <U, T> U blockingFilteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor, ReduceOption ... options) { | |
1064 return blockingFilteredReduced(sequence, filteredFunctor, reducedFunctor, new ReduceOptions(options)); | |
1065 } | |
1066 | |
1067 /** | |
1068 * Calls filterFunction once for each item in sequence. If filterFunction returns true for an item, that item is then passed to reduceFunction. In other words, the return value is the result of reduceFunction for each item where filterFunction returns true. | |
1069 * <p> | |
1070 * Note that while filterFunction is called concurrently, only one thread at a time will call reduceFunction. The order in which reduceFunction is called is undefined if reduceOptions is QtConcurrent::UnorderedReduce. If reduceOptions is QtConcurrent::OrderedReduce, reduceFunction is called in the order of the original sequence. | |
1071 */ | |
1072 public static <U, T> U blockingFilteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor, ReduceOptions options) { | |
1073 return blockingFilteredReduced(sequence, filteredFunctor, reducedFunctor, options.value()); | |
1074 } | |
1075 | |
1076 private native static <U, T> U blockingFilteredReduced(java.util.Collection<T> sequence, FilteredFunctor<T> filteredFunctor, ReducedFunctor<U, T> reducedFunctor, int options); | |
1077 | |
1078 /** | |
1079 * Executes the method <tt>m</tt> through the QtConcurrent framework with the given arguments. The returned QFuture object's result wil be the | |
1080 * return value of <tt>m</tt>. Note that this method does not accept function that return void. use runVoidMethod() for this. | |
1081 */ | |
1082 public static <T> QFuture<T> run(Object _this, java.lang.reflect.Method m, Object ... args) { | |
1083 if (m.getReturnType() == null || m.getReturnType().equals(Void.TYPE)) | |
1084 throw new IllegalArgumentException("Cannot call run on method returning void. Use 'runVoidMethod' instead."); | |
1085 | |
1086 return runPrivate(_this, m.getDeclaringClass(), m, args, qt.internal.QtJambiInternal.resolveConversionSchema(m.getParameterTypes(), m.getParameterTypes()), qt.internal.QtJambiInternal.typeConversionCode(m.getReturnType())); | |
1087 } | |
1088 private native static <T> QFuture<T> runPrivate(Object _this, Class<?> declaringClass, java.lang.reflect.Method m, Object args[], int conversionScheme[], byte returnType); | |
1089 | |
1090 /** | |
1091 * Executes the method <tt>m</tt> with the given arguments using the QtConcurrent framework. Notice that runVoidMethod() does not | |
1092 * accept methods that has a return value. Use the run() method for this purpose. | |
1093 */ | |
1094 public static QFutureVoid runVoidMethod(Object _this, java.lang.reflect.Method m, Object ... args) { | |
1095 if (m.getReturnType() != null && !m.getReturnType().equals(Void.TYPE)) | |
1096 throw new IllegalArgumentException("Cannot call runVoidMethod on method returning non-void type. Use 'run' instead."); | |
1097 | |
1098 return runVoidMethodPrivate(_this, m.getDeclaringClass(), m, args, qt.internal.QtJambiInternal.resolveConversionSchema(m.getParameterTypes(), m.getParameterTypes())); | |
1099 } | |
1100 private native static QFutureVoid runVoidMethodPrivate(Object _this, Class<?> declaringClass, java.lang.reflect.Method m, Object args[], int conversionScheme[]); | |
1101 | |
1102 | |
1103 }// class |