gtypeplugin.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. /* GObject - GLib Type, Object, Parameter and Signal Library
  2. * Copyright (C) 2000 Red Hat, Inc.
  3. *
  4. * This library is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2 of the License, or (at your option) any later version.
  8. *
  9. * This library is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General
  15. * Public License along with this library; if not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #ifndef __G_TYPE_PLUGIN_H__
  18. #define __G_TYPE_PLUGIN_H__
  19. #if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)
  20. #error "Only <glib-object.h> can be included directly."
  21. #endif
  22. #include <gobject/gtype.h>
  23. G_BEGIN_DECLS
  24. /* --- type macros --- */
  25. #define G_TYPE_TYPE_PLUGIN (g_type_plugin_get_type ())
  26. #define G_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_CAST ((inst), G_TYPE_TYPE_PLUGIN, GTypePlugin))
  27. #define G_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_CAST ((vtable), G_TYPE_TYPE_PLUGIN, GTypePluginClass))
  28. #define G_IS_TYPE_PLUGIN(inst) (G_TYPE_CHECK_INSTANCE_TYPE ((inst), G_TYPE_TYPE_PLUGIN))
  29. #define G_IS_TYPE_PLUGIN_CLASS(vtable) (G_TYPE_CHECK_CLASS_TYPE ((vtable), G_TYPE_TYPE_PLUGIN))
  30. #define G_TYPE_PLUGIN_GET_CLASS(inst) (G_TYPE_INSTANCE_GET_INTERFACE ((inst), G_TYPE_TYPE_PLUGIN, GTypePluginClass))
  31. /* --- typedefs & structures --- */
  32. typedef struct _GTypePluginClass GTypePluginClass;
  33. /**
  34. * GTypePluginUse:
  35. * @plugin: the #GTypePlugin whose use count should be increased
  36. *
  37. * The type of the @use_plugin function of #GTypePluginClass, which gets called
  38. * to increase the use count of @plugin.
  39. */
  40. typedef void (*GTypePluginUse) (GTypePlugin *plugin);
  41. /**
  42. * GTypePluginUnuse:
  43. * @plugin: the #GTypePlugin whose use count should be decreased
  44. *
  45. * The type of the @unuse_plugin function of #GTypePluginClass.
  46. */
  47. typedef void (*GTypePluginUnuse) (GTypePlugin *plugin);
  48. /**
  49. * GTypePluginCompleteTypeInfo:
  50. * @plugin: the #GTypePlugin
  51. * @g_type: the #GType whose info is completed
  52. * @info: the #GTypeInfo struct to fill in
  53. * @value_table: the #GTypeValueTable to fill in
  54. *
  55. * The type of the @complete_type_info function of #GTypePluginClass.
  56. */
  57. typedef void (*GTypePluginCompleteTypeInfo) (GTypePlugin *plugin,
  58. GType g_type,
  59. GTypeInfo *info,
  60. GTypeValueTable *value_table);
  61. /**
  62. * GTypePluginCompleteInterfaceInfo:
  63. * @plugin: the #GTypePlugin
  64. * @instance_type: the #GType of an instantiable type to which the interface
  65. * is added
  66. * @interface_type: the #GType of the interface whose info is completed
  67. * @info: the #GInterfaceInfo to fill in
  68. *
  69. * The type of the @complete_interface_info function of #GTypePluginClass.
  70. */
  71. typedef void (*GTypePluginCompleteInterfaceInfo) (GTypePlugin *plugin,
  72. GType instance_type,
  73. GType interface_type,
  74. GInterfaceInfo *info);
  75. /**
  76. * GTypePlugin:
  77. *
  78. * The GTypePlugin typedef is used as a placeholder
  79. * for objects that implement the GTypePlugin interface.
  80. */
  81. /**
  82. * GTypePluginClass:
  83. * @use_plugin: Increases the use count of the plugin.
  84. * @unuse_plugin: Decreases the use count of the plugin.
  85. * @complete_type_info: Fills in the #GTypeInfo and
  86. * #GTypeValueTable structs for the type. The structs are initialized
  87. * with `memset(s, 0, sizeof (s))` before calling this function.
  88. * @complete_interface_info: Fills in missing parts of the #GInterfaceInfo
  89. * for the interface. The structs is initialized with
  90. * `memset(s, 0, sizeof (s))` before calling this function.
  91. *
  92. * The #GTypePlugin interface is used by the type system in order to handle
  93. * the lifecycle of dynamically loaded types.
  94. */
  95. struct _GTypePluginClass
  96. {
  97. /*< private >*/
  98. GTypeInterface base_iface;
  99. /*< public >*/
  100. GTypePluginUse use_plugin;
  101. GTypePluginUnuse unuse_plugin;
  102. GTypePluginCompleteTypeInfo complete_type_info;
  103. GTypePluginCompleteInterfaceInfo complete_interface_info;
  104. };
  105. /* --- prototypes --- */
  106. GLIB_AVAILABLE_IN_ALL
  107. GType g_type_plugin_get_type (void) G_GNUC_CONST;
  108. GLIB_AVAILABLE_IN_ALL
  109. void g_type_plugin_use (GTypePlugin *plugin);
  110. GLIB_AVAILABLE_IN_ALL
  111. void g_type_plugin_unuse (GTypePlugin *plugin);
  112. GLIB_AVAILABLE_IN_ALL
  113. void g_type_plugin_complete_type_info (GTypePlugin *plugin,
  114. GType g_type,
  115. GTypeInfo *info,
  116. GTypeValueTable *value_table);
  117. GLIB_AVAILABLE_IN_ALL
  118. void g_type_plugin_complete_interface_info (GTypePlugin *plugin,
  119. GType instance_type,
  120. GType interface_type,
  121. GInterfaceInfo *info);
  122. G_END_DECLS
  123. #endif /* __G_TYPE_PLUGIN_H__ */