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