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