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