gi-gobject-2.0.31: GObject bindings

Copyright | Will Thompson and Iñaki García Etxebarria
License | LGPL-2.1
Maintainer | Iñaki García Etxebarria
Safe Haskell | None
Language | Haskell2010

GI.GObject.Structs.TypeClass

Contents

- Exported types
- Methods
  - addPrivate
  - adjustPrivateOffset
  - get
  - getPrivate
  - peek
  - peekParent
  - peekStatic
  - ref
  - unref

Description

An opaque structure used as the base of all classes.

Synopsis

- newtype TypeClass = TypeClass (ManagedPtr TypeClass)
- newZeroTypeClass :: MonadIO m => m TypeClass
- typeClassAddPrivate :: (HasCallStack, MonadIO m) => TypeClass -> CSize -> m ()
- typeClassAdjustPrivateOffset :: (HasCallStack, MonadIO m) => Ptr () -> Int32 -> m ()
- typeClassGet :: (HasCallStack, MonadIO m) => GType -> m TypeClass
- typeClassGetPrivate :: (HasCallStack, MonadIO m) => TypeClass -> GType -> m (Ptr ())
- typeClassPeek :: (HasCallStack, MonadIO m) => GType -> m (Maybe TypeClass)
- typeClassPeekParent :: (HasCallStack, MonadIO m) => TypeClass -> m TypeClass
- typeClassPeekStatic :: (HasCallStack, MonadIO m) => GType -> m (Maybe TypeClass)
- typeClassRef :: (HasCallStack, MonadIO m) => GType -> m TypeClass
- typeClassUnref :: (HasCallStack, MonadIO m) => TypeClass -> m ()

# Exported types

newtype TypeClass Source #

Memory-managed wrapper type.

Constructors

TypeClass (ManagedPtr TypeClass) |

#### Instances

Instances details

Eq TypeClass Source # |
Instance details Defined in GI.GObject.Structs.TypeClass Methods (==) :: TypeClass -> TypeClass -> Bool Source # (/=) :: TypeClass -> TypeClass -> Bool Source #
BoxedPtr TypeClass Source # |
Instance details Defined in GI.GObject.Structs.TypeClass Methods boxedPtrCopy :: TypeClass -> IO TypeClass Source # boxedPtrFree :: TypeClass -> IO () Source #
CallocPtr TypeClass Source # |
Instance details Defined in GI.GObject.Structs.TypeClass Methods boxedPtrCalloc :: IO (Ptr TypeClass) Source #
ManagedPtrNewtype TypeClass Source # |
Instance details Defined in GI.GObject.Structs.TypeClass Methods toManagedPtr :: TypeClass -> ManagedPtr TypeClass Source #
tag ~ 'AttrSet => Constructible TypeClass tag Source # |
Instance details Defined in GI.GObject.Structs.TypeClass Methods new :: MonadIO m => (ManagedPtr TypeClass -> TypeClass) -> [AttrOp TypeClass tag] -> m TypeClass Source #

newZeroTypeClass :: MonadIO m => m TypeClass Source #

Construct a `TypeClass` struct initialized to zero.

# Methods

### Click to display all available methods, including inherited ones

Expand

#### Methods

addPrivate, peekParent, unref.

#### Getters

getPrivate.

#### Setters

None.

## addPrivate

typeClassAddPrivate Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> TypeClass | `gClass`: class structure for an instantiatable type
-> CSize | `privateSize`: size of private structure
-> m () |

Deprecated: (Since version 2.58)Use the `G_ADD_PRIVATE()` macro with the `G_DEFINE_*`family of macros to add instance private data to a type

Registers a private structure for an instantiatable type.

When an object is allocated, the private structures for the type and all of its parent types are allocated sequentially in the same memory block as the public structures, and are zero-filled.

Note that the accumulated size of the private structures of a type and all its parent types cannot exceed 64 KiB.

This function should be called in the type's `class_init()` function. The private structure can be retrieved using the `G_TYPE_INSTANCE_GET_PRIVATE()` macro.

The following example shows attaching a private structure MyObjectPrivate to an object MyObject defined in the standard GObject fashion in the type's `class_init()` function.

Note the use of a structure member "priv" to avoid the overhead of repeatedly calling `MY_OBJECT_GET_PRIVATE()`.

### C code

    typedef struct _MyObject        MyObject;
    typedef struct _MyObjectPrivate MyObjectPrivate;

    struct _MyObject {
     GObject parent;

     MyObjectPrivate *priv;
    };

    struct _MyObjectPrivate {
      int some_field;
    };

    static void
    my_object_class_init (MyObjectClass *klass)
    {
      g_type_class_add_private (klass, sizeof (MyObjectPrivate));
    }

    static void
    my_object_init (MyObject *my_object)
    {
      my_object->priv = G_TYPE_INSTANCE_GET_PRIVATE (my_object,
                                                     MY_TYPE_OBJECT,
                                                     MyObjectPrivate);
      // my_object->priv->some_field will be automatically initialised to 0
    }

    static int
    my_object_get_some_field (MyObject *my_object)
    {
      MyObjectPrivate *priv;

      g_return_val_if_fail (MY_IS_OBJECT (my_object), 0);

      priv = my_object->priv;

      return priv->some_field;
    }

Since: 2.4

## adjustPrivateOffset

typeClassAdjustPrivateOffset :: (HasCallStack, MonadIO m) => Ptr () -> Int32 -> m () Source #

No description available in the introspection data.

## get

typeClassGet Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GType | `type`: type ID of a classed type
-> m TypeClass | Returns: the class structure for the type

Retrieves the type class of the given `type`.

This function will create the class on demand if it does not exist already.

If you don't want to create the class, use `typeClassPeek` instead.

Since: 2.84

## getPrivate

typeClassGetPrivate :: (HasCallStack, MonadIO m) => TypeClass -> GType -> m (Ptr ()) Source #

No description available in the introspection data.

## peek

typeClassPeek Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GType | `type`: type ID of a classed type
-> m (Maybe TypeClass) | Returns: the `TypeClass` structure for the given type ID or `Nothing` if the class does not currently exist

Retrieves the class for a give type.

This function is essentially the same as `typeClassGet`, except that the class may have not been instantiated yet.

As a consequence, this function may return `Nothing` if the class of the type passed in does not currently exist (hasn't been referenced before).

## peekParent

typeClassPeekParent Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> TypeClass | `gClass`: the `TypeClass` structure to retrieve the parent class for
-> m TypeClass | Returns: the parent class of `gClass`

Retrieves the class structure of the immediate parent type of the class passed in.

This is a convenience function often needed in class initializers.

Since derived classes hold a reference on their parent classes as long as they are instantiated, the returned class will always exist.

This function is essentially equivalent to: g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)))

## peekStatic

typeClassPeekStatic Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GType | `type`: type ID of a classed type
-> m (Maybe TypeClass) | Returns: the `TypeClass` structure for the given type ID or `Nothing` if the class does not currently exist or is dynamically loaded

A more efficient version of `typeClassPeek` which works only for static types.

Since: 2.4

## ref

typeClassRef Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> GType | `type`: type ID of a classed type
-> m TypeClass | Returns: the `TypeClass` structure for the given type ID

Deprecated: (Since version 2.84)Use `typeClassGet` instead

Increments the reference count of the class structure belonging to `type`.

This function will demand-create the class if it doesn't exist already.

## unref

typeClassUnref Source #

Arguments

:: (HasCallStack, MonadIO m) |
=> TypeClass | `gClass`: a `TypeClass` structure to unref
-> m () |

Deprecated: (Since version 2.84)Type class reference counting has been removed and typeclasses now cannot be finalized. This function no longer does anything.

Decrements the reference count of the class structure being passed in.

Once the last reference count of a class has been released, classes may be finalized by the type system, so further dereferencing of a class pointer after `typeClassUnref` are invalid.