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