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