alternative to assert
[gtkD.git] / gtkD / srcgstreamer / gstreamer / Iterator.d
blob438f288a5c7130733030237c8d0f5967f45ad1c2
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 private import gstreamerc.gstreamertypes;
56 private import gstreamerc.gstreamer;
58 private import glib.Str;
62 /**
63 * Description
64 * A GstIterator is used to retrieve multiple objects from another object in
65 * a threadsafe way.
66 * Various GStreamer objects provide access to their internal structures using
67 * an iterator.
68 * The basic use pattern of an iterator is as follows:
69 * Example10.Using an iterator
70 * it = _get_iterator(object);
71 * done = FALSE;
72 * while (!done) {
73 * switch (gst_iterator_next (it, item)) {
74 * case GST_ITERATOR_OK:
75 * ... use/change item here...
76 * gst_object_unref (item);
77 * break;
78 * case GST_ITERATOR_RESYNC:
79 * ...rollback changes to items...
80 * gst_iterator_resync (it);
81 * break;
82 * case GST_ITERATOR_ERROR:
83 * ...wrong parameter were given...
84 * done = TRUE;
85 * break;
86 * case GST_ITERATOR_DONE:
87 * done = TRUE;
88 * break;
89 * }
90 * }
91 * gst_iterator_free (it);
92 * Last reviewed on 2005-11-09 (0.9.4)
94 public class Iterator
97 /** the main Gtk struct */
98 protected GstIterator* gstIterator;
101 public GstIterator* getIteratorStruct()
103 return gstIterator;
107 /** the main Gtk struct as a void* */
108 protected void* getStruct()
110 return cast(void*)gstIterator;
114 * Sets our main struct and passes it to the parent class
116 public this (GstIterator* gstIterator)
118 this.gstIterator = gstIterator;
138 * Create a new iterator. This function is mainly used for objects
139 * implementing the next/resync/free function to iterate a data structure.
140 * For each item retrieved, the item function is called with the lock
141 * held. The free function is called when the iterator is freed.
142 * size:
143 * the size of the iterator structure
144 * type:
145 * GType of children
146 * lock:
147 * pointer to a GMutex.
148 * master_cookie:
149 * pointer to a guint32 to protect the iterated object.
150 * next:
151 * function to get next item
152 * item:
153 * function to call on each item retrieved
154 * resync:
155 * function to resync the iterator
156 * free:
157 * function to free the iterator
158 * Returns:
159 * the new GstIterator.
160 * MT safe.
162 public this (uint size, GType type, GMutex* lock, uint* masterCookie, GstIteratorNextFunction next, GstIteratorItemFunction item, GstIteratorResyncFunction resync, GstIteratorFreeFunction free)
164 // GstIterator* gst_iterator_new (guint size, GType type, GMutex *lock, guint32 *master_cookie, GstIteratorNextFunction next, GstIteratorItemFunction item, GstIteratorResyncFunction resync, GstIteratorFreeFunction free);
165 this(cast(GstIterator*)gst_iterator_new(size, type, lock, masterCookie, next, item, resync, free) );
169 * Create a new iterator designed for iterating list.
170 * type:
171 * GType of elements
172 * lock:
173 * pointer to a GMutex protecting the list.
174 * master_cookie:
175 * pointer to a guint32 to protect the list.
176 * list:
177 * pointer to the list
178 * owner:
179 * object owning the list
180 * item:
181 * function to call for each item
182 * free:
183 * function to call when the iterator is freed
184 * Returns:
185 * the new GstIterator for list.
186 * MT safe.
188 public this (GType type, GMutex* lock, uint* masterCookie, GList** list, void* owner, GstIteratorItemFunction item, GstIteratorDisposeFunction free)
190 // GstIterator* gst_iterator_new_list (GType type, GMutex *lock, guint32 *master_cookie, GList **list, gpointer owner, GstIteratorItemFunction item, GstIteratorDisposeFunction free);
191 this(cast(GstIterator*)gst_iterator_new_list(type, lock, masterCookie, list, owner, item, free) );
195 * Get the next item from the iterator. For iterators that return
196 * refcounted objects, the returned object will have its refcount
197 * increased and should therefore be unreffed after usage.
198 * it:
199 * The GstIterator to iterate
200 * elem:
201 * pointer to hold next element
202 * Returns:
203 * The result of the iteration. Unref after usage if this is
204 * a refcounted object.
205 * MT safe.
207 public GstIteratorResult next(void** elem)
209 // GstIteratorResult gst_iterator_next (GstIterator *it, gpointer *elem);
210 return gst_iterator_next(gstIterator, elem);
214 * Resync the iterator. this function is mostly called
215 * after gst_iterator_next() returned GST_ITERATOR_RESYNC.
216 * MT safe.
217 * it:
218 * The GstIterator to resync
220 public void resync()
222 // void gst_iterator_resync (GstIterator *it);
223 gst_iterator_resync(gstIterator);
227 * Free the iterator.
228 * MT safe.
229 * it:
230 * The GstIterator to free
232 public void free()
234 // void gst_iterator_free (GstIterator *it);
235 gst_iterator_free(gstIterator);
239 * Pushes other iterator onto it. All calls performed on it are
240 * forwarded tot other. If other returns GST_ITERATOR_DONE, it is
241 * popped again and calls are handled by it again.
242 * This function is mainly used by objects implementing the iterator
243 * next function to recurse into substructures.
244 * MT safe.
245 * it:
246 * The GstIterator to use
247 * other:
248 * The GstIterator to push
250 public void push(Iterator other)
252 // void gst_iterator_push (GstIterator *it, GstIterator *other);
253 gst_iterator_push(gstIterator, (other is null) ? null : other.getIteratorStruct());
257 * Create a new iterator from an existing iterator. The new iterator
258 * will only return those elements that match the given compare function func.
259 * func should return 0 for elements that should be included
260 * in the iterator.
261 * When this iterator is freed, it will also be freed.
262 * it:
263 * The GstIterator to filter
264 * func:
265 * the compare function to select elements
266 * user_data:
267 * user data passed to the compare function
268 * Returns:
269 * a new GstIterator.
270 * MT safe.
272 public Iterator filter(GCompareFunc func, void* userData)
274 // GstIterator* gst_iterator_filter (GstIterator *it, GCompareFunc func, gpointer user_data);
275 return new Iterator( gst_iterator_filter(gstIterator, func, userData) );
279 * Folds func over the elements of iter. That is to say, proc will be called
280 * as proc (object, ret, user_data) for each object in iter. The normal use
281 * of this procedure is to accumulate the results of operating on the objects in
282 * ret.
283 * This procedure can be used (and is used internally) to implement the foreach
284 * and find_custom operations.
285 * The fold will proceed as long as func returns TRUE. When the iterator has no
286 * more arguments, GST_ITERATOR_DONE will be returned. If func returns FALSE,
287 * the fold will stop, and GST_ITERATOR_OK will be returned. Errors or resyncs
288 * will cause fold to return GST_ITERATOR_ERROR or GST_ITERATOR_RESYNC as
289 * appropriate.
290 * The iterator will not be freed.
291 * it:
292 * The GstIterator to fold over
293 * func:
294 * the fold function
295 * ret:
296 * the seed value passed to the fold function
297 * user_data:
298 * user data passed to the fold function
299 * Returns:
300 * A GstIteratorResult, as described above.
301 * MT safe.
303 public GstIteratorResult fold(GstIteratorFoldFunction func, GValue* ret, void* userData)
305 // GstIteratorResult gst_iterator_fold (GstIterator *it, GstIteratorFoldFunction func, GValue *ret, gpointer user_data);
306 return gst_iterator_fold(gstIterator, func, ret, userData);
310 * Iterate over all element of it and call the given function func for
311 * each element.
312 * it:
313 * The GstIterator to iterate
314 * func:
315 * the function to call for each element.
316 * user_data:
317 * user data passed to the function
318 * Returns:
319 * the result call to gst_iterator_fold(). The iterator will not be
320 * freed.
321 * MT safe.
323 public GstIteratorResult foreac(GFunc func, void* userData)
325 // GstIteratorResult gst_iterator_foreach (GstIterator *it, GFunc func, gpointer user_data);
326 return gst_iterator_foreach(gstIterator, func, userData);
330 * Find the first element in it that matches the compare function func.
331 * func should return 0 when the element is found.
332 * The iterator will not be freed.
333 * This function will return NULL if an error or resync happened to
334 * the iterator.
335 * it:
336 * The GstIterator to iterate
337 * func:
338 * the compare function to use
339 * user_data:
340 * user data passed to the compare function
341 * Returns:
342 * The element in the iterator that matches the compare
343 * function or NULL when no element matched.
344 * MT safe.
345 * See Also
346 * GstElement, GstBin
348 public void* findCustom(GCompareFunc func, void* userData)
350 // gpointer gst_iterator_find_custom (GstIterator *it, GCompareFunc func, gpointer user_data);
351 return gst_iterator_find_custom(gstIterator, func, userData);