## The Object Interface

The Object Interface

## Synopsis

                        CoglObject;
    void *              cogl_object_ref                     (void *object);
    void                cogl_object_unref                   (void *object);
    void *              cogl_object_get_user_data           (CoglObject *object,
                                                             CoglUserDataKey *key);
    void                cogl_object_set_user_data           (CoglObject *object,
                                                             CoglUserDataKey *key,
                                                             void *user_data,
                                                             CoglUserDataDestroyCallback destroy);

## Description

## Details

### CoglObject

    typedef struct _CoglObject CoglObject;

### cogl_object_ref ()

    void *              cogl_object_ref                     (void *object);

Increases the reference count of `handle` by 1

`object` : | a CoglObject
Returns : | the `object`, with its reference count increased

### cogl_object_unref ()

    void                cogl_object_unref                   (void *object);

Drecreases the reference count of `object` by 1; if the reference count reaches 0, the resources allocated by `object` will be freed

`object` : | a CoglObject

### cogl_object_get_user_data ()

    void *              cogl_object_get_user_data           (CoglObject *object,
                                                             CoglUserDataKey *key);

Finds the user data previously associated with `object` using the given `key`. If no user data has been associated with `object` for the given `key` this function returns NULL.

`object` : | The object with associated private data to query
`key` : | The address of a CoglUserDataKey which provides a unique value with which to index the private data.
Returns : | The user data previously associated with `object` using the given `key`; or `NULL` if no associated data is found. [transfer none]

Since 1.4

### cogl_object_set_user_data ()

    void                cogl_object_set_user_data           (CoglObject *object,
                                                             CoglUserDataKey *key,
                                                             void *user_data,
                                                             CoglUserDataDestroyCallback destroy);

Associates some private `user_data` with a given CoglObject. To later remove the association call `cogl_object_set_user_data()` with the same `key` but NULL for the `user_data`.

`object` : | The object to associate private data with
`key` : | The address of a CoglUserDataKey which provides a unique value with which to index the private data.
`user_data` : | The data to associate with the given object, or `NULL` to remove a previous association.
`destroy` : | A CoglUserDataDestroyCallback to call if the object is destroyed or if the association is removed by later setting `NULL` data for the same key.

Since 1.4