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 glib.Private;
26 
27 private import gtkc.glib;
28 public  import gtkc.glibtypes;
29 
30 
31 /**
32  * The #GPrivate struct is an opaque data structure to represent a
33  * thread-local data key. It is approximately equivalent to the
34  * pthread_setspecific()/pthread_getspecific() APIs on POSIX and to
35  * TlsSetValue()/TlsGetValue() on Windows.
36  * 
37  * If you don't already know why you might want this functionality,
38  * then you probably don't need it.
39  * 
40  * #GPrivate is a very limited resource (as far as 128 per program,
41  * shared between all libraries). It is also not possible to destroy a
42  * #GPrivate after it has been used. As such, it is only ever acceptable
43  * to use #GPrivate in static scope, and even then sparingly so.
44  * 
45  * See G_PRIVATE_INIT() for a couple of examples.
46  * 
47  * The #GPrivate structure should be considered opaque.  It should only
48  * be accessed via the g_private_ functions.
49  */
50 public class Private
51 {
52 	/** the main Gtk struct */
53 	protected GPrivate* gPrivate;
54 	protected bool ownedRef;
55 
56 	/** Get the main Gtk struct */
57 	public GPrivate* getPrivateStruct(bool transferOwnership = false)
58 	{
59 		if (transferOwnership)
60 			ownedRef = false;
61 		return gPrivate;
62 	}
63 
64 	/** the main Gtk struct as a void* */
65 	protected void* getStruct()
66 	{
67 		return cast(void*)gPrivate;
68 	}
69 
70 	/**
71 	 * Sets our main struct and passes it to the parent class.
72 	 */
73 	public this (GPrivate* gPrivate, bool ownedRef = false)
74 	{
75 		this.gPrivate = gPrivate;
76 		this.ownedRef = ownedRef;
77 	}
78 
79 
80 	/**
81 	 * Returns the current value of the thread local variable @key.
82 	 *
83 	 * If the value has not yet been set in this thread, %NULL is returned.
84 	 * Values are never copied between threads (when a new thread is
85 	 * created, for example).
86 	 *
87 	 * Returns: the thread-local value
88 	 */
89 	public void* get()
90 	{
91 		return g_private_get(gPrivate);
92 	}
93 
94 	/**
95 	 * Sets the thread local variable @key to have the value @value in the
96 	 * current thread.
97 	 *
98 	 * This function differs from g_private_set() in the following way: if
99 	 * the previous value was non-%NULL then the #GDestroyNotify handler for
100 	 * @key is run on it.
101 	 *
102 	 * Params:
103 	 *     value = the new value
104 	 *
105 	 * Since: 2.32
106 	 */
107 	public void replace(void* value)
108 	{
109 		g_private_replace(gPrivate, value);
110 	}
111 
112 	/**
113 	 * Sets the thread local variable @key to have the value @value in the
114 	 * current thread.
115 	 *
116 	 * This function differs from g_private_replace() in the following way:
117 	 * the #GDestroyNotify for @key is not called on the old value.
118 	 *
119 	 * Params:
120 	 *     value = the new value
121 	 */
122 	public void set(void* value)
123 	{
124 		g_private_set(gPrivate, value);
125 	}
126 }