alternative to assert
[gtkD.git] / src / gobject / TypePlugin.d
blob11c071974327f634d6d617381c2897ac31128bf4
1 /*
2 * This file is part of duit.
4 * duit is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation; either version 2.1 of the License, or
7 * (at your option) any later version.
9 * duit 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
12 * GNU Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with duit; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 // generated automatically - do not change
20 // find conversion definition on APILookup.txt
21 // implement new conversion functionalities on the wrap.utils pakage
24 * Conversion parameters:
25 * inFile = GTypePlugin.html
26 * outPack = gobject
27 * outFile = TypePlugin
28 * strct = GTypePlugin
29 * realStrct=
30 * ctorStrct=
31 * clss = TypePlugin
32 * interf =
33 * class Code: No
34 * interface Code: No
35 * template for:
36 * extend =
37 * implements:
38 * prefixes:
39 * - g_type_plugin_
40 * omit structs:
41 * omit prefixes:
42 * omit code:
43 * imports:
44 * - glib.Str
45 * - gobject.Type
46 * structWrap:
47 * local aliases:
50 module gobject.TypePlugin;
52 private import gobject.gobjecttypes;
54 private import lib.gobject;
56 private import glib.Str;
57 private import gobject.Type;
59 /**
60 * Description
61 * The GObject type system supports dynamic loading of types. The GTypePlugin
62 * interface is used to handle the lifecycle of dynamically loaded types.
63 * It goes as follows:
64 * The type is initially introduced (usually upon loading the module
65 * the first time, or by your main application that knows what modules
66 * introduces what types), like this:
67 * new_type_id = g_type_register_dynamic (parent_type_id,
68 * "TypeName",
69 * new_type_plugin,
70 * type_flags);
71 * where new_type_plugin is an implementation of the
72 * GTypePlugin interface.
73 * The type's implementation is referenced, e.g. through
74 * g_type_class_ref() or through g_type_create_instance() (this is
75 * being called by g_object_new()) or through one of the above done on
76 * a type derived from new_type_id.
77 * This causes the type system to load the type's implementation by calling
78 * g_type_plugin_use() and g_type_plugin_complete_type_info() on
79 * new_type_plugin.
80 * At some point the type's implementation isn't required anymore, e.g. after
81 * g_type_class_unref() or g_type_free_instance() (called when the reference
82 * count of an instance drops to zero).
83 * This causes the type system to throw away the information retrieved from
84 * g_type_plugin_complete_type_info() and then it calls
85 * g_type_plugin_unuse() on new_type_plugin.
86 * Things may repeat from the second step.
87 * So basically, you need to implement a GTypePlugin type that carries a
88 * use_count, once use_count goes from zero to one, you need to load the
89 * implementation to successfully handle the upcoming
90 * g_type_plugin_complete_type_info() call. Later, maybe after succeeding
91 * use/unuse calls, once use_count drops to zero, you can unload the
92 * implementation again. The type system makes sure to call g_type_plugin_use()
93 * and g_type_plugin_complete_type_info() again when the type is needed again.
94 * GTypeModule is an implementation of GTypePlugin that already implements
95 * most of this except for the actual module loading and unloading. It even
96 * handles multiple registered types per module.
98 public class TypePlugin
101 /** the main Gtk struct */
102 protected GTypePlugin* gTypePlugin;
105 public GTypePlugin* getTypePluginStruct()
107 return gTypePlugin;
111 /** the main Gtk struct as a void* */
112 protected void* getStruct()
114 return cast(void*)gTypePlugin;
118 * Sets our main struct and passes it to the parent class
120 public this (GTypePlugin* gTypePlugin)
122 this.gTypePlugin = gTypePlugin;
135 * Calls the use_plugin function from the GTypePluginClass of plugin.
136 * There should be no need to use this function outside of the GObject
137 * type system itself.
138 * plugin:
139 * a GTypePlugin
141 public void use()
143 // void g_type_plugin_use (GTypePlugin *plugin);
144 g_type_plugin_use(gTypePlugin);
148 * Calls the unuse_plugin function from the GTypePluginClass of plugin.
149 * There should be no need to use this function outside of the GObject
150 * type system itself.
151 * plugin:
152 * a GTypePlugin
154 public void unuse()
156 // void g_type_plugin_unuse (GTypePlugin *plugin);
157 g_type_plugin_unuse(gTypePlugin);
161 * Calls the complete_type_info function from the GTypePluginClass of plugin.
162 * There should be no need to use this function outside of the GObject
163 * type system itself.
164 * plugin:
165 * a GTypePlugin
166 * g_type:
167 * the GType whose info is completed
168 * info:
169 * the GTypeInfo struct to fill in
170 * value_table:
171 * the GTypeValueTable to fill in
173 public void completeTypeInfo(GType gType, GTypeInfo* info, GTypeValueTable* valueTable)
175 // void g_type_plugin_complete_type_info (GTypePlugin *plugin, GType g_type, GTypeInfo *info, GTypeValueTable *value_table);
176 g_type_plugin_complete_type_info(gTypePlugin, gType, info, valueTable);
180 * Calls the complete_interface_info function from the GTypePluginClass
181 * of plugin. There should be no need to use this function outside of the
182 * GObject type system itself.
183 * plugin:
184 * the GTypePlugin
185 * instance_type:
186 * the GType of an instantiable type to which the interface
187 * is added
188 * interface_type:
189 * the GType of the interface whose info is completed
190 * info:
191 * the GInterfaceInfo to fill in
192 * See Also
193 * GTypeModule and g_type_register_dynamic().
195 public void completeInterfaceInfo(GType instanceType, GType interfaceType, GInterfaceInfo* info)
197 // void g_type_plugin_complete_interface_info (GTypePlugin *plugin, GType instance_type, GType interface_type, GInterfaceInfo *info);
198 g_type_plugin_complete_interface_info(gTypePlugin, instanceType, interfaceType, info);