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 module gobject.TypePluginT; 26 27 public import gtkc.gobject; 28 public import gtkc.gobjecttypes; 29 30 31 /** 32 * The GObject type system supports dynamic loading of types. 33 * The #GTypePlugin interface is used to handle the lifecycle 34 * of dynamically loaded types. It goes as follows: 35 * 36 * 1. The type is initially introduced (usually upon loading the module 37 * the first time, or by your main application that knows what modules 38 * introduces what types), like this: 39 * |[<!-- language="C" --> 40 * new_type_id = g_type_register_dynamic (parent_type_id, 41 * "TypeName", 42 * new_type_plugin, 43 * type_flags); 44 * ]| 45 * where @new_type_plugin is an implementation of the 46 * #GTypePlugin interface. 47 * 48 * 2. The type's implementation is referenced, e.g. through 49 * g_type_class_ref() or through g_type_create_instance() (this is 50 * being called by g_object_new()) or through one of the above done on 51 * a type derived from @new_type_id. 52 * 53 * 3. This causes the type system to load the type's implementation by 54 * calling g_type_plugin_use() and g_type_plugin_complete_type_info() 55 * on @new_type_plugin. 56 * 57 * 4. At some point the type's implementation isn't required anymore, 58 * e.g. after g_type_class_unref() or g_type_free_instance() (called 59 * when the reference count of an instance drops to zero). 60 * 61 * 5. This causes the type system to throw away the information retrieved 62 * from g_type_plugin_complete_type_info() and then it calls 63 * g_type_plugin_unuse() on @new_type_plugin. 64 * 65 * 6. Things may repeat from the second step. 66 * 67 * So basically, you need to implement a #GTypePlugin type that 68 * carries a use_count, once use_count goes from zero to one, you need 69 * to load the implementation to successfully handle the upcoming 70 * g_type_plugin_complete_type_info() call. Later, maybe after 71 * succeeding use/unuse calls, once use_count drops to zero, you can 72 * unload the implementation again. The type system makes sure to call 73 * g_type_plugin_use() and g_type_plugin_complete_type_info() again 74 * when the type is needed again. 75 * 76 * #GTypeModule is an implementation of #GTypePlugin that already 77 * implements most of this except for the actual module loading and 78 * unloading. It even handles multiple registered types per module. 79 */ 80 public template TypePluginT(TStruct) 81 { 82 /** Get the main Gtk struct */ 83 public GTypePlugin* getTypePluginStruct() 84 { 85 return cast(GTypePlugin*)getStruct(); 86 } 87 88 /** 89 */ 90 91 /** 92 * Calls the @complete_interface_info function from the 93 * #GTypePluginClass of @plugin. There should be no need to use this 94 * function outside of the GObject type system itself. 95 * 96 * Params: 97 * instanceType = the #GType of an instantiable type to which the interface 98 * is added 99 * interfaceType = the #GType of the interface whose info is completed 100 * info = the #GInterfaceInfo to fill in 101 */ 102 public void completeInterfaceInfo(GType instanceType, GType interfaceType, GInterfaceInfo* info) 103 { 104 g_type_plugin_complete_interface_info(getTypePluginStruct(), instanceType, interfaceType, info); 105 } 106 107 /** 108 * Calls the @complete_type_info function from the #GTypePluginClass of @plugin. 109 * There should be no need to use this function outside of the GObject 110 * type system itself. 111 * 112 * Params: 113 * gType = the #GType whose info is completed 114 * info = the #GTypeInfo struct to fill in 115 * valueTable = the #GTypeValueTable to fill in 116 */ 117 public void completeTypeInfo(GType gType, GTypeInfo* info, GTypeValueTable* valueTable) 118 { 119 g_type_plugin_complete_type_info(getTypePluginStruct(), gType, info, valueTable); 120 } 121 122 /** 123 * Calls the @unuse_plugin function from the #GTypePluginClass of 124 * @plugin. There should be no need to use this function outside of 125 * the GObject type system itself. 126 */ 127 public void unuse() 128 { 129 g_type_plugin_unuse(getTypePluginStruct()); 130 } 131 132 /** 133 * Calls the @use_plugin function from the #GTypePluginClass of 134 * @plugin. There should be no need to use this function outside of 135 * the GObject type system itself. 136 */ 137 public void use() 138 { 139 g_type_plugin_use(getTypePluginStruct()); 140 } 141 }