1 /* 2 * This file is part of gtkD. 3 * 4 * gtkD is free software; you can redistribute it and/or modify 5 * it under the terms of the GNU Lesser General Public License 6 * as published by the Free Software Foundation; either version 3 7 * of the License, or (at your option) any later version, with 8 * some exceptions, please read the COPYING file. 9 * 10 * gtkD is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU Lesser General Public License for more details. 14 * 15 * You should have received a copy of the GNU Lesser General Public License 16 * along with gtkD; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA 18 */ 19 20 // generated automatically - do not change 21 // find conversion definition on APILookup.txt 22 // implement new conversion functionalities on the wrap.utils pakage 23 24 /* 25 * Conversion parameters: 26 * inFile = GTypePlugin.html 27 * outPack = gobject 28 * outFile = TypePlugin 29 * strct = GTypePlugin 30 * realStrct= 31 * ctorStrct= 32 * clss = TypePlugin 33 * interf = 34 * class Code: No 35 * interface Code: No 36 * template for: 37 * extend = 38 * implements: 39 * prefixes: 40 * - g_type_plugin_ 41 * omit structs: 42 * omit prefixes: 43 * omit code: 44 * omit signals: 45 * imports: 46 * structWrap: 47 * module aliases: 48 * local aliases: 49 * overrides: 50 */ 51 52 module gobject.TypePlugin; 53 54 public import gtkc.gobjecttypes; 55 56 private import gtkc.gobject; 57 private import glib.ConstructionException; 58 private import gobject.ObjectG; 59 60 61 62 63 /** 64 * The GObject type system supports dynamic loading of types. The 65 * GTypePlugin interface is used to handle the lifecycle of 66 * dynamically loaded types. It goes as follows: 67 * 68 * The type is initially introduced (usually upon loading the module 69 * the first time, or by your main application that knows what modules 70 * introduces what types), like this: 71 * 72 * $(DDOC_COMMENT example) 73 * 74 * where new_type_plugin is an implementation of the 75 * GTypePlugin interface. 76 * 77 * The type's implementation is referenced, e.g. through 78 * g_type_class_ref() or through g_type_create_instance() (this is 79 * being called by g_object_new()) or through one of the above done on 80 * a type derived from new_type_id. 81 * 82 * This causes the type system to load the type's implementation by calling 83 * g_type_plugin_use() and g_type_plugin_complete_type_info() on 84 * new_type_plugin. 85 * 86 * At some point the type's implementation isn't required anymore, e.g. after 87 * g_type_class_unref() or g_type_free_instance() (called when the reference 88 * count of an instance drops to zero). 89 * 90 * This causes the type system to throw away the information retrieved from 91 * g_type_plugin_complete_type_info() and then it calls 92 * g_type_plugin_unuse() on new_type_plugin. 93 * 94 * Things may repeat from the second step. 95 * 96 * So basically, you need to implement a GTypePlugin type that 97 * carries a use_count, once use_count goes from zero to one, you need 98 * to load the implementation to successfully handle the upcoming 99 * g_type_plugin_complete_type_info() call. Later, maybe after 100 * succeeding use/unuse calls, once use_count drops to zero, you can 101 * unload the implementation again. The type system makes sure to call 102 * g_type_plugin_use() and g_type_plugin_complete_type_info() again 103 * when the type is needed again. 104 * 105 * GTypeModule is an implementation of GTypePlugin that already 106 * implements most of this except for the actual module loading and 107 * unloading. It even handles multiple registered types per module. 108 */ 109 public class TypePlugin 110 { 111 112 /** the main Gtk struct */ 113 protected GTypePlugin* gTypePlugin; 114 115 116 /** Get the main Gtk struct */ 117 public GTypePlugin* getTypePluginStruct() 118 { 119 return gTypePlugin; 120 } 121 122 123 /** the main Gtk struct as a void* */ 124 protected void* getStruct() 125 { 126 return cast(void*)gTypePlugin; 127 } 128 129 /** 130 * Sets our main struct and passes it to the parent class 131 */ 132 public this (GTypePlugin* gTypePlugin) 133 { 134 this.gTypePlugin = gTypePlugin; 135 } 136 137 /** 138 */ 139 140 /** 141 * Calls the use_plugin function from the GTypePluginClass of 142 * plugin. There should be no need to use this function outside of 143 * the GObject type system itself. 144 */ 145 public void use() 146 { 147 // void g_type_plugin_use (GTypePlugin *plugin); 148 g_type_plugin_use(gTypePlugin); 149 } 150 151 /** 152 * Calls the unuse_plugin function from the GTypePluginClass of 153 * plugin. There should be no need to use this function outside of 154 * the GObject type system itself. 155 */ 156 public void unuse() 157 { 158 // void g_type_plugin_unuse (GTypePlugin *plugin); 159 g_type_plugin_unuse(gTypePlugin); 160 } 161 162 /** 163 * Calls the complete_type_info function from the GTypePluginClass of plugin. 164 * There should be no need to use this function outside of the GObject 165 * type system itself. 166 * Params: 167 * gType = the GType whose info is completed 168 * info = the GTypeInfo struct to fill in 169 * valueTable = the GTypeValueTable to fill in 170 */ 171 public void completeTypeInfo(GType gType, GTypeInfo* info, GTypeValueTable* valueTable) 172 { 173 // void g_type_plugin_complete_type_info (GTypePlugin *plugin, GType g_type, GTypeInfo *info, GTypeValueTable *value_table); 174 g_type_plugin_complete_type_info(gTypePlugin, gType, info, valueTable); 175 } 176 177 /** 178 * Calls the complete_interface_info function from the 179 * GTypePluginClass of plugin. There should be no need to use this 180 * function outside of the GObject type system itself. 181 * Params: 182 * instanceType = the GType of an instantiable type to which the interface 183 * is added 184 * interfaceType = the GType of the interface whose info is completed 185 * info = the GInterfaceInfo to fill in 186 */ 187 public void completeInterfaceInfo(GType instanceType, GType interfaceType, GInterfaceInfo* info) 188 { 189 // void g_type_plugin_complete_interface_info (GTypePlugin *plugin, GType instance_type, GType interface_type, GInterfaceInfo *info); 190 g_type_plugin_complete_interface_info(gTypePlugin, instanceType, interfaceType, info); 191 } 192 }