I've no idea here...
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Iterator.d
blob0a381d5da3ee0c63c49e48a52ce131e0dec2dc97
1 /*
2 * This file is part of gtkD.
4 * gtkD is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * gtkD is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with gtkD; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = gstreamer-GstIterator.html
26 * outPack = gstreamer
27 * outFile = Iterator
28 * strct = GstIterator
29 * realStrct=
30 * ctorStrct=
31 * clss = Iterator
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - gst_iterator_
40 * - gst_
41 * omit structs:
42 * omit prefixes:
43 * omit code:
44 * imports:
45 * - glib.Str
46 * structWrap:
47 * - GstIterator* -> Iterator
48 * module aliases:
49 * local aliases:
52 module gstreamer.Iterator;
54 version(noAssert)
56 version(Tango)
58 import tango.io.Stdout; // use the tango loging?
62 private import gstreamerc.gstreamertypes;
64 private import gstreamerc.gstreamer;
67 private import glib.Str;
72 /**
73 * Description
74 * A GstIterator is used to retrieve multiple objects from another object in
75 * a threadsafe way.
76 * Various GStreamer objects provide access to their internal structures using
77 * an iterator.
78 * The basic use pattern of an iterator is as follows:
79 * Example10.Using an iterator
80 * it = _get_iterator(object);
81 * done = FALSE;
82 * while (!done) {
83 * switch (gst_iterator_next (it, item)) {
84 * case GST_ITERATOR_OK:
85 * ... use/change item here...
86 * gst_object_unref (item);
87 * break;
88 * case GST_ITERATOR_RESYNC:
89 * ...rollback changes to items...
90 * gst_iterator_resync (it);
91 * break;
92 * case GST_ITERATOR_ERROR:
93 * ...wrong parameter were given...
94 * done = TRUE;
95 * break;
96 * case GST_ITERATOR_DONE:
97 * done = TRUE;
98 * break;
99 * }
101 * gst_iterator_free (it);
102 * Last reviewed on 2005-11-09 (0.9.4)
104 public class Iterator
107 /** the main Gtk struct */
108 protected GstIterator* gstIterator;
111 public GstIterator* getIteratorStruct()
113 return gstIterator;
117 /** the main Gtk struct as a void* */
118 protected void* getStruct()
120 return cast(void*)gstIterator;
124 * Sets our main struct and passes it to the parent class
126 public this (GstIterator* gstIterator)
128 version(noAssert)
130 if ( gstIterator is null )
132 int zero = 0;
133 version(Tango)
135 Stdout("struct gstIterator is null on constructor").newline;
137 else
139 printf("struct gstIterator is null on constructor");
141 zero = zero / zero;
144 else
146 assert(gstIterator !is null, "struct gstIterator is null on constructor");
148 this.gstIterator = gstIterator;
168 * Create a new iterator. This function is mainly used for objects
169 * implementing the next/resync/free function to iterate a data structure.
170 * For each item retrieved, the item function is called with the lock
171 * held. The free function is called when the iterator is freed.
172 * size:
173 * the size of the iterator structure
174 * type:
175 * GType of children
176 * lock:
177 * pointer to a GMutex.
178 * master_cookie:
179 * pointer to a guint32 to protect the iterated object.
180 * next:
181 * function to get next item
182 * item:
183 * function to call on each item retrieved
184 * resync:
185 * function to resync the iterator
186 * free:
187 * function to free the iterator
188 * Returns:
189 * the new GstIterator.
190 * MT safe.
192 public this (uint size, GType type, GMutex* lock, uint* masterCookie, GstIteratorNextFunction next, GstIteratorItemFunction item, GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
194 // GstIterator* gst_iterator_new (guint size, GType type, GMutex *lock, guint32 *master_cookie, GstIteratorNextFunction next, GstIteratorItemFunction item, GstIteratorResyncFunction resync, GstIteratorFreeFunction free);
195 this(cast(GstIterator*)gst_iterator_new(size, type, lock, masterCookie, next, item, resync, free) );
199 * Create a new iterator designed for iterating list.
200 * type:
201 * GType of elements
202 * lock:
203 * pointer to a GMutex protecting the list.
204 * master_cookie:
205 * pointer to a guint32 to protect the list.
206 * list:
207 * pointer to the list
208 * owner:
209 * object owning the list
210 * item:
211 * function to call for each item
212 * free:
213 * function to call when the iterator is freed
214 * Returns:
215 * the new GstIterator for list.
216 * MT safe.
218 public this (GType type, GMutex* lock, uint* masterCookie, GList** list, void* owner, GstIteratorItemFunction item, GstIteratorDisposeFunction free)
220 // GstIterator* gst_iterator_new_list (GType type, GMutex *lock, guint32 *master_cookie, GList **list, gpointer owner, GstIteratorItemFunction item, GstIteratorDisposeFunction free);
221 this(cast(GstIterator*)gst_iterator_new_list(type, lock, masterCookie, list, owner, item, free) );
225 * Get the next item from the iterator. For iterators that return
226 * refcounted objects, the returned object will have its refcount
227 * increased and should therefore be unreffed after usage.
228 * it:
229 * The GstIterator to iterate
230 * elem:
231 * pointer to hold next element
232 * Returns:
233 * The result of the iteration. Unref after usage if this is
234 * a refcounted object.
235 * MT safe.
237 public GstIteratorResult next(void** elem)
239 // GstIteratorResult gst_iterator_next (GstIterator *it, gpointer *elem);
240 return gst_iterator_next(gstIterator, elem);
244 * Resync the iterator. this function is mostly called
245 * after gst_iterator_next() returned GST_ITERATOR_RESYNC.
246 * MT safe.
247 * it:
248 * The GstIterator to resync
250 public void resync()
252 // void gst_iterator_resync (GstIterator *it);
253 gst_iterator_resync(gstIterator);
257 * Free the iterator.
258 * MT safe.
259 * it:
260 * The GstIterator to free
262 public void free()
264 // void gst_iterator_free (GstIterator *it);
265 gst_iterator_free(gstIterator);
269 * Pushes other iterator onto it. All calls performed on it are
270 * forwarded tot other. If other returns GST_ITERATOR_DONE, it is
271 * popped again and calls are handled by it again.
272 * This function is mainly used by objects implementing the iterator
273 * next function to recurse into substructures.
274 * MT safe.
275 * it:
276 * The GstIterator to use
277 * other:
278 * The GstIterator to push
280 public void push(Iterator other)
282 // void gst_iterator_push (GstIterator *it, GstIterator *other);
283 gst_iterator_push(gstIterator, (other is null) ? null : other.getIteratorStruct());
287 * Create a new iterator from an existing iterator. The new iterator
288 * will only return those elements that match the given compare function func.
289 * func should return 0 for elements that should be included
290 * in the iterator.
291 * When this iterator is freed, it will also be freed.
292 * it:
293 * The GstIterator to filter
294 * func:
295 * the compare function to select elements
296 * user_data:
297 * user data passed to the compare function
298 * Returns:
299 * a new GstIterator.
300 * MT safe.
302 public Iterator filter(GCompareFunc func, void* userData)
304 // GstIterator* gst_iterator_filter (GstIterator *it, GCompareFunc func, gpointer user_data);
305 return new Iterator( gst_iterator_filter(gstIterator, func, userData) );
309 * Folds func over the elements of iter. That is to say, proc will be called
310 * as proc (object, ret, user_data) for each object in iter. The normal use
311 * of this procedure is to accumulate the results of operating on the objects in
312 * ret.
313 * This procedure can be used (and is used internally) to implement the foreach
314 * and find_custom operations.
315 * The fold will proceed as long as func returns TRUE. When the iterator has no
316 * more arguments, GST_ITERATOR_DONE will be returned. If func returns FALSE,
317 * the fold will stop, and GST_ITERATOR_OK will be returned. Errors or resyncs
318 * will cause fold to return GST_ITERATOR_ERROR or GST_ITERATOR_RESYNC as
319 * appropriate.
320 * The iterator will not be freed.
321 * it:
322 * The GstIterator to fold over
323 * func:
324 * the fold function
325 * ret:
326 * the seed value passed to the fold function
327 * user_data:
328 * user data passed to the fold function
329 * Returns:
330 * A GstIteratorResult, as described above.
331 * MT safe.
333 public GstIteratorResult fold(GstIteratorFoldFunction func, GValue* ret, void* userData)
335 // GstIteratorResult gst_iterator_fold (GstIterator *it, GstIteratorFoldFunction func, GValue *ret, gpointer user_data);
336 return gst_iterator_fold(gstIterator, func, ret, userData);
340 * Iterate over all element of it and call the given function func for
341 * each element.
342 * it:
343 * The GstIterator to iterate
344 * func:
345 * the function to call for each element.
346 * user_data:
347 * user data passed to the function
348 * Returns:
349 * the result call to gst_iterator_fold(). The iterator will not be
350 * freed.
351 * MT safe.
353 public GstIteratorResult foreac(GFunc func, void* userData)
355 // GstIteratorResult gst_iterator_foreach (GstIterator *it, GFunc func, gpointer user_data);
356 return gst_iterator_foreach(gstIterator, func, userData);
360 * Find the first element in it that matches the compare function func.
361 * func should return 0 when the element is found.
362 * The iterator will not be freed.
363 * This function will return NULL if an error or resync happened to
364 * the iterator.
365 * it:
366 * The GstIterator to iterate
367 * func:
368 * the compare function to use
369 * user_data:
370 * user data passed to the compare function
371 * Returns:
372 * The element in the iterator that matches the compare
373 * function or NULL when no element matched.
374 * MT safe.
375 * See Also
376 * GstElement, GstBin
378 public void* findCustom(GCompareFunc func, void* userData)
380 // gpointer gst_iterator_find_custom (GstIterator *it, GCompareFunc func, gpointer user_data);
381 return gst_iterator_find_custom(gstIterator, func, userData);