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