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