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-GstMiniObject.html
27  * outPack = gstreamer
28  * outFile = MiniObject
29  * strct   = GstMiniObject
30  * realStrct=
31  * ctorStrct=
32  * clss    = MiniObject
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- gst_mini_object_
41  * omit structs:
42  * 	- GstMiniObject
43  * omit prefixes:
44  * omit code:
45  * omit signals:
46  * imports:
47  * structWrap:
48  * 	- GstMiniObject* -> MiniObject
49  * module aliases:
50  * local aliases:
51  * overrides:
52  */
53 
54 module gstreamer.MiniObject;
55 
56 public  import gstreamerc.gstreamertypes;
57 
58 private import gstreamerc.gstreamer;
59 private import glib.ConstructionException;
60 private import gobject.ObjectG;
61 
62 
63 
64 
65 /**
66  * GstMiniObject is a simple structure that can be used to implement refcounted
67  * types.
68  *
69  * Subclasses will include GstMiniObject as the first member in their structure
70  * and then call gst_mini_object_init() to initialize the GstMiniObject fields.
71  *
72  * gst_mini_object_ref() and gst_mini_object_unref() increment and decrement the
73  * refcount respectively. When the refcount of a mini-object reaches 0, the
74  * dispose function is called first and when this returns TRUE, the free
75  * function of the miniobject is called.
76  *
77  * A copy can be made with gst_mini_object_copy().
78  *
79  * gst_mini_object_is_writable() will return TRUE when the refcount of the
80  * object is exactly 1, meaning the current caller has the only reference to the
81  * object. gst_mini_object_make_writable() will return a writable version of the
82  * object, which might be a new copy when the refcount was not 1.
83  *
84  * Opaque data can be associated with a GstMiniObject with
85  * gst_mini_object_set_qdata() and gst_mini_object_get_qdata(). The data is
86  * meant to be specific to the particular object and is not automatically copied
87  * with gst_mini_object_copy() or similar methods.
88  *
89  * A weak reference can be added and remove with gst_mini_object_weak_ref()
90  * and gst_mini_object_weak_unref() respectively.
91  *
92  * Last reviewed on 2012-06-15 (0.11.93)
93  */
94 public class MiniObject
95 {
96 	
97 	/** the main Gtk struct */
98 	protected GstMiniObject* gstMiniObject;
99 	
100 	
101 	/** Get the main Gtk struct */
102 	public GstMiniObject* getMiniObjectStruct()
103 	{
104 		return gstMiniObject;
105 	}
106 	
107 	
108 	/** the main Gtk struct as a void* */
109 	protected void* getStruct()
110 	{
111 		return cast(void*)gstMiniObject;
112 	}
113 	
114 	/**
115 	 * Sets our main struct and passes it to the parent class
116 	 */
117 	public this (GstMiniObject* gstMiniObject)
118 	{
119 		this.gstMiniObject = gstMiniObject;
120 	}
121 	
122 	/**
123 	 */
124 	
125 	/**
126 	 * Initializes a mini-object with the desired type and copy/dispose/free
127 	 * functions.
128 	 * Params:
129 	 * flags = initial GstMiniObjectFlags
130 	 * type = the GType of the mini-object to create
131 	 * copyFunc = the copy function, or NULL. [allow-none]
132 	 * disposeFunc = the dispose function, or NULL. [allow-none]
133 	 * freeFunc = the free function or NULL. [allow-none]
134 	 */
135 	public void init(uint flags, GType type, GstMiniObjectCopyFunction copyFunc, GstMiniObjectDisposeFunction disposeFunc, GstMiniObjectFreeFunction freeFunc)
136 	{
137 		// void gst_mini_object_init (GstMiniObject *mini_object,  guint flags,  GType type,  GstMiniObjectCopyFunction copy_func,  GstMiniObjectDisposeFunction dispose_func,  GstMiniObjectFreeFunction free_func);
138 		gst_mini_object_init(gstMiniObject, flags, type, copyFunc, disposeFunc, freeFunc);
139 	}
140 	
141 	/**
142 	 * Increase the reference count of the mini-object.
143 	 * Note that the refcount affects the writeability
144 	 * of mini-object, see gst_mini_object_is_writable(). It is
145 	 * important to note that keeping additional references to
146 	 * GstMiniObject instances can potentially increase the number
147 	 * of memcpy operations in a pipeline, especially if the miniobject
148 	 * is a GstBuffer.
149 	 * Returns: the mini-object. [transfer full]
150 	 */
151 	public MiniObject doref()
152 	{
153 		// GstMiniObject * gst_mini_object_ref (GstMiniObject *mini_object);
154 		auto p = gst_mini_object_ref(gstMiniObject);
155 		
156 		if(p is null)
157 		{
158 			return null;
159 		}
160 		
161 		return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p);
162 	}
163 	
164 	/**
165 	 * Decreases the reference count of the mini-object, possibly freeing
166 	 * the mini-object.
167 	 */
168 	public void unref()
169 	{
170 		// void gst_mini_object_unref (GstMiniObject *mini_object);
171 		gst_mini_object_unref(gstMiniObject);
172 	}
173 	
174 	/**
175 	 * Adds a weak reference callback to a mini object. Weak references are
176 	 * used for notification when a mini object is finalized. They are called
177 	 * "weak references" because they allow you to safely hold a pointer
178 	 * to the mini object without calling gst_mini_object_ref()
179 	 * (gst_mini_object_ref() adds a strong reference, that is, forces the object
180 	 * to stay alive).
181 	 * Params:
182 	 * notify = callback to invoke before the mini object is freed
183 	 * data = extra data to pass to notify
184 	 */
185 	public void weakRef(GstMiniObjectNotify notify, void* data)
186 	{
187 		// void gst_mini_object_weak_ref (GstMiniObject *object,  GstMiniObjectNotify notify,  gpointer data);
188 		gst_mini_object_weak_ref(gstMiniObject, notify, data);
189 	}
190 	
191 	/**
192 	 * Removes a weak reference callback from a mini object.
193 	 * Params:
194 	 * notify = callback to search for
195 	 * data = data to search for
196 	 */
197 	public void weakUnref(GstMiniObjectNotify notify, void* data)
198 	{
199 		// void gst_mini_object_weak_unref (GstMiniObject *object,  GstMiniObjectNotify notify,  gpointer data);
200 		gst_mini_object_weak_unref(gstMiniObject, notify, data);
201 	}
202 	
203 	/**
204 	 * Lock the mini-object with the specified access mode in flags.
205 	 * Params:
206 	 * flags = GstLockFlags
207 	 * Returns: TRUE if object could be locked.
208 	 */
209 	public int lock(GstLockFlags flags)
210 	{
211 		// gboolean gst_mini_object_lock (GstMiniObject *object,  GstLockFlags flags);
212 		return gst_mini_object_lock(gstMiniObject, flags);
213 	}
214 	
215 	/**
216 	 * Unlock the mini-object with the specified access mode in flags.
217 	 * Params:
218 	 * flags = GstLockFlags
219 	 */
220 	public void unlock(GstLockFlags flags)
221 	{
222 		// void gst_mini_object_unlock (GstMiniObject *object,  GstLockFlags flags);
223 		gst_mini_object_unlock(gstMiniObject, flags);
224 	}
225 	
226 	/**
227 	 * If mini_object has the LOCKABLE flag set, check if the current EXCLUSIVE
228 	 * lock on object is the only one, this means that changes to the object will
229 	 * not be visible to any other object.
230 	 * If the LOCKABLE flag is not set, check if the refcount of mini_object is
231 	 * exactly 1, meaning that no other reference exists to the object and that the
232 	 * object is therefore writable.
233 	 * Modification of a mini-object should only be done after verifying that it
234 	 * is writable.
235 	 * Returns: TRUE if the object is writable.
236 	 */
237 	public int isWritable()
238 	{
239 		// gboolean gst_mini_object_is_writable (const GstMiniObject *mini_object);
240 		return gst_mini_object_is_writable(gstMiniObject);
241 	}
242 	
243 	/**
244 	 * Checks if a mini-object is writable. If not, a writable copy is made and
245 	 * returned. This gives away the reference to the original mini object,
246 	 * and returns a reference to the new object.
247 	 * MT safe
248 	 * Returns: a mini-object (possibly the same pointer) that is writable. [transfer full]
249 	 */
250 	public MiniObject makeWritable()
251 	{
252 		// GstMiniObject * gst_mini_object_make_writable (GstMiniObject *mini_object);
253 		auto p = gst_mini_object_make_writable(gstMiniObject);
254 		
255 		if(p is null)
256 		{
257 			return null;
258 		}
259 		
260 		return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p);
261 	}
262 	
263 	/**
264 	 * Creates a copy of the mini-object.
265 	 * MT safe
266 	 * Returns: the new mini-object. [transfer full]
267 	 */
268 	public MiniObject copy()
269 	{
270 		// GstMiniObject * gst_mini_object_copy (const GstMiniObject *mini_object);
271 		auto p = gst_mini_object_copy(gstMiniObject);
272 		
273 		if(p is null)
274 		{
275 			return null;
276 		}
277 		
278 		return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p);
279 	}
280 	
281 	/**
282 	 * This sets an opaque, named pointer on a miniobject.
283 	 * The name is specified through a GQuark (retrived e.g. via
284 	 * g_quark_from_static_string()), and the pointer
285 	 * can be gotten back from the object with gst_mini_object_get_qdata()
286 	 * until the object is disposed.
287 	 * Setting a previously set user data pointer, overrides (frees)
288 	 * the old pointer set, using NULL as pointer essentially
289 	 * removes the data stored.
290 	 * destroy may be specified which is called with data as argument
291 	 * when the object is disposed, or the data is being overwritten by
292 	 * a call to gst_mini_object_set_qdata() with the same quark.
293 	 * Params:
294 	 * quark = A GQuark, naming the user data pointer
295 	 * data = An opaque user data pointer
296 	 * destroy = Function to invoke with data as argument, when data
297 	 * needs to be freed
298 	 */
299 	public void setQdata(GQuark quark, void* data, GDestroyNotify destroy)
300 	{
301 		// void gst_mini_object_set_qdata (GstMiniObject *object,  GQuark quark,  gpointer data,  GDestroyNotify destroy);
302 		gst_mini_object_set_qdata(gstMiniObject, quark, data, destroy);
303 	}
304 	
305 	/**
306 	 * This function gets back user data pointers stored via
307 	 * gst_mini_object_set_qdata().
308 	 * Params:
309 	 * quark = A GQuark, naming the user data pointer
310 	 * Returns: The user data pointer set, or NULL. [transfer none]
311 	 */
312 	public void* getQdata(GQuark quark)
313 	{
314 		// gpointer gst_mini_object_get_qdata (GstMiniObject *object,  GQuark quark);
315 		return gst_mini_object_get_qdata(gstMiniObject, quark);
316 	}
317 	
318 	/**
319 	 * This function gets back user data pointers stored via gst_mini_object_set_qdata()
320 	 * and removes the data from object without invoking its destroy() function (if
321 	 * any was set).
322 	 * Params:
323 	 * quark = A GQuark, naming the user data pointer
324 	 * Returns: The user data pointer set, or NULL. [transfer full]
325 	 */
326 	public void* stealQdata(GQuark quark)
327 	{
328 		// gpointer gst_mini_object_steal_qdata (GstMiniObject *object,  GQuark quark);
329 		return gst_mini_object_steal_qdata(gstMiniObject, quark);
330 	}
331 	
332 	/**
333 	 * Atomically modifies a pointer to point to a new mini-object.
334 	 * The reference count of olddata is decreased and the reference count of
335 	 * newdata is increased.
336 	 * Either newdata and the value pointed to by olddata may be NULL.
337 	 * Params:
338 	 * olddata = pointer to a pointer to a mini-object to
339 	 * be replaced. [inout][transfer full]
340 	 * newdata = pointer to new mini-object
341 	 * Returns: TRUE if newdata was different from olddata
342 	 */
343 	public static int replace(ref MiniObject olddata, MiniObject newdata)
344 	{
345 		// gboolean gst_mini_object_replace (GstMiniObject **olddata,  GstMiniObject *newdata);
346 		GstMiniObject* outolddata = (olddata is null) ? null : olddata.getMiniObjectStruct();
347 		
348 		auto p = gst_mini_object_replace(&outolddata, (newdata is null) ? null : newdata.getMiniObjectStruct());
349 		
350 		olddata = ObjectG.getDObject!(MiniObject)(outolddata);
351 		return p;
352 	}
353 	
354 	/**
355 	 * Modifies a pointer to point to a new mini-object. The modification
356 	 * is done atomically. This version is similar to gst_mini_object_replace()
357 	 * except that it does not increase the refcount of newdata and thus
358 	 * takes ownership of newdata.
359 	 * Either newdata and the value pointed to by olddata may be NULL.
360 	 * Params:
361 	 * olddata = pointer to a pointer to a mini-object to
362 	 * be replaced. [inout][transfer full]
363 	 * newdata = pointer to new mini-object
364 	 * Returns: TRUE if newdata was different from olddata
365 	 */
366 	public static int take(GstMiniObject** olddata, MiniObject newdata)
367 	{
368 		// gboolean gst_mini_object_take (GstMiniObject **olddata,  GstMiniObject *newdata);
369 		return gst_mini_object_take(olddata, (newdata is null) ? null : newdata.getMiniObjectStruct());
370 	}
371 	
372 	/**
373 	 * Replace the current GstMiniObject pointer to by olddata with NULL and
374 	 * return the old value.
375 	 * Params:
376 	 * olddata = pointer to a pointer to a mini-object to
377 	 * be stolen. [inout][transfer full]
378 	 * Returns: the GstMiniObject at oldata
379 	 */
380 	public static MiniObject steal(GstMiniObject** olddata)
381 	{
382 		// GstMiniObject * gst_mini_object_steal (GstMiniObject **olddata);
383 		auto p = gst_mini_object_steal(olddata);
384 		
385 		if(p is null)
386 		{
387 			return null;
388 		}
389 		
390 		return ObjectG.getDObject!(MiniObject)(cast(GstMiniObject*) p);
391 	}
392 }