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()
58 	{
59 		return gPrivate;
60 	}
61 
62 	/** the main Gtk struct as a void* */
63 	protected void* getStruct()
64 	{
65 		return cast(void*)gPrivate;
66 	}
67 
68 	/**
69 	 * Sets our main struct and passes it to the parent class.
70 	 */
71 	public this (GPrivate* gPrivate, bool ownedRef = false)
72 	{
73 		this.gPrivate = gPrivate;
74 		this.ownedRef = ownedRef;
75 	}
76 
77 
78 	/**
79 	 * Returns the current value of the thread local variable @key.
80 	 *
81 	 * If the value has not yet been set in this thread, %NULL is returned.
82 	 * Values are never copied between threads (when a new thread is
83 	 * created, for example).
84 	 *
85 	 * Return: the thread-local value
86 	 */
87 	public void* get()
88 	{
89 		return g_private_get(gPrivate);
90 	}
91 
92 	/**
93 	 * Sets the thread local variable @key to have the value @value in the
94 	 * current thread.
95 	 *
96 	 * This function differs from g_private_set() in the following way: if
97 	 * the previous value was non-%NULL then the #GDestroyNotify handler for
98 	 * @key is run on it.
99 	 *
100 	 * Params:
101 	 *     value = the new value
102 	 *
103 	 * Since: 2.32
104 	 */
105 	public void replace(void* value)
106 	{
107 		g_private_replace(gPrivate, value);
108 	}
109 
110 	/**
111 	 * Sets the thread local variable @key to have the value @value in the
112 	 * current thread.
113 	 *
114 	 * This function differs from g_private_replace() in the following way:
115 	 * the #GDestroyNotify for @key is not called on the old value.
116 	 *
117 	 * Params:
118 	 *     value = the new value
119 	 */
120 	public void set(void* value)
121 	{
122 		g_private_set(gPrivate, value);
123 	}
124 }