/src/wrappers/glib/library/data_types/glib_caches.e

http://github.com/tybor/Liberty · Specman e · 141 lines · 7 code · 33 blank · 101 comment · 0 complexity · b97745d49b822a531aadf0853c78b81b MD5 · raw file

  1. indexing
  2. copyright: "(C) 2005 Paolo Redaelli "
  3. license: "LGPL v2 or later"
  4. date: "$Date:$"
  5. revision: "$REvision:$"
  6. class GLIB_CACHES
  7. -- Prev Up Home GLib Reference Manual Next
  8. -- Top | Description
  9. -- Caches
  10. -- Caches %G —%@ caches allow sharing of complex data structures to save resources.
  11. -- Synopsis
  12. -- #include <glib.h>
  13. -- GCache;
  14. -- GCache* g_cache_new (GCacheNewFunc value_new_func,
  15. -- GCacheDestroyFunc value_destroy_func,
  16. -- GCacheDupFunc key_dup_func,
  17. -- GCacheDestroyFunc key_destroy_func,
  18. -- GHashFunc hash_key_func,
  19. -- GHashFunc hash_value_func,
  20. -- GEqualFunc key_equal_func);
  21. -- gpointer g_cache_insert (GCache *cache,
  22. -- gpointer key);
  23. -- void g_cache_remove (GCache *cache,
  24. -- gconstpointer value);
  25. -- void g_cache_destroy (GCache *cache);
  26. -- void g_cache_key_foreach (GCache *cache,
  27. -- GHFunc func,
  28. -- gpointer user_data);
  29. -- void g_cache_value_foreach (GCache *cache,
  30. -- GHFunc func,
  31. -- gpointer user_data);
  32. -- void (*GCacheDestroyFunc) (gpointer value);
  33. -- gpointer (*GCacheDupFunc) (gpointer value);
  34. -- gpointer (*GCacheNewFunc) (gpointer key);
  35. -- Description
  36. -- A GCache allows sharing of complex data structures, in order to save system resources.
  37. -- GTK+ uses caches for GtkStyles and GdkGCs. These consume a lot of resources, so a GCache is used to see if a GtkStyle or GdkGC with the required properties already exists. If it does, then the existing object is used instead of creating a new one.
  38. -- GCache uses keys and values. A GCache key describes the properties of a particular resource. A GCache value is the actual resource.
  39. -- Details
  40. -- GCache
  41. -- typedef struct _GCache GCache;
  42. -- The GCache struct is an opaque data structure containing information about a GCache. It should only be accessed via the following functions.
  43. -- g_cache_new ()
  44. -- GCache* g_cache_new (GCacheNewFunc value_new_func,
  45. -- GCacheDestroyFunc value_destroy_func,
  46. -- GCacheDupFunc key_dup_func,
  47. -- GCacheDestroyFunc key_destroy_func,
  48. -- GHashFunc hash_key_func,
  49. -- GHashFunc hash_value_func,
  50. -- GEqualFunc key_equal_func);
  51. -- Creates a new GCache.
  52. -- value_new_func : a function to create a new object given a key. This is called by g_cache_insert() if an object with the given key does not already exist.
  53. -- value_destroy_func : a function to destroy an object. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0).
  54. -- key_dup_func : a function to copy a key. It is called by g_cache_insert() if the key does not already exist in the GCache.
  55. -- key_destroy_func : a function to destroy a key. It is called by g_cache_remove() when the object is no longer needed (i.e. its reference count drops to 0).
  56. -- hash_key_func : a function to create a hash value from a key.
  57. -- hash_value_func : a function to create a hash value from a value.
  58. -- key_equal_func : a function to compare two keys. It should return TRUE if the two keys are equivalent.
  59. -- Returns : a new GCache.
  60. -- g_cache_insert ()
  61. -- gpointer g_cache_insert (GCache *cache,
  62. -- gpointer key);
  63. -- Gets the value corresponding to the given key, creating it if necessary. It first checks if the value already exists in the GCache, by using the key_equal_func function passed to g_cache_new(). If it does already exist it is returned, and its reference count is increased by one. If the value does not currently exist, if is created by calling the value_new_func. The key is duplicated by calling key_dup_func and the duplicated key and value are inserted into the GCache.
  64. -- cache : a GCache.
  65. -- key : a key describing a GCache object.
  66. -- Returns : a pointer to a GCache value.
  67. -- g_cache_remove ()
  68. -- void g_cache_remove (GCache *cache,
  69. -- gconstpointer value);
  70. -- Decreases the reference count of the given value. If it drops to 0 then the value and its corresponding key are destroyed, using the value_destroy_func and key_destroy_func passed to g_cache_new().
  71. -- cache : a GCache.
  72. -- value : the value to remove.
  73. -- g_cache_destroy ()
  74. -- void g_cache_destroy (GCache *cache);
  75. -- Frees the memory allocated for the GCache.
  76. -- Note that it does not destroy the keys and values which were contained in the GCache.
  77. -- cache : a GCache.
  78. -- g_cache_key_foreach ()
  79. -- void g_cache_key_foreach (GCache *cache,
  80. -- GHFunc func,
  81. -- gpointer user_data);
  82. -- Calls the given function for each of the keys in the GCache.
  83. -- cache : a GCache.
  84. -- func : the function to call with each GCache key.
  85. -- user_data : user data to pass to the function.
  86. -- g_cache_value_foreach ()
  87. -- void g_cache_value_foreach (GCache *cache,
  88. -- GHFunc func,
  89. -- gpointer user_data);
  90. -- Calls the given function for each of the values in the GCache.
  91. -- cache : a GCache.
  92. -- func : the function to call with each GCache value.
  93. -- user_data : user data to pass to the function.
  94. -- GCacheDestroyFunc ()
  95. -- void (*GCacheDestroyFunc) (gpointer value);
  96. -- Specifies the type of the value_destroy_func and key_destroy_func functions passed to g_cache_new(). The functions are passed a pointer to the GCache key or GCache value and should free any memory and other resources associated with it.
  97. -- value : the GCache value to destroy.
  98. -- GCacheDupFunc ()
  99. -- gpointer (*GCacheDupFunc) (gpointer value);
  100. -- Specifies the type of the key_dup_func function passed to g_cache_new(). The function is passed a key (not a value as the prototype implies) and should return a duplicate of the key.
  101. -- value : the GCache key to destroy (not a GCache value as it seems).
  102. -- Returns : a copy of the GCache key.
  103. -- GCacheNewFunc ()
  104. -- gpointer (*GCacheNewFunc) (gpointer key);
  105. -- Specifies the type of the value_new_func function passed to g_cache_new(). It is passed a GCache key and should create the value corresponding to the key.
  106. -- key : a GCache key.
  107. -- Returns : a new GCache value corresponding to the key.
  108. end