### Class

# GObject TypeModule

#### Description [src]

    abstract class GObject.TypeModule : GObject.Object
      implements GObject.TypePlugin {
      guint use_count,
      gpointer type_infos,
      gpointer interface_infos,
      gchar* name
    }

`GTypeModule` provides a simple implementation of the `GTypePlugin` interface.

The model of `GTypeModule` is a dynamically loaded module which implements some number of types and interface implementations.

When the module is loaded, it registers its types and interfaces using `g_type_module_register_type()` and `g_type_module_add_interface()`. As long as any instances of these types and interface implementations are in use, the module is kept loaded. When the types and interfaces are gone, the module may be unloaded. If the types and interfaces become used again, the module will be reloaded. Note that the last reference cannot be released from within the module code, since that would lead to the caller’s code being unloaded before `g_object_unref()` returns to it.

Keeping track of whether the module should be loaded or not is done by using a use count - it starts at zero, and whenever it is greater than zero, the module is loaded. The use count is maintained internally by the type system, but also can be explicitly controlled by `g_type_module_use()` and `g_type_module_unuse()`. Typically, when loading a module for the first type, `g_type_module_use()` will be used to load it so that it can initialize its types. At some later point, when the module no longer needs to be loaded except for the type implementations it contains, `g_type_module_unuse()` is called.

`GTypeModule` does not actually provide any implementation of module loading and unloading. To create a particular module type you must derive from `GTypeModule` and implement the load and unload functions in `GTypeModuleClass`.

#### Hierarchy

#### Ancestors

- GObject

#### Implements

- GTypePlugin

#### Instance methods

###### g_type_module_add_interface

Registers an additional interface for a type, whose interface lives in the given type plugin. If the interface was already registered for the type in this plugin, nothing will be done.

###### g_type_module_register_enum

Looks up or registers an enumeration that is implemented with a particular type plugin. If a type with name `type_name` was previously registered, the `GType` identifier for the type is returned, otherwise the type is newly registered, and the resulting `GType` identifier returned.

since: 2.6

###### g_type_module_register_flags

Looks up or registers a flags type that is implemented with a particular type plugin. If a type with name `type_name` was previously registered, the `GType` identifier for the type is returned, otherwise the type is newly registered, and the resulting `GType` identifier returned.

since: 2.6

###### g_type_module_register_type

Looks up or registers a type that is implemented with a particular type plugin. If a type with name `type_name` was previously registered, the `GType` identifier for the type is returned, otherwise the type is newly registered, and the resulting `GType` identifier returned.

###### g_type_module_set_name

Sets the name for a `GTypeModule`.

###### g_type_module_unuse

Decreases the use count of a `GTypeModule` by one. If the result is zero, the module will be unloaded. (However, the `GTypeModule` will not be freed, and types associated with the `GTypeModule` are not unregistered. Once a `GTypeModule` is initialized, it must exist forever.).

###### g_type_module_use

Increases the use count of a `GTypeModule` by one. If the use count was zero before, the plugin will be loaded. If loading the plugin fails, the use count is reset to its prior value.

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

##### Methods inherited from GTypePlugin (4)

###### g_type_plugin_complete_interface_info

Calls the `complete_interface_info` function from the `GTypePluginClass` of `plugin`. There should be no need to use this function outside of the GObject type system itself.

###### g_type_plugin_complete_type_info

Calls the `complete_type_info` function from the `GTypePluginClass` of `plugin`. There should be no need to use this function outside of the GObject type system itself.

###### g_type_plugin_unuse

Calls the `unuse_plugin` function from the `GTypePluginClass` of `plugin`. There should be no need to use this function outside of the GObject type system itself.

###### g_type_plugin_use

Calls the `use_plugin` function from the `GTypePluginClass` of `plugin`. There should be no need to use this function outside of the GObject type system itself.

#### Signals

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

#### Class structure

    struct GObjectTypeModuleClass {
      GObjectClass parent_class;
      gboolean (* load) (
        GTypeModule* module
      );
      void (* unload) (
        GTypeModule* module
      );
      void (* reserved1) (
    void
      );
      void (* reserved2) (
    void
      );
      void (* reserved3) (
    void
      );
      void (* reserved4) (
    void
      );

    }

In order to implement dynamic loading of types based on `GTypeModule`, the `load` and `unload` functions in `GTypeModuleClass` must be implemented.

###### Class members

`parent_class: GObjectClass`

  The parent class.

`load: gboolean (* load) ( GTypeModule* module )`

  Loads the module and registers one or more types using g_type_module_register_type().

`unload: void (* unload) ( GTypeModule* module )`

  Unloads the module.

`reserved1: void (* reserved1) ( void )`

  No description available.

`reserved2: void (* reserved2) ( void )`

  No description available.

`reserved3: void (* reserved3) ( void )`

  No description available.

`reserved4: void (* reserved4) ( void )`

  No description available.

#### Virtual methods

###### GObject.TypeModuleClass.load

Loads the module and registers one or more types using g_type_module_register_type().

###### GObject.TypeModuleClass.unload

Unloads the module.