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