alternative to assert
[gtkD.git] / gtkD / src / gobject / TypePlugin.d
blobeb6e490ecf9608851c43cf95e518e1b8a3b81b03
1 /*
2 * This file is part of gtkD.
4 * gtkD 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 * gtkD 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 gtkD; 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 * module aliases:
48 * local aliases:
51 module gobject.TypePlugin;
53 version(noAssert)
55 version(Tango)
57 import tango.io.Stdout; // use the tango loging?
61 private import gtkc.gobjecttypes;
63 private import gtkc.gobject;
66 private import glib.Str;
67 private import gobject.Type;
72 /**
73 * Description
74 * The GObject type system supports dynamic loading of types. The GTypePlugin
75 * interface is used to handle the lifecycle of dynamically loaded types.
76 * It goes as follows:
77 * The type is initially introduced (usually upon loading the module
78 * the first time, or by your main application that knows what modules
79 * introduces what types), like this:
80 * new_type_id = g_type_register_dynamic (parent_type_id,
81 * "TypeName",
82 * new_type_plugin,
83 * type_flags);
84 * where new_type_plugin is an implementation of the
85 * GTypePlugin interface.
86 * The type's implementation is referenced, e.g. through
87 * g_type_class_ref() or through g_type_create_instance() (this is
88 * being called by g_object_new()) or through one of the above done on
89 * a type derived from new_type_id.
90 * This causes the type system to load the type's implementation by calling
91 * g_type_plugin_use() and g_type_plugin_complete_type_info() on
92 * new_type_plugin.
93 * At some point the type's implementation isn't required anymore, e.g. after
94 * g_type_class_unref() or g_type_free_instance() (called when the reference
95 * count of an instance drops to zero).
96 * This causes the type system to throw away the information retrieved from
97 * g_type_plugin_complete_type_info() and then it calls
98 * g_type_plugin_unuse() on new_type_plugin.
99 * Things may repeat from the second step.
100 * So basically, you need to implement a GTypePlugin type that carries a
101 * use_count, once use_count goes from zero to one, you need to load the
102 * implementation to successfully handle the upcoming
103 * g_type_plugin_complete_type_info() call. Later, maybe after succeeding
104 * use/unuse calls, once use_count drops to zero, you can unload the
105 * implementation again. The type system makes sure to call g_type_plugin_use()
106 * and g_type_plugin_complete_type_info() again when the type is needed again.
107 * GTypeModule is an implementation of GTypePlugin that already implements
108 * most of this except for the actual module loading and unloading. It even
109 * handles multiple registered types per module.
111 public class TypePlugin
114 /** the main Gtk struct */
115 protected GTypePlugin* gTypePlugin;
118 public GTypePlugin* getTypePluginStruct()
120 return gTypePlugin;
124 /** the main Gtk struct as a void* */
125 protected void* getStruct()
127 return cast(void*)gTypePlugin;
131 * Sets our main struct and passes it to the parent class
133 public this (GTypePlugin* gTypePlugin)
135 version(noAssert)
137 if ( gTypePlugin is null )
139 int zero = 0;
140 version(Tango)
142 Stdout("struct gTypePlugin is null on constructor").newline;
144 else
146 printf("struct gTypePlugin is null on constructor");
148 zero = zero / zero;
151 else
153 assert(gTypePlugin !is null, "struct gTypePlugin is null on constructor");
155 this.gTypePlugin = gTypePlugin;
168 * Calls the use_plugin function from the GTypePluginClass of plugin.
169 * There should be no need to use this function outside of the GObject
170 * type system itself.
171 * plugin:
172 * a GTypePlugin
174 public void use()
176 // void g_type_plugin_use (GTypePlugin *plugin);
177 g_type_plugin_use(gTypePlugin);
181 * Calls the unuse_plugin function from the GTypePluginClass of plugin.
182 * There should be no need to use this function outside of the GObject
183 * type system itself.
184 * plugin:
185 * a GTypePlugin
187 public void unuse()
189 // void g_type_plugin_unuse (GTypePlugin *plugin);
190 g_type_plugin_unuse(gTypePlugin);
194 * Calls the complete_type_info function from the GTypePluginClass of plugin.
195 * There should be no need to use this function outside of the GObject
196 * type system itself.
197 * plugin:
198 * a GTypePlugin
199 * g_type:
200 * the GType whose info is completed
201 * info:
202 * the GTypeInfo struct to fill in
203 * value_table:
204 * the GTypeValueTable to fill in
206 public void completeTypeInfo(GType gType, GTypeInfo* info, GTypeValueTable* valueTable)
208 // void g_type_plugin_complete_type_info (GTypePlugin *plugin, GType g_type, GTypeInfo *info, GTypeValueTable *value_table);
209 g_type_plugin_complete_type_info(gTypePlugin, gType, info, valueTable);
213 * Calls the complete_interface_info function from the GTypePluginClass
214 * of plugin. There should be no need to use this function outside of the
215 * GObject type system itself.
216 * plugin:
217 * the GTypePlugin
218 * instance_type:
219 * the GType of an instantiable type to which the interface
220 * is added
221 * interface_type:
222 * the GType of the interface whose info is completed
223 * info:
224 * the GInterfaceInfo to fill in
225 * See Also
226 * GTypeModule and g_type_register_dynamic().
228 public void completeInterfaceInfo(GType instanceType, GType interfaceType, GInterfaceInfo* info)
230 // void g_type_plugin_complete_interface_info (GTypePlugin *plugin, GType instance_type, GType interface_type, GInterfaceInfo *info);
231 g_type_plugin_complete_interface_info(gTypePlugin, instanceType, interfaceType, info);