📄 gobject.h
字号:
/* GObject - GLib Type, Object, Parameter and Signal Library * Copyright (C) 1998-1999, 2000-2001 Tim Janik and Red Hat, Inc. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General * Public License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */#if !defined (__GLIB_GOBJECT_H_INSIDE__) && !defined (GOBJECT_COMPILATION)#error "Only <glib-object.h> can be included directly."#endif#ifndef __G_OBJECT_H__#define __G_OBJECT_H__#include <gobject/gtype.h>#include <gobject/gvalue.h>#include <gobject/gparam.h>#include <gobject/gclosure.h>#include <gobject/gsignal.h>G_BEGIN_DECLS/* --- type macros --- *//** * G_TYPE_IS_OBJECT: * @type: Type id to check * * Check if the passed in type id is a %G_TYPE_OBJECT or derived from it. * * Returns: %FALSE or %TRUE, indicating whether @type is a %G_TYPE_OBJECT. */#define G_TYPE_IS_OBJECT(type) (G_TYPE_FUNDAMENTAL (type) == G_TYPE_OBJECT)/** * G_OBJECT: * @object: Object which is subject to casting. * * Casts a #GObject or derived pointer into a (GObject*) pointer. * Depending on the current debugging level, this function may invoke * certain runtime checks to identify invalid casts. */#define G_OBJECT(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_OBJECT, GObject))/** * G_OBJECT_CLASS: * @class: a valid #GObjectClass * * Casts a derived #GObjectClass structure into a #GObjectClass structure. */#define G_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_OBJECT, GObjectClass))/** * G_IS_OBJECT: * @object: Instance to check for being a %G_TYPE_OBJECT. * * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_OBJECT. */#define G_IS_OBJECT(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_OBJECT))/** * G_IS_OBJECT_CLASS: * @class: a #GObjectClass * * Checks whether @class "is a" valid #GObjectClass structure of type * %G_TYPE_OBJECT or derived. */#define G_IS_OBJECT_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_OBJECT))/** * G_OBJECT_GET_CLASS: * @object: a #GObject instance. * * Get the class structure associated to a #GObject instance. * * Returns: pointer to object class structure. */#define G_OBJECT_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_OBJECT, GObjectClass))/** * G_OBJECT_TYPE: * @object: Object to return the type id for. * * Get the type id of an object. * * Returns: Type id of @object. */#define G_OBJECT_TYPE(object) (G_TYPE_FROM_INSTANCE (object))/** * G_OBJECT_TYPE_NAME: * @object: Object to return the type name for. * * Get the name of an object's type. * * Returns: Type name of @object. The string is owned by the type system and * should not be freed. */#define G_OBJECT_TYPE_NAME(object) (g_type_name (G_OBJECT_TYPE (object)))/** * G_OBJECT_CLASS_TYPE: * @class: a valid #GObjectClass * * Get the type id of a class structure. * * Returns: Type id of @class. */#define G_OBJECT_CLASS_TYPE(class) (G_TYPE_FROM_CLASS (class))/** * G_OBJECT_CLASS_NAME: * @class: a valid #GObjectClass * * Return the name of a class structure's type. * * Returns: Type name of @class. The string is owned by the type system and * should not be freed. */#define G_OBJECT_CLASS_NAME(class) (g_type_name (G_OBJECT_CLASS_TYPE (class)))/** * G_VALUE_HOLDS_OBJECT: * @value: a valid #GValue structure * * Checks whether the given #GValue can hold values derived from type %G_TYPE_OBJECT. * * Returns: %TRUE on success. */#define G_VALUE_HOLDS_OBJECT(value) (G_TYPE_CHECK_VALUE_TYPE ((value), G_TYPE_OBJECT))/* --- type macros --- *//** * G_TYPE_INITIALLY_UNOWNED: * * The type for #GInitiallyUnowned. */#define G_TYPE_INITIALLY_UNOWNED (g_initially_unowned_get_type())/** * G_INITIALLY_UNOWNED: * @object: Object which is subject to casting. * * Casts a #GInitiallyUnowned or derived pointer into a (GInitiallyUnowned*) * pointer. Depending on the current debugging level, this function may invoke * certain runtime checks to identify invalid casts. */#define G_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnowned))/** * G_INITIALLY_UNOWNED_CLASS: * @class: a valid #GInitiallyUnownedClass * * Casts a derived #GInitiallyUnownedClass structure into a * #GInitiallyUnownedClass structure. */#define G_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_CAST ((class), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))/** * G_IS_INITIALLY_UNOWNED: * @object: Instance to check for being a %G_TYPE_INITIALLY_UNOWNED. * * Checks whether a valid #GTypeInstance pointer is of type %G_TYPE_INITIALLY_UNOWNED. */#define G_IS_INITIALLY_UNOWNED(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), G_TYPE_INITIALLY_UNOWNED))/** * G_IS_INITIALLY_UNOWNED_CLASS: * @class: a #GInitiallyUnownedClass * * Checks whether @class "is a" valid #GInitiallyUnownedClass structure of type * %G_TYPE_INITIALLY_UNOWNED or derived. */#define G_IS_INITIALLY_UNOWNED_CLASS(class) (G_TYPE_CHECK_CLASS_TYPE ((class), G_TYPE_INITIALLY_UNOWNED))/** * G_INITIALLY_UNOWNED_GET_CLASS: * @object: a #GInitiallyUnowned instance. * * Get the class structure associated to a #GInitiallyUnowned instance. * * Returns: pointer to object class structure. */#define G_INITIALLY_UNOWNED_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS ((object), G_TYPE_INITIALLY_UNOWNED, GInitiallyUnownedClass))/* GInitiallyUnowned ia a GObject with initially floating reference count *//* --- typedefs & structures --- */typedef struct _GObject GObject;typedef struct _GObjectClass GObjectClass;typedef struct _GObject GInitiallyUnowned;typedef struct _GObjectClass GInitiallyUnownedClass;typedef struct _GObjectConstructParam GObjectConstructParam;/** * GObjectGetPropertyFunc: * @object: a #GObject * @property_id: the numeric id under which the property was registered with * g_object_class_install_property(). * @value: a #GValue to return the property value in * @pspec: the #GParamSpec describing the property * * The type of the @get_property function of #GObjectClass. */typedef void (*GObjectGetPropertyFunc) (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);/** * GObjectSetPropertyFunc: * @object: a #GObject * @property_id: the numeric id under which the property was registered with * g_object_class_install_property(). * @value: the new value for the property * @pspec: the #GParamSpec describing the property * * The type of the @set_property function of #GObjectClass. */typedef void (*GObjectSetPropertyFunc) (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec);/** * GObjectFinalizeFunc: * @object: the #GObject being finalized * * The type of the @finalize function of #GObjectClass. */typedef void (*GObjectFinalizeFunc) (GObject *object);/** * GWeakNotify: * @data: data that was provided when the weak reference was established * @where_the_object_was: the object being finalized * * A #GWeakNotify function can be added to an object as a callback that gets * triggered when the object is finalized. Since the object is already being * finalized when the #GWeakNotify is called, there's not much you could do * with the object, apart from e.g. using its adress as hash-index or the like. */typedef void (*GWeakNotify) (gpointer data, GObject *where_the_object_was);/** * GObject: * * All the fields in the <structname>GObject</structname> structure are private * to the #GObject implementation and should never be accessed directly. */struct _GObject{ GTypeInstance g_type_instance; /*< private >*/ volatile guint ref_count; GData *qdata;};/** * GObjectClass: * @g_type_class: the parent class * @constructor: the @constructor function is called by g_object_new () to * complete the object initialization after all the construction properties are * set. The first thing a @constructor implementation must do is chain up to the * @constructor of the parent class. Overriding @constructor should be rarely * needed, e.g. to handle construct properties, or to implement singletons. * @set_property: the generic setter for all properties of this type. Should be * overridden for every type with properties. Implementations of @set_property * don't need to emit property change notification explicitly, this is handled * by the type system. * @get_property: the generic getter for all properties of this type. Should be * overridden for every type with properties. * @dispose: the @dispose function is supposed to drop all references to other * objects, but keep the instance otherwise intact, so that client method * invocations still work. It may be run multiple times (due to reference * loops). Before returning, @dispose should chain up to the @dispose method * of the parent class. * @finalize: instance finalization function, should finish the finalization of * the instance begun in @dispose and chain up to the @finalize method of the * parent class. * @dispatch_properties_changed: emits property change notification for a bunch * of properties. Overriding @dispatch_properties_changed should be rarely * needed. * @notify: the class closure for the notify signal * @constructed: the @constructed function is called by g_object_new() as the * final step of the object creation process. At the point of the call, all * construction properties have been set on the object. The purpose of this * call is to allow for object initialisation steps that can only be performed * after construction properties have been set. @constructed implementors * should chain up to the @constructed call of their parent class to allow it
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -