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
47 * - GstIterator* -> Iterator
52 module gstreamer
.Iterator
;
58 import tango
.io
.Stdout
; // use the tango loging?
62 private import gstreamerc
.gstreamertypes
;
64 private import gstreamerc
.gstreamer
;
67 private import glib
.Str
;
74 * A GstIterator is used to retrieve multiple objects from another object in
76 * Various GStreamer objects provide access to their internal structures using
78 * The basic use pattern of an iterator is as follows:
79 * Example10.Using an iterator
80 * it = _get_iterator(object);
83 * switch (gst_iterator_next (it, item)) {
84 * case GST_ITERATOR_OK:
85 * ... use/change item here...
86 * gst_object_unref (item);
88 * case GST_ITERATOR_RESYNC:
89 * ...rollback changes to items...
90 * gst_iterator_resync (it);
92 * case GST_ITERATOR_ERROR:
93 * ...wrong parameter were given...
96 * case GST_ITERATOR_DONE:
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()
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
)
130 if ( gstIterator
is null )
135 Stdout("struct gstIterator is null on constructor").newline
;
139 printf("struct gstIterator is null on constructor");
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.
173 * the size of the iterator structure
177 * pointer to a GMutex.
179 * pointer to a guint32 to protect the iterated object.
181 * function to get next item
183 * function to call on each item retrieved
185 * function to resync the iterator
187 * function to free the iterator
189 * the new GstIterator.
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.
203 * pointer to a GMutex protecting the list.
205 * pointer to a guint32 to protect the list.
207 * pointer to the list
209 * object owning the list
211 * function to call for each item
213 * function to call when the iterator is freed
215 * the new GstIterator for list.
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.
229 * The GstIterator to iterate
231 * pointer to hold next element
233 * The result of the iteration. Unref after usage if this is
234 * a refcounted object.
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.
248 * The GstIterator to resync
252 // void gst_iterator_resync (GstIterator *it);
253 gst_iterator_resync(gstIterator
);
260 * The GstIterator to 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.
276 * The GstIterator to use
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
291 * When this iterator is freed, it will also be freed.
293 * The GstIterator to filter
295 * the compare function to select elements
297 * user data passed to the compare function
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
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
320 * The iterator will not be freed.
322 * The GstIterator to fold over
326 * the seed value passed to the fold function
328 * user data passed to the fold function
330 * A GstIteratorResult, as described above.
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
343 * The GstIterator to iterate
345 * the function to call for each element.
347 * user data passed to the function
349 * the result call to gst_iterator_fold(). The iterator will not be
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
366 * The GstIterator to iterate
368 * the compare function to use
370 * user data passed to the compare function
372 * The element in the iterator that matches the compare
373 * function or NULL when no element matched.
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
);