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  = glib-Caches.html
27  * outPack = glib
28  * outFile = Cache
29  * strct   = GCache
30  * realStrct=
31  * ctorStrct=
32  * clss    = Cache
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_cache_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * structWrap:
47  * module aliases:
48  * local aliases:
49  * overrides:
50  */
51 
52 module glib.Cache;
53 
54 public  import gtkc.glibtypes;
55 
56 private import gtkc.glib;
57 private import glib.ConstructionException;
58 
59 
60 
61 
62 /**
63  * A GCache allows sharing of complex data structures, in order to
64  * save system resources.
65  *
66  * GCache uses keys and values. A GCache key describes the properties
67  * of a particular resource. A GCache value is the actual resource.
68  *
69  * GCache has been marked as deprecated, since this API is rarely
70  * used and not very actively maintained.
71  */
72 public class Cache
73 {
74 	
75 	/** the main Gtk struct */
76 	protected GCache* gCache;
77 	
78 	
79 	/** Get the main Gtk struct */
80 	public GCache* getCacheStruct()
81 	{
82 		return gCache;
83 	}
84 	
85 	
86 	/** the main Gtk struct as a void* */
87 	protected void* getStruct()
88 	{
89 		return cast(void*)gCache;
90 	}
91 	
92 	/**
93 	 * Sets our main struct and passes it to the parent class
94 	 */
95 	public this (GCache* gCache)
96 	{
97 		this.gCache = gCache;
98 	}
99 	
100 	/**
101 	 */
102 	
103 	/**
104 	 * Warning
105 	 * g_cache_new has been deprecated since version 2.32 and should not be used in newly-written code. Use a GHashTable instead
106 	 * Creates a new GCache.
107 	 * Params:
108 	 * valueNewFunc = a function to create a new object given a key.
109 	 * This is called by g_cache_insert() if an object
110 	 * with the given key does not already exist
111 	 * valueDestroyFunc = a function to destroy an object. It is called
112 	 * by g_cache_remove() when the object is no
113 	 * longer needed (i.e. its reference count drops
114 	 * to 0)
115 	 * keyDupFunc = a function to copy a key. It is called by
116 	 * g_cache_insert() if the key does not already exist in
117 	 * the GCache
118 	 * keyDestroyFunc = a function to destroy a key. It is called by
119 	 * g_cache_remove() when the object is no longer
120 	 * needed (i.e. its reference count drops to 0)
121 	 * hashKeyFunc = a function to create a hash value from a key
122 	 * hashValueFunc = a function to create a hash value from a value
123 	 * keyEqualFunc = a function to compare two keys. It should return
124 	 * TRUE if the two keys are equivalent
125 	 * Throws: ConstructionException GTK+ fails to create the object.
126 	 */
127 	public this (GCacheNewFunc valueNewFunc, GCacheDestroyFunc valueDestroyFunc, GCacheDupFunc keyDupFunc, GCacheDestroyFunc keyDestroyFunc, GHashFunc hashKeyFunc, GHashFunc hashValueFunc, GEqualFunc keyEqualFunc)
128 	{
129 		// GCache * g_cache_new (GCacheNewFunc value_new_func,  GCacheDestroyFunc value_destroy_func,  GCacheDupFunc key_dup_func,  GCacheDestroyFunc key_destroy_func,  GHashFunc hash_key_func,  GHashFunc hash_value_func,  GEqualFunc key_equal_func);
130 		auto p = g_cache_new(valueNewFunc, valueDestroyFunc, keyDupFunc, keyDestroyFunc, hashKeyFunc, hashValueFunc, keyEqualFunc);
131 		if(p is null)
132 		{
133 			throw new ConstructionException("null returned by g_cache_new(valueNewFunc, valueDestroyFunc, keyDupFunc, keyDestroyFunc, hashKeyFunc, hashValueFunc, keyEqualFunc)");
134 		}
135 		this(cast(GCache*) p);
136 	}
137 	
138 	/**
139 	 * Warning
140 	 * g_cache_insert has been deprecated since version 2.32 and should not be used in newly-written code. Use a GHashTable instead
141 	 * Gets the value corresponding to the given key, creating it if
142 	 * necessary. It first checks if the value already exists in the
143 	 * GCache, by using the key_equal_func function passed to
144 	 * g_cache_new(). If it does already exist it is returned, and its
145 	 * reference count is increased by one. If the value does not currently
146 	 * exist, if is created by calling the value_new_func. The key is
147 	 * duplicated by calling key_dup_func and the duplicated key and value
148 	 * are inserted into the GCache.
149 	 * Params:
150 	 * key = a key describing a GCache object
151 	 * Returns: a pointer to a GCache value
152 	 */
153 	public void* insert(void* key)
154 	{
155 		// gpointer g_cache_insert (GCache *cache,  gpointer key);
156 		return g_cache_insert(gCache, key);
157 	}
158 	
159 	/**
160 	 * Warning
161 	 * g_cache_remove has been deprecated since version 2.32 and should not be used in newly-written code. Use a GHashTable instead
162 	 * Decreases the reference count of the given value. If it drops to 0
163 	 * then the value and its corresponding key are destroyed, using the
164 	 * value_destroy_func and key_destroy_func passed to g_cache_new().
165 	 * Params:
166 	 * value = the value to remove
167 	 */
168 	public void remove(void* value)
169 	{
170 		// void g_cache_remove (GCache *cache,  gconstpointer value);
171 		g_cache_remove(gCache, value);
172 	}
173 	
174 	/**
175 	 * Warning
176 	 * g_cache_destroy has been deprecated since version 2.32 and should not be used in newly-written code. Use a GHashTable instead
177 	 * Frees the memory allocated for the GCache.
178 	 * Note that it does not destroy the keys and values which were
179 	 * contained in the GCache.
180 	 */
181 	public void destroy()
182 	{
183 		// void g_cache_destroy (GCache *cache);
184 		g_cache_destroy(gCache);
185 	}
186 	
187 	/**
188 	 * Warning
189 	 * g_cache_key_foreach has been deprecated since version 2.32 and should not be used in newly-written code. Use a GHashTable instead
190 	 * Calls the given function for each of the keys in the GCache.
191 	 * NOTE func is passed three parameters, the value and key of a cache
192 	 * entry and the user_data. The order of value and key is different
193 	 * from the order in which g_hash_table_foreach() passes key-value
194 	 * pairs to its callback function !
195 	 * Params:
196 	 * func = the function to call with each GCache key
197 	 * userData = user data to pass to the function
198 	 */
199 	public void keyForeach(GHFunc func, void* userData)
200 	{
201 		// void g_cache_key_foreach (GCache *cache,  GHFunc func,  gpointer user_data);
202 		g_cache_key_foreach(gCache, func, userData);
203 	}
204 	
205 	/**
206 	 * Warning
207 	 * g_cache_value_foreach has been deprecated since version 2.10 and should not be used in newly-written code. The reason is that it passes pointers to internal
208 	 *  data structures to func; use g_cache_key_foreach() instead
209 	 * Calls the given function for each of the values in the GCache.
210 	 * Params:
211 	 * func = the function to call with each GCache value
212 	 * userData = user data to pass to the function
213 	 */
214 	public void valueForeach(GHFunc func, void* userData)
215 	{
216 		// void g_cache_value_foreach (GCache *cache,  GHFunc func,  gpointer user_data);
217 		g_cache_value_foreach(gCache, func, userData);
218 	}
219 }