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 module gst.base.QueueArray; 26 27 private import glib.ConstructionException; 28 private import gobject.ObjectG; 29 private import gst.base.c.functions; 30 public import gst.base.c.types; 31 private import gtkd.Loader; 32 33 34 /** 35 * #GstQueueArray is an object that provides standard queue functionality 36 * based on an array instead of linked lists. This reduces the overhead 37 * caused by memory management by a large factor. 38 */ 39 public class QueueArray 40 { 41 /** the main Gtk struct */ 42 protected GstQueueArray* gstQueueArray; 43 protected bool ownedRef; 44 45 /** Get the main Gtk struct */ 46 public GstQueueArray* getQueueArrayStruct(bool transferOwnership = false) 47 { 48 if (transferOwnership) 49 ownedRef = false; 50 return gstQueueArray; 51 } 52 53 /** the main Gtk struct as a void* */ 54 protected void* getStruct() 55 { 56 return cast(void*)gstQueueArray; 57 } 58 59 /** 60 * Sets our main struct and passes it to the parent class. 61 */ 62 public this (GstQueueArray* gstQueueArray, bool ownedRef = false) 63 { 64 this.gstQueueArray = gstQueueArray; 65 this.ownedRef = ownedRef; 66 } 67 68 ~this () 69 { 70 if ( Linker.isLoaded(LIBRARY_GSTBASE) && ownedRef ) 71 gst_queue_array_free(gstQueueArray); 72 } 73 74 75 /** 76 * Drops the queue element at position @idx from queue @array. 77 * 78 * Params: 79 * idx = index to drop 80 * 81 * Returns: the dropped element 82 * 83 * Since: 1.2 84 */ 85 public void* dropElement(uint idx) 86 { 87 return gst_queue_array_drop_element(gstQueueArray, idx); 88 } 89 90 /** 91 * Drops the queue element at position @idx from queue @array and copies the 92 * data of the element or structure that was removed into @p_struct if 93 * @p_struct is set (not NULL). 94 * 95 * Params: 96 * idx = index to drop 97 * pStruct = address into which to store the data of the dropped structure, or NULL 98 * 99 * Returns: TRUE on success, or FALSE on error 100 * 101 * Since: 1.6 102 */ 103 public bool dropStruct(uint idx, void* pStruct) 104 { 105 return gst_queue_array_drop_struct(gstQueueArray, idx, pStruct) != 0; 106 } 107 108 /** 109 * Finds an element in the queue @array, either by comparing every element 110 * with @func or by looking up @data if no compare function @func is provided, 111 * and returning the index of the found element. 112 * 113 * Note that the index is not 0-based, but an internal index number with a 114 * random offset. The index can be used in connection with 115 * gst_queue_array_drop_element(). FIXME: return index 0-based and make 116 * gst_queue_array_drop_element() take a 0-based index. 117 * 118 * Params: 119 * func = comparison function, or %NULL to find @data by value 120 * data = data for comparison function 121 * 122 * Returns: Index of the found element or -1 if nothing was found. 123 * 124 * Since: 1.2 125 */ 126 public uint find(GCompareFunc func, void* data) 127 { 128 return gst_queue_array_find(gstQueueArray, func, data); 129 } 130 131 /** 132 * Frees queue @array and all memory associated to it. 133 * 134 * Since: 1.2 135 */ 136 public void free() 137 { 138 gst_queue_array_free(gstQueueArray); 139 ownedRef = false; 140 } 141 142 /** 143 * Returns the length of the queue @array 144 * 145 * Returns: the length of the queue @array. 146 * 147 * Since: 1.2 148 */ 149 public uint getLength() 150 { 151 return gst_queue_array_get_length(gstQueueArray); 152 } 153 154 /** 155 * Checks if the queue @array is empty. 156 * 157 * Returns: %TRUE if the queue @array is empty 158 * 159 * Since: 1.2 160 */ 161 public bool isEmpty() 162 { 163 return gst_queue_array_is_empty(gstQueueArray) != 0; 164 } 165 166 /** 167 * Returns the head of the queue @array and does not 168 * remove it from the queue. 169 * 170 * Returns: The head of the queue 171 * 172 * Since: 1.2 173 */ 174 public void* peekHead() 175 { 176 return gst_queue_array_peek_head(gstQueueArray); 177 } 178 179 /** 180 * Returns the head of the queue @array without removing it from the queue. 181 * 182 * Returns: pointer to element or struct, or NULL if @array was empty. The 183 * data pointed to by the returned pointer stays valid only as long as 184 * the queue array is not modified further! 185 * 186 * Since: 1.6 187 */ 188 public void* peekHeadStruct() 189 { 190 return gst_queue_array_peek_head_struct(gstQueueArray); 191 } 192 193 /** 194 * Returns and head of the queue @array and removes 195 * it from the queue. 196 * 197 * Returns: The head of the queue 198 * 199 * Since: 1.2 200 */ 201 public void* popHead() 202 { 203 return gst_queue_array_pop_head(gstQueueArray); 204 } 205 206 /** 207 * Returns the head of the queue @array and removes it from the queue. 208 * 209 * Returns: pointer to element or struct, or NULL if @array was empty. The 210 * data pointed to by the returned pointer stays valid only as long as 211 * the queue array is not modified further! 212 * 213 * Since: 1.6 214 */ 215 public void* popHeadStruct() 216 { 217 return gst_queue_array_pop_head_struct(gstQueueArray); 218 } 219 220 /** 221 * Pushes @data to the tail of the queue @array. 222 * 223 * Params: 224 * data = object to push 225 * 226 * Since: 1.2 227 */ 228 public void pushTail(void* data) 229 { 230 gst_queue_array_push_tail(gstQueueArray, data); 231 } 232 233 /** */ 234 public void pushTailStruct(void* pStruct) 235 { 236 gst_queue_array_push_tail_struct(gstQueueArray, pStruct); 237 } 238 239 /** 240 * Allocates a new #GstQueueArray object with an initial 241 * queue size of @initial_size. 242 * 243 * Params: 244 * initialSize = Initial size of the new queue 245 * 246 * Returns: a new #GstQueueArray object 247 * 248 * Since: 1.2 249 * 250 * Throws: ConstructionException GTK+ fails to create the object. 251 */ 252 public this(uint initialSize) 253 { 254 auto p = gst_queue_array_new(initialSize); 255 256 if(p is null) 257 { 258 throw new ConstructionException("null returned by new"); 259 } 260 261 this(cast(GstQueueArray*) p); 262 } 263 264 /** 265 * Allocates a new #GstQueueArray object for elements (e.g. structures) 266 * of size @struct_size, with an initial queue size of @initial_size. 267 * 268 * Params: 269 * structSize = Size of each element (e.g. structure) in the array 270 * initialSize = Initial size of the new queue 271 * 272 * Returns: a new #GstQueueArray object 273 * 274 * Since: 1.6 275 * 276 * Throws: ConstructionException GTK+ fails to create the object. 277 */ 278 public this(size_t structSize, uint initialSize) 279 { 280 auto p = gst_queue_array_new_for_struct(structSize, initialSize); 281 282 if(p is null) 283 { 284 throw new ConstructionException("null returned by new_for_struct"); 285 } 286 287 this(cast(GstQueueArray*) p); 288 } 289 }