1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = gstreamer-GstIterator.html 27 * outPack = gstreamer 28 * outFile = Iterator 29 * strct = GstIterator 30 * realStrct= 31 * ctorStrct= 32 * clss = Iterator 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - gst_iterator_ 41 * - gst_ 42 * omit structs: 43 * omit prefixes: 44 * omit code: 45 * omit signals: 46 * imports: 47 * - glib.Str 48 * - gthread.Mutex 49 * structWrap: 50 * - GMutex* -> Mutex 51 * - GstIterator* -> Iterator 52 * module aliases: 53 * local aliases: 54 * overrides: 55 */ 56 57 module gstreamer.Iterator; 58 59 public import gstreamerc.gstreamertypes; 60 61 private import gstreamerc.gstreamer; 62 private import glib.ConstructionException; 63 private import gobject.ObjectG; 64 65 66 private import glib.Str; 67 private import gthread.Mutex; 68 69 70 71 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 * $(DDOC_COMMENT example) 80 * Last reviewed on 2005-11-09 (0.9.4) 81 */ 82 public class Iterator 83 { 84 85 /** the main Gtk struct */ 86 protected GstIterator* gstIterator; 87 88 89 public GstIterator* getIteratorStruct() 90 { 91 return gstIterator; 92 } 93 94 95 /** the main Gtk struct as a void* */ 96 protected void* getStruct() 97 { 98 return cast(void*)gstIterator; 99 } 100 101 /** 102 * Sets our main struct and passes it to the parent class 103 */ 104 public this (GstIterator* gstIterator) 105 { 106 this.gstIterator = gstIterator; 107 } 108 109 /** 110 */ 111 112 /** 113 * Create a new iterator. This function is mainly used for objects 114 * implementing the next/resync/free function to iterate a data structure. 115 * For each item retrieved, the item function is called with the lock 116 * held. The free function is called when the iterator is freed. 117 * Params: 118 * size = the size of the iterator structure 119 * type = GType of children 120 * lock = pointer to a GMutex. 121 * masterCookie = pointer to a guint32 to protect the iterated object. 122 * next = function to get next item 123 * item = function to call on each item retrieved 124 * resync = function to resync the iterator 125 * free = function to free the iterator 126 * Throws: ConstructionException GTK+ fails to create the object. 127 */ 128 public this (uint size, GType type, Mutex lock, ref uint masterCookie, GstIteratorNextFunction next, GstIteratorItemFunction item, GstIteratorResyncFunction resync, GstIteratorFreeFunction free) 129 { 130 // GstIterator* gst_iterator_new (guint size, GType type, GMutex *lock, guint32 *master_cookie, GstIteratorNextFunction next, GstIteratorItemFunction item, GstIteratorResyncFunction resync, GstIteratorFreeFunction free); 131 auto p = gst_iterator_new(size, type, (lock is null) ? null : lock.getMutexStruct(), &masterCookie, next, item, resync, free); 132 if(p is null) 133 { 134 throw new ConstructionException("null returned by gst_iterator_new(size, type, (lock is null) ? null : lock.getMutexStruct(), &masterCookie, next, item, resync, free)"); 135 } 136 this(cast(GstIterator*) p); 137 } 138 139 /** 140 * Create a new iterator designed for iterating list. 141 * Params: 142 * type = GType of elements 143 * lock = pointer to a GMutex protecting the list. 144 * masterCookie = pointer to a guint32 to protect the list. 145 * list = pointer to the list 146 * owner = object owning the list 147 * item = function to call for each item 148 * free = function to call when the iterator is freed 149 * Throws: ConstructionException GTK+ fails to create the object. 150 */ 151 public this (GType type, Mutex lock, uint* masterCookie, GList** list, void* owner, GstIteratorItemFunction item, GstIteratorDisposeFunction free) 152 { 153 // GstIterator* gst_iterator_new_list (GType type, GMutex *lock, guint32 *master_cookie, GList **list, gpointer owner, GstIteratorItemFunction item, GstIteratorDisposeFunction free); 154 auto p = gst_iterator_new_list(type, (lock is null) ? null : lock.getMutexStruct(), masterCookie, list, owner, item, free); 155 if(p is null) 156 { 157 throw new ConstructionException("null returned by gst_iterator_new_list(type, (lock is null) ? null : lock.getMutexStruct(), masterCookie, list, owner, item, free)"); 158 } 159 this(cast(GstIterator*) p); 160 } 161 162 /** 163 * Get the next item from the iterator. For iterators that return 164 * refcounted objects, the returned object will have its refcount 165 * increased and should therefore be unreffed after usage. 166 * Params: 167 * elem = pointer to hold next element 168 * Returns: The result of the iteration. Unref after usage if this is a refcounted object. MT safe. 169 */ 170 public GstIteratorResult next(void** elem) 171 { 172 // GstIteratorResult gst_iterator_next (GstIterator *it, gpointer *elem); 173 return gst_iterator_next(gstIterator, elem); 174 } 175 176 /** 177 * Resync the iterator. this function is mostly called 178 * after gst_iterator_next() returned GST_ITERATOR_RESYNC. 179 * MT safe. 180 */ 181 public void resync() 182 { 183 // void gst_iterator_resync (GstIterator *it); 184 gst_iterator_resync(gstIterator); 185 } 186 187 /** 188 * Free the iterator. 189 * MT safe. 190 */ 191 public void free() 192 { 193 // void gst_iterator_free (GstIterator *it); 194 gst_iterator_free(gstIterator); 195 } 196 197 /** 198 * Pushes other iterator onto it. All calls performed on it are 199 * forwarded tot other. If other returns GST_ITERATOR_DONE, it is 200 * popped again and calls are handled by it again. 201 * This function is mainly used by objects implementing the iterator 202 * next function to recurse into substructures. 203 * MT safe. 204 * Params: 205 * other = The GstIterator to push 206 */ 207 public void push(Iterator other) 208 { 209 // void gst_iterator_push (GstIterator *it, GstIterator *other); 210 gst_iterator_push(gstIterator, (other is null) ? null : other.getIteratorStruct()); 211 } 212 213 /** 214 * Create a new iterator from an existing iterator. The new iterator 215 * will only return those elements that match the given compare function func. 216 * func should return 0 for elements that should be included 217 * in the iterator. 218 * When this iterator is freed, it will also be freed. 219 * Params: 220 * func = the compare function to select elements 221 * userData = user data passed to the compare function 222 * Returns: a new GstIterator. MT safe. 223 */ 224 public Iterator filter(GCompareFunc func, void* userData) 225 { 226 // GstIterator* gst_iterator_filter (GstIterator *it, GCompareFunc func, gpointer user_data); 227 auto p = gst_iterator_filter(gstIterator, func, userData); 228 229 if(p is null) 230 { 231 return null; 232 } 233 234 return ObjectG.getDObject!(Iterator)(cast(GstIterator*) p); 235 } 236 237 /** 238 * Folds func over the elements of iter. That is to say, proc will be called 239 * as proc (object, ret, user_data) for each object in iter. The normal use 240 * of this procedure is to accumulate the results of operating on the objects in 241 * ret. 242 * This procedure can be used (and is used internally) to implement the foreach 243 * and find_custom operations. 244 * The fold will proceed as long as func returns TRUE. When the iterator has no 245 * more arguments, GST_ITERATOR_DONE will be returned. If func returns FALSE, 246 * the fold will stop, and GST_ITERATOR_OK will be returned. Errors or resyncs 247 * will cause fold to return GST_ITERATOR_ERROR or GST_ITERATOR_RESYNC as 248 * appropriate. 249 * The iterator will not be freed. 250 * Params: 251 * func = the fold function 252 * ret = the seed value passed to the fold function 253 * userData = user data passed to the fold function 254 * Returns: A GstIteratorResult, as described above. MT safe. 255 */ 256 public GstIteratorResult fold(GstIteratorFoldFunction func, GValue* ret, void* userData) 257 { 258 // GstIteratorResult gst_iterator_fold (GstIterator *it, GstIteratorFoldFunction func, GValue *ret, gpointer user_data); 259 return gst_iterator_fold(gstIterator, func, ret, userData); 260 } 261 262 /** 263 * Iterate over all element of it and call the given function func for 264 * each element. 265 * Params: 266 * func = the function to call for each element. 267 * userData = user data passed to the function 268 * Returns: the result call to gst_iterator_fold(). The iterator will not be freed. MT safe. 269 */ 270 public GstIteratorResult foreac(GFunc func, void* userData) 271 { 272 // GstIteratorResult gst_iterator_foreach (GstIterator *it, GFunc func, gpointer user_data); 273 return gst_iterator_foreach(gstIterator, func, userData); 274 } 275 276 /** 277 * Find the first element in it that matches the compare function func. 278 * func should return 0 when the element is found. 279 * The iterator will not be freed. 280 * This function will return NULL if an error or resync happened to 281 * the iterator. 282 * Params: 283 * func = the compare function to use 284 * userData = user data passed to the compare function 285 * Returns: The element in the iterator that matches the compare function or NULL when no element matched. MT safe. 286 */ 287 public void* findCustom(GCompareFunc func, void* userData) 288 { 289 // gpointer gst_iterator_find_custom (GstIterator *it, GCompareFunc func, gpointer user_data); 290 return gst_iterator_find_custom(gstIterator, func, userData); 291 } 292 }