Rename (private) GSource.id and id parameter to
[platform/upstream/glib.git] / docs / reference / gobject / tmpl / gtype.sgml
1 <!-- ##### SECTION Title ##### -->
2 GType
3
4 <!-- ##### SECTION Short_Description ##### -->
5 The GLib Runtime type identification and management system
6
7 <!-- ##### SECTION Long_Description ##### -->
8 <para>
9 The GType API is the foundation of the GObject system.  It provides the
10 facilities for registering and managing all fundamental data types,
11 user-defined object and interface types.  Before using any GType
12 or GObject functions, g_type_init() must be called to initialize the
13 type system.
14 </para>
15 <para>
16 For type creation and registration purposes, all types fall into one of
17 two categories: static or dynamic.  Static types are never loaded or
18 unloaded at run-time as dynamic types may be.  Static types are created
19 with g_type_register_static() that gets type specific information passed
20 in via a #GTypeInfo structure.
21 Dynamic types are created with g_type_register_dynamic() which takes a
22 #GTypePlugin structure instead. The remaining type information (the
23 #GTypeInfo structure) is retrived during runtime through #GTypePlugin
24 and the g_type_plugin_*() API.
25 These registration functions are usually called only once from a 
26 function whose only purpose is to return the type identifier for a 
27 specific class.  Once the type (or class or interface) is registered,
28 it may be instantiated, inherited, or implemented depending on exactly
29 what sort of type it is.
30 There is also a third registration function for registering fundamental
31 types called g_type_register_fundamental() which requires both a #GTypeInfo
32 structure and a GTypeFundamentalInfo structure but it is seldom used
33 since most fundamental types are predefined rather than user-defined.
34 </para>
35
36 <!-- ##### SECTION See_Also ##### -->
37 <para>
38
39 </para>
40
41 <!-- ##### TYPEDEF GType ##### -->
42 <para>
43 A numerical value which represents the unique identifier of a registered
44 type.
45 </para>
46
47
48 <!-- ##### MACRO G_TYPE_FUNDAMENTAL ##### -->
49 <para>
50 Returns #TRUE if @type is a fundamental data type such as #G_TYPE_INT or
51 #G_TYPE_POINTER. Fundamental types are types that serve as fundaments for
52 the derived types, thus they are the roots of distinct inheritance hierarchies.
53 </para>
54
55 @type: A #GType value.
56
57
58 <!-- ##### MACRO G_TYPE_FUNDAMENTAL_MAX ##### -->
59 <para>
60 An integer constant that represents the number of identifiers reserved
61 for types that are assigned at compile-time.
62 </para>
63
64
65
66 <!-- ##### MACRO G_TYPE_FUNDAMENTAL_SHIFT ##### -->
67 <para>
68
69 </para>
70
71
72
73 <!-- ##### MACRO G_TYPE_IS_ABSTRACT ##### -->
74 <para>
75 Returns #TRUE if @type is an abstract type.  An abstract type can not be
76 instantiated and is normally used as an abstract base class for
77 derived classes.
78 </para>
79
80 @type: A #GType value.
81
82
83 <!-- ##### MACRO G_TYPE_IS_DERIVED ##### -->
84 <para>
85 Returns #TRUE if @type is derived (or in object-oriented terminology:
86 inherited) from another type (this holds true for all non-fundamental
87 types).
88 </para>
89
90 @type: A #GType value.
91
92
93 <!-- ##### MACRO G_TYPE_IS_FUNDAMENTAL ##### -->
94 <para>
95 Returns #TRUE if @type is a fundamental type.
96 </para>
97
98 @type: A #GType value.
99
100
101 <!-- ##### MACRO G_TYPE_IS_VALUE_TYPE ##### -->
102 <para>
103
104 </para>
105
106 @type: A #GType value.
107
108
109 <!-- ##### MACRO G_TYPE_HAS_VALUE_TABLE ##### -->
110 <para>
111
112 </para>
113
114 @type: 
115
116
117 <!-- ##### MACRO G_TYPE_IS_CLASSED ##### -->
118 <para>
119 Returns #TRUE if @type is a classed type.
120 </para>
121
122 @type: A #GType value.
123
124
125 <!-- ##### MACRO G_TYPE_IS_INSTANTIATABLE ##### -->
126 <para>
127 Returns #TRUE if @type can be instantiated.  Instantiation is the
128 process of creating an instance (object) of this type.
129 </para>
130
131 @type: A #GType value.
132
133
134 <!-- ##### MACRO G_TYPE_IS_DERIVABLE ##### -->
135 <para>
136 Returns #TRUE if @type is a derivable type.  A derivable type can
137 be used as the base class of a flat (single-level) class hierarchy.
138 </para>
139
140 @type: A #GType value.
141
142
143 <!-- ##### MACRO G_TYPE_IS_DEEP_DERIVABLE ##### -->
144 <para>
145 Returns #TRUE if @type is a deep derivable type.  A deep derivable type
146 can be used as the base class of a deep (multi-level) class hierarchy.
147 </para>
148
149 @type: A #GType value.
150
151
152 <!-- ##### MACRO G_TYPE_IS_INTERFACE ##### -->
153 <para>
154 Returns #TRUE if @type is an interface type.
155 Interface types are types that provide pure APIs, the implementation
156 of which is provided by another type (which is then said to conform
157 to the interface).  GLib interfaces are somewhat analogous to Java
158 interfaces and C++ classes containing only pure virtual functions.
159 </para>
160
161 @type: A #GType value.
162
163
164 <!-- ##### STRUCT GTypeInterface ##### -->
165 <para>
166 An opaque structure used as the base of all interface types.
167 </para>
168
169
170 <!-- ##### STRUCT GTypeInstance ##### -->
171 <para>
172 An opaque structure used as the base of all type instances.
173 </para>
174
175
176 <!-- ##### STRUCT GTypeInfo ##### -->
177 <para>
178 This structure is used to provide the type system with the information
179 required to initialize and destruct (finalize) a type's class and
180 instances thereof.
181 The initialized structure is passed to the g_type_register_static() function
182 (or is copied into the provided #GTypeInfo structure in the
183 g_type_plugin_complete_type_info()). The type system will perform a deep
184 copy of this structure, so it's memory does not need to be persistent
185 across invocation of g_type_register_static().
186 </para>
187
188 @class_size:     Size of the class structure (required for interface, classed and instantiatable types).
189 @base_init:      Location of the base initialization function (optional).
190 @base_finalize:  Location of the base finalization function (optional).
191 @class_init:     Location of the class initialization function (optional, for classed and instantiatable types only).
192 @class_finalize: Location of the class finalization function (optional).
193 @class_data:     User-supplied data passed to the class init/finalize functions.
194 @instance_size:  Size of the instance (object) structure (required for instantiatable types only).
195 @n_preallocs:    Number of pre-allocated (cached) instances to reserve memory for (0 indicates no caching).
196 @instance_init:  Location of the instance initialization function (optional, for instantiatable types only).
197 @value_table:    A #GTypeValueTable function table for generic handling of GValues of this type (usualy only
198                  useful for fundamental types).
199
200 <!-- ##### STRUCT GTypeFundamentalInfo ##### -->
201 <para>
202 A structure that provides information to the type system which is
203 used specifically for managing fundamental types.  
204 </para>
205
206 @type_flags: 
207
208 <!-- ##### STRUCT GInterfaceInfo ##### -->
209 <para>
210 A structure that provides information to the type system which is
211 used specifically for managing interface types.
212 </para>
213
214 @interface_init:        Location of the function that initializes the interface.
215 @interface_finalize:    Location of the function that finalizes the interface.
216 @interface_data:        Location of user data passed to the @interface_init and
217                         @interface_finalize functions (optional).
218
219 <!-- ##### STRUCT GTypeValueTable ##### -->
220 <para>
221 The #GTypeValueTable provides the functions required by the #GValue implementation,
222 to serve as a container for values of a type.
223 </para>
224
225 @value_init:            Default initialize @values contents by poking values
226                         directly into the value-&gt;data array. The data array of
227                         the #GValue passed into this function was zero-filled
228                         with memset, so no care has to be taken to free any
229                         old contents. E.g. for the implementation of a string
230                         value that may never be NULL, the implementation might
231                         look like:
232 <msgtext><programlisting>
233 {
234   value-&gt;data[0].v_pointer = g_strdup ("");
235 }
236 </programlisting></msgtext>
237 @value_free:            Free any old contents that might be left in the
238                         data array of the passed in @value. No resources may
239                         remain allocated through the #GValue contents after
240                         this function returns. E.g. for our above string type:
241 <msgtext><programlisting>
242 {
243   /* only free strings without a specific flag for static storage */
244   if (!(value-&gt;data[1].v_uint & G_VALUE_NOCOPY_CONTENTS))
245     g_free (value-&gt;data[0].v_pointer);
246 }
247 </programlisting></msgtext>
248 @value_copy:            @dest_value is a #GValue with zero-filled data section
249                         and @src_value is a properly setup #GValue of same or
250                         derived type.
251                         The purpose of this function is to copy the contents of
252                         @src_value into @dest_value in a way, that even after
253                         @src_value has been freed, the contents of @dest_value
254                         remain valid. String type example:
255 <msgtext><programlisting>
256 {
257   dest_value-&gt;data[0].v_pointer = g_strdup (src_value-&gt;data[0].v_pointer);
258 }
259 </programlisting></msgtext>
260 @value_peek_pointer:    If the value contents fit into a pointer, such as objects
261                         or strings, return this pointer, so the caller can peek at
262                         the current contents. To extend on our above string example:
263 <msgtext><programlisting>
264 {
265   return value-&gt;data[0].v_pointer;
266 }
267 </programlisting></msgtext>
268 @collect_format:        A string format describing how to collect the contents of
269                         this value, bit-by-bit. Each character in the format represents
270                         an argument to be collected, the characters themselves indicate
271                         the type of the argument. Currently supported arguments are:
272 <msgtext><variablelist>
273   <varlistentry><term></term><listitem><para>
274         'i' - Integers. passed as collect_values[].v_int.
275   </para></listitem></varlistentry>
276   <varlistentry><term></term><listitem><para>
277         'l' - Longs. passed as collect_values[].v_long.
278   </para></listitem></varlistentry>
279   <varlistentry><term></term><listitem><para>
280         'd' - Doubles. passed as collect_values[].v_double.
281   </para></listitem></varlistentry>
282   <varlistentry><term></term><listitem><para>
283         'p' - Pointers. passed as collect_values[].v_pointer.
284   </para></listitem></varlistentry>
285 </variablelist></msgtext>
286                         It should be noted, that for variable argument list construction,
287                         ANSI C promotes every type smaller than an integer to an int, and
288                         floats to doubles. So for collection of short int or char, 'i'
289                         needs to be used, and for collection of floats 'd'.
290 @collect_value:         The collect_value() function is responsible for converting the
291                         values collected from a variable argument list into contents
292                         suitable for storage in a GValue. This function should setup
293                         @value similar to value_init(), e.g. for a string value that
294                         does not allow NULL pointers, it needs to either spew an error,
295                         or do an implicit conversion by storing an empty string.
296                         The @value passed in to this function has a zero-filled data
297                         array, so just like for @value_init it is guaranteed to not
298                         contain any old contents that might need freeing.
299                         @n_collect_values is exactly the string length of @collect_format,
300                         and @collect_values is an array of unions #GTypeCValue with
301                         length @n_collect_values, containing the collected values
302                         according to @collect_format.
303                         @collect_flags is an argument provided as a hint by the caller,
304                         which may contain the flag #G_VALUE_NOCOPY_CONTENTS indicating,
305                         that the collected value contents may be considered "static"
306                         for the duration of the #@value lifetime.
307                         Thus an extra copy of the contents stored in @collect_values is
308                         not required for assignment to @value.
309                         For our above string example, we continue with:
310 <msgtext><programlisting>
311 {
312   if (!collect_values[0].v_pointer)
313     value->data[0].v_pointer = g_strdup ("");
314   else if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
315     {
316       value-&gt;data[0].v_pointer = collect_values[0].v_pointer;
317       /* keep a flag for the value_free() implementation to not free this string */
318       value-&gt;data[1].v_uint = G_VALUE_NOCOPY_CONTENTS;
319     }
320   else
321     value-&gt;data[0].v_pointer = g_strdup (collect_values[0].v_pointer);
322
323   return NULL;
324 }
325 </programlisting></msgtext>
326                         It should be noted, that it is generally a bad idea to follow the
327                         #G_VALUE_NOCOPY_CONTENTS hint for reference counted types. Due to
328                         reentrancy requirements and reference count assertions performed
329                         by the GSignal code, reference counts should always be incremented
330                         for reference counted contents stored in the value-&gt;data array.
331                         To deviate from our string example for a moment, and taking a look
332                         at an exemplary implementation for collect_value() of #GObject:
333 <msgtext><programlisting>
334 {
335   if (collect_values[0].v_pointer)
336     {
337       GObject *object = G_OBJECT (collect_values[0].v_pointer);
338
339       /* never honour G_VALUE_NOCOPY_CONTENTS for ref-counted types */
340       value-&gt;data[0].v_pointer = g_object_ref (object);
341       return NULL;
342     }
343   else
344     return g_strdup_printf ("Object passed as invalid NULL pointer");
345 }
346 </programlisting></msgtext>
347                         The reference count for valid objects is always incremented,
348                         regardless of @collect_flags. For invalid objects, the example
349                         returns a newly allocated string without altering @value.
350                         Upon success, collect_value() needs to return NULL, if however
351                         a malicious condition occurred, collect_value() may spew an
352                         error by returning a newly allocated non-NULL string, giving
353                         a suitable description of the error condition.
354                         The calling code makes no assumptions about the @value
355                         contents being valid upon error returns, @value
356                         is simply thrown away without further freeing. As such, it is
357                         a good idea to not allocate #GValue contents, prior to returning
358                         an error, however, collect_values() is not obliged to return
359                         a correctly setup @value for error returns, simply because
360                         any non-NULL return is considered a fatal condition so further
361                         program behaviour is undefined.
362 @lcopy_format:          Format description of the arguments to collect for @lcopy_value,
363                         analogous to @collect_format. Usually, @lcopy_format string consists
364                         only of 'p's to provide lcopy_value() with pointers to storage locations.
365 @lcopy_value:           This function is responsible for storing the @value contents into
366                         arguments passed through a variable argument list which got
367                         collected into @collect_values according to @lcopy_format.
368                         @n_collect_values equals the string length of @lcopy_format,
369                         and @collect_flags may contain #G_VALUE_NOCOPY_CONTENTS.
370                         In contrast to collect_value(), lcopy_value() is obliged to
371                         always properly support #G_VALUE_NOCOPY_CONTENTS.
372                         Similar to collect_value() the function may prematurely abort
373                         by returning a newly allocated string describing an error condition.
374                         To complete the string example:
375 <msgtext><programlisting>
376 {
377   gchar **string_p = collect_values[0].v_pointer;
378
379   if (!string_p)
380     return g_strdup_printf ("string location passed as NULL");
381
382   if (collect_flags & G_VALUE_NOCOPY_CONTENTS)
383     *string_p = value-&gt;data[0].v_pointer;
384   else
385     *string_p = g_strdup (value-&gt;data[0].v_pointer);
386
387 }
388 </programlisting></msgtext>
389                         And an exemplary version of lcopy_value() for
390                         reference-counted types:
391 <msgtext><programlisting>
392 {
393   GObject **object_p = collect_values[0].v_pointer;
394
395   if (!object_p)
396     return g_strdup_printf ("object location passed as NULL");
397   if (!value-&gt;data[0].v_pointer)
398     *object_p = NULL;
399   else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) /* always honour */
400     *object_p = value-&gt;data[0].v_pointer;
401   else
402     *object_p = g_object_ref (value-&gt;data[0].v_pointer);
403   return NULL;
404 }
405 </programlisting></msgtext>
406
407 <!-- ##### MACRO G_TYPE_FROM_INSTANCE ##### -->
408 <para>
409 Returns the type identifier from a given @instance structure.
410 </para>
411
412 @instance: Location of a valid #GTypeInstance structure.
413
414
415 <!-- ##### MACRO G_TYPE_FROM_CLASS ##### -->
416 <para>
417 Returns the type identifier from a given @class structure.
418 </para>
419
420 @g_class: Location of a valid #GTypeClass structure.
421
422
423 <!-- ##### MACRO G_TYPE_FROM_INTERFACE ##### -->
424 <para>
425 Returns the type identifier from a given @interface structure.
426 </para>
427
428 @g_iface: Location of a valid #GTypeInterface structure.
429
430
431 <!-- ##### MACRO G_TYPE_INSTANCE_GET_CLASS ##### -->
432 <para>
433 Returns the class structure of a given @instance, casted
434 to a specified anchestor type @g_type of the instance.
435 </para>
436
437 @instance:      Location of the #GTypeInstance structure.
438 @g_type:        The anchestor type of the class to be returned.
439 @c_type:        The corresponding C type of @g_Type.
440
441
442 <!-- ##### MACRO G_TYPE_INSTANCE_GET_INTERFACE ##### -->
443 <para>
444
445 </para>
446
447 @instance: 
448 @g_type: 
449 @c_type: 
450
451
452 <!-- ##### MACRO G_TYPE_CHECK_INSTANCE ##### -->
453 <para>
454
455 </para>
456
457 @instance: 
458
459
460 <!-- ##### MACRO G_TYPE_CHECK_INSTANCE_CAST ##### -->
461 <para>
462
463 </para>
464
465 @instance: 
466 @g_type: 
467 @c_type: 
468
469
470 <!-- ##### MACRO G_TYPE_CHECK_INSTANCE_TYPE ##### -->
471 <para>
472
473 </para>
474
475 @instance: 
476 @g_type: 
477
478
479 <!-- ##### MACRO G_TYPE_CHECK_CLASS_CAST ##### -->
480 <para>
481
482 </para>
483
484 @g_class: 
485 @g_type: 
486 @c_type: 
487
488
489 <!-- ##### MACRO G_TYPE_CHECK_CLASS_TYPE ##### -->
490 <para>
491
492 </para>
493
494 @g_class: 
495 @g_type: 
496
497
498 <!-- ##### MACRO G_TYPE_CHECK_VALUE ##### -->
499 <para>
500
501 </para>
502
503 @value: 
504
505
506 <!-- ##### MACRO G_TYPE_CHECK_VALUE_TYPE ##### -->
507 <para>
508
509 </para>
510
511 @value: 
512 @g_type: 
513
514
515 <!-- ##### MACRO G_TYPE_FLAG_RESERVED_ID_BIT ##### -->
516 <para>
517
518 </para>
519
520
521
522 <!-- ##### FUNCTION g_type_init ##### -->
523 <para>
524 Prior to any use of the type system, g_type_init() has to be called to initialize
525 the type system and assorted other code portions (such as the various fundamental
526 type implementations or the signal system).
527 </para>
528
529 <!-- # Unused Parameters # -->
530 @debug_flags: Bitwise combination of #GTypeDebugFlags values for debugging purposes.
531
532
533 <!-- ##### ENUM GTypeDebugFlags ##### -->
534 <para>
535
536 </para>
537
538 @G_TYPE_DEBUG_NONE: 
539 @G_TYPE_DEBUG_OBJECTS: 
540 @G_TYPE_DEBUG_SIGNALS: 
541 @G_TYPE_DEBUG_MASK: 
542
543 <!-- ##### FUNCTION g_type_init_with_debug_flags ##### -->
544 <para>
545
546 </para>
547
548 @debug_flags: 
549
550
551 <!-- ##### FUNCTION g_type_name ##### -->
552 <para>
553 Return the unique name that is assigned to a type ID (this is the preferred method
554 to find out whether a specific type has been registered for the passed in ID yet).
555 </para>
556
557 @type:          Type to return name for.
558 @Returns:       Static type name or NULL.
559
560
561 <!-- ##### FUNCTION g_type_qname ##### -->
562 <para>
563 Return the corresponding quark of the type IDs name.
564 </para>
565
566 @type:    Type to return quark of type name for.
567 @Returns: The type names quark or 0.
568
569
570 <!-- ##### FUNCTION g_type_from_name ##### -->
571 <para>
572 Lookup the type ID from a given type name, returns 0 if no type has been registered under this name
573 (this is the preferred method to find out by name whether a specific type has been registered yet).
574 </para>
575
576 @name:    Type name to lookup.
577 @Returns: Corresponding type ID or 0.
578
579
580 <!-- ##### FUNCTION g_type_parent ##### -->
581 <para>
582 Return the direct parent type of the passed in type.
583 If the passed in type has no parent, i.e. is a fundamental type, 0 is returned.
584 </para>
585
586 @type:    The derived type.
587 @Returns: The parent type.
588
589
590 <!-- ##### FUNCTION g_type_depth ##### -->
591 <para>
592
593 </para>
594
595 @type: 
596 @Returns: 
597
598
599 <!-- ##### FUNCTION g_type_next_base ##### -->
600 <para>
601 Given a @leaf_type and a @root_type which is contained in its anchestry, return
602 the type that @root_type is the immediate parent of.
603 In other words, this function determines the type that is derived directly from
604 @root_type which is also a base class of @leaf_type.  Given a root type and a
605 leaf type, this function can be used to determine the types and order in which
606 the leaf type is descended from the root type.
607 </para>
608
609 @leaf_type:     Descendant of @root_type and the type to be returned.
610 @root_type:     Immediate parent of the returned type.
611 @Returns:       Immediate child of @root_type and anchestor of @leaf_type.
612
613
614 <!-- ##### FUNCTION g_type_is_a ##### -->
615 <para>
616 Check whether @type is a descendant of @is_a_type.
617 </para>
618
619 @type:      Type to check anchestry for.
620 @is_a_type: Possible anchestor of @type.
621 @Returns:   %TRUE if @type is_a @is_a_type holds true.
622
623
624 <!-- ##### FUNCTION g_type_class_ref ##### -->
625 <para>
626 Increments the reference count of the class structure belonging to
627 @type. This function will demand-create the class if it doesn't
628 exist already.
629 </para>
630
631 @type:    Type ID of a classed type.
632 @Returns: The #GTypeClass structure for the given type ID.
633
634
635 <!-- ##### FUNCTION g_type_class_peek ##### -->
636 <para>
637 This function is essentially the same as g_type_class_ref(), except that
638 the classes reference count isn't incremented. Therefore, this function
639 may return NULL if the class of the type passed in does not currently
640 exist (hasn't been referenced before).
641 </para>
642
643 @type:          Type ID of a classed type.
644 @Returns:       The #GTypeClass structure for the given type ID or NULL
645                 if the class does not currently exist.
646
647
648 <!-- ##### FUNCTION g_type_class_unref ##### -->
649 <para>
650 Decrements the reference count of the class structure being passed in.
651 Once the last reference count of a class has been released, classes
652 may be finalized by the type system, so further dereferencing of a
653 class pointer after g_type_class_unref() are invalid.
654 </para>
655
656 @g_class:       The #GTypeClass structure to unreference.
657
658
659 <!-- ##### FUNCTION g_type_class_peek_parent ##### -->
660 <para>
661 This is a convenience function, often needed in class intializers.
662 It essentially takes the immediate parent type of the class passed in,
663 and returns the class structure thereof. Since derived classes hold
664 a reference count on their parent classes as long as they are instantiated,
665 the returned class will always exist. This function is essentially
666 equivalent to:
667
668 <msgtext><programlisting>
669 g_type_class_peek (g_type_parent (G_TYPE_FROM_CLASS (g_class)));
670 </programlisting></msgtext>
671
672 </para>
673
674 @g_class: The #GTypeClass structure to retrieve the parent class for.
675 @Returns: The parent class of @g_class.
676
677
678 <!-- ##### FUNCTION g_type_interface_peek ##### -->
679 <para>
680
681 </para>
682
683 @instance_class: 
684 @iface_type: 
685 @Returns: 
686
687
688 <!-- ##### FUNCTION g_type_interface_peek_parent ##### -->
689 <para>
690
691 </para>
692
693 @g_iface: 
694 @Returns: 
695
696
697 <!-- ##### FUNCTION g_type_children ##### -->
698 <para>
699 Return a newly allocated and 0 terminated array of type IDs, listing the
700 child types of @type. The return value has to be g_free()ed after use.
701 </para>
702
703 @type:       The parent type.
704 @n_children: Optional #guint pointer to contain the number of child types.
705 @Returns:    Newly allocated and 0 terminated array of child types.
706
707
708 <!-- ##### FUNCTION g_type_interfaces ##### -->
709 <para>
710 Return a newly allocated and 0 terminated array of type IDs, listing the
711 interface types that @type conforms to. The return value has to be
712 g_free()ed after use.
713 </para>
714
715 @type:         The type to list interface types for.
716 @n_interfaces: Optional #guint pointer to contain the number of interface types.
717 @Returns:      Newly allocated and 0 terminated array of interface types.
718
719
720 <!-- ##### FUNCTION g_type_set_qdata ##### -->
721 <para>
722
723 </para>
724
725 @type: 
726 @quark: 
727 @data: 
728
729
730 <!-- ##### FUNCTION g_type_get_qdata ##### -->
731 <para>
732
733 </para>
734
735 @type: 
736 @quark: 
737 @Returns: 
738
739
740 <!-- ##### FUNCTION g_type_query ##### -->
741 <para>
742
743 </para>
744
745 @type: 
746 @query: 
747
748
749 <!-- ##### STRUCT GTypeQuery ##### -->
750 <para>
751
752 </para>
753
754 @type: 
755 @type_name: 
756 @class_size: 
757 @instance_size: 
758
759 <!-- ##### USER_FUNCTION GBaseInitFunc ##### -->
760 <para>
761 A callback function used by the type system to do base initialization
762 of the class structures of derived types. It is called as part of the
763 initialization process of all derived classes and should reallocate
764 or reset all dynamic class members copied over from the parent class.
765 Therefore class members, e.g. strings, that are not sufficiently
766 handled by a plain memory copy of the parent class into the derived class
767 have to be altered. See GClassInitFunc() for a discussion of the class
768 intialization process.
769 </para>
770
771 @g_class: The #GTypeClass structure to initialize.
772
773
774 <!-- ##### USER_FUNCTION GBaseFinalizeFunc ##### -->
775 <para>
776 A callback function used by the type system to finalize those portions
777 of a derived types class structure that were setup from the corresponding
778 GBaseInitFunc() function. Class finalization basically works the inverse
779 way in which class intialization is performed.
780 See GClassInitFunc() for a discussion of the class intialization process.
781 </para>
782
783 @g_class: The #GTypeClass structure to finalize.
784
785
786 <!-- ##### USER_FUNCTION GClassInitFunc ##### -->
787 <para>
788 A callback function used by the type system to initialize the class
789 of a specific type. This function should initialize all static class
790 members.
791 The initialization process of a class involves:
792 <variablelist>
793   <varlistentry><term></term><listitem><para>
794         1 - Copying common members from the parent class over to the
795         derived class structure.
796   </para></listitem></varlistentry>
797   <varlistentry><term></term><listitem><para>
798         2 -  Zero initialization of the remaining members not copied
799         over from the parent class.
800   </para></listitem></varlistentry>
801   <varlistentry><term></term><listitem><para>
802         3 - Invocation of the GBaseInitFunc initializers of all parent
803         types and the class' type.
804   </para></listitem></varlistentry>
805   <varlistentry><term></term><listitem><para>
806         4 - Invocation of the class' GClassInitFunc initializer.
807   </para></listitem></varlistentry>
808 </variablelist>
809 Since derived classes are partially initialized through a memory copy
810 of the parent class, the general rule is that GBaseInitFunc() and
811 GBaseFinalizeFunc() should take care of necessary reinitialization
812 and release of those class members that were introduced by the type
813 that specified these GBaseInitFunc()/GBaseFinalizeFunc().
814 GClassInitFunc() should only care about intializing static
815 class members, while dynamic class members (such as allocated strings
816 or reference counted resources) are better handled by a GBaseInitFunc()
817 for this type, so proper initialization of the dynamic class members
818 are performed for class intialization of derived types as well.
819 An example may help to correspond the intend of the different class
820 initializers:
821
822 <msgtext><programlisting>
823 typedef struct {
824   GObjectClass parent_class;
825   gint         static_integer;
826   gchar       *dynamic_string;
827 } TypeAClass;
828 static void
829 type_a_base_class_init (TypeAClass *class)
830 {
831   class->dynamic_string = g_strdup ("some string");
832 }
833 static void
834 type_a_base_class_finalize (TypeAClass *class)
835 {
836   g_free (class->dynamic_string);
837 }
838 static void
839 type_a_class_init (TypeAClass *class)
840 {
841   class->static_integer = 42;
842 }
843
844 typedef struct {
845   TypeAClass   parent_class;
846   gfloat       static_float;
847   GString     *dynamic_gstring;
848 } TypeBClass;
849 static void
850 type_b_base_class_init (TypeBClass *class)
851 {
852   class->dynamic_gstring = g_string_new ("some other string);
853 }
854 static void
855 type_b_base_class_finalize (TypeBClass *class)
856 {
857   g_string_free (class->dynamic_gstring);
858 }
859 static void
860 type_b_class_init (TypeBClass *class)
861 {
862   class->static_float = 3.14159265358979323846;
863 }
864 </programlisting></msgtext>
865 Initialization of TypeBClass will first cause initialization of
866 TypeAClass (derived classes reference their parent classes, see
867 g_type_class_ref() on this).
868 Initialization of TypeAClass roughly involves zero-initializing its fields,
869 then calling its GBaseInitFunc() type_a_base_class_init() that allocates
870 its dynamic members (dynamic_string) and finally calling its GClassInitFunc()
871 type_a_class_init() to initialize its static members (static_integer).
872 The first step in the initialization process of TypeBClass is then
873 a plain memory copy of the contents of TypeAClass into TypeBClass and 
874 zero-initialization of the remaining fields in TypeBClass.
875 The dynamic members of TypeAClass within TypeBClass now need
876 reinitialization which is performed by calling type_a_base_class_init()
877 with an argument of TypeBClass.
878 After that, the GBaseInitFunc() of TypeBClass, type_b_base_class_init()
879 is called to allocate the dynamic members of TypeBClass (dynamic_gstring),
880 and finally the GClassInitFunc() of TypeBClass, type_b_class_init(),
881 is called to complete the initialization process with the static members
882 (static_float).
883 Corresponding finalization counter parts to the GBaseInitFunc() functions
884 have to be provided to release allocated resources at class finalization
885 time.
886 </para>
887
888 @g_class:       The #GTypeClass structure to initialize.
889 @class_data:    The @class_data member supplied via the #GTypeInfo structure.
890
891
892 <!-- ##### USER_FUNCTION GClassFinalizeFunc ##### -->
893 <para>
894 A callback function used by the type system to finalize a class.
895 This function is rarely needed, as dynamically allocated class resources
896 should be handled by GBaseInitFunc() and GBaseFinalizeFunc().
897 Also, specification of a GClassFinalizeFunc in the #GTypeInfo
898 structure of a static type is invalid, because classes of static types
899 will never be finalized (they are artificially kept alive when their
900 reference count drops to zero).
901 </para>
902
903 @g_class:       The #GTypeClass structure to finalize.
904 @class_data:    The @class_data member supplied via the #GTypeInfo structure.
905
906
907 <!-- ##### USER_FUNCTION GInstanceInitFunc ##### -->
908 <para>
909 A callback function used by the type system to initialize a new
910 instance of a type. This function initializes all instance members and
911 allocates any resources required by it.
912 Initialization of a derived instance involves calling all its parent
913 types instance initializers, therefore the class member of the instance
914 is altered during its initialization to always point to the class that
915 belongs to the type the current initializer was introduced for.
916 </para>
917
918 @instance:      The instance to initialize.
919 @g_class:       The class of the type the instance is created for.
920
921
922 <!-- ##### USER_FUNCTION GInterfaceInitFunc ##### -->
923 <para>
924 A callback function used by the type system to initialize a new
925 interface.  This function should initialize all internal data and
926 allocate any resources required by the interface.
927 </para>
928
929 @g_iface:       The interface structure to initialize.
930 @iface_data:    The @class_data supplied via the #GTypeInfo structure.
931
932
933 <!-- ##### USER_FUNCTION GInterfaceFinalizeFunc ##### -->
934 <para>
935 A callback function used by the type system to finalize an interface.
936 This function should destroy any internal data and release any resources
937 allocated by the corresponding GInterfaceInitFunc() function.
938 </para>
939
940 @g_iface:       The interface structure to finalize.
941 @iface_data:    The @class_data supplied via the #GTypeInfo structure.
942
943
944 <!-- ##### USER_FUNCTION GTypeClassCacheFunc ##### -->
945 <para>
946
947 </para>
948
949 @cache_data: 
950 @g_class: 
951 @Returns: 
952
953
954 <!-- ##### ENUM GTypeFlags ##### -->
955 <para>
956 Bit masks used to check or determine characteristics of a type.
957 </para>
958
959 @G_TYPE_FLAG_ABSTRACT:  Indicates an abstract type. No instances can be
960                         created for an abstract type.
961 @G_TYPE_FLAG_VALUE_ABSTRACT: 
962
963 <!-- ##### ENUM GTypeFundamentalFlags ##### -->
964 <para>
965 Bit masks used to check or determine specific characteristics of a
966 fundamental type.
967 </para>
968
969 @G_TYPE_FLAG_CLASSED:           Indicates a classed type.
970 @G_TYPE_FLAG_INSTANTIATABLE:    Indicates an instantiable type (implies classed).
971 @G_TYPE_FLAG_DERIVABLE:                 Indicates a flat derivable type.
972 @G_TYPE_FLAG_DEEP_DERIVABLE:    Indicates a deep derivable type (implies derivable).
973
974 <!-- ##### FUNCTION g_type_register_static ##### -->
975 <para>
976 Registers @type_name as the name of a new static type derived from
977 @parent_type.  The type system uses the information contained in the
978 #GTypeInfo structure pointed to by @info to manage the type and its
979 instances (if not abstract).  The value of @flags determines the nature
980 (e.g. abstract or not) of the type.
981 </para>
982
983 @parent_type:   Type which this type will be derived from.
984 @type_name:     Null-terminated string used as the name of the new type.
985 @info:          The #GTypeInfo structure for this type.
986 @flags:                 Bitwise combination of #GTypeFlags values.
987 @Returns:       The new type identifier.
988
989
990 <!-- ##### FUNCTION g_type_register_dynamic ##### -->
991 <para>
992 Registers @type_name as the name of a new dynamic type derived from
993 @parent_type.  The type system uses the information contained in the
994 #GTypePlugin structure pointed to by @plugin to manage the type and its
995 instances (if not abstract).  The value of @flags determines the nature
996 (e.g. abstract or not) of the type.
997 </para>
998
999 @parent_type:   Type which this type will be derived from.
1000 @type_name:     Null-terminated string used as the name of the new type.
1001 @plugin:        The #GTypePlugin structure to retrive the #GTypeInfo from.
1002 @flags:                 Bitwise combination of #GTypeFlags values.
1003 @Returns:       The new type identifier.
1004 <!-- # Unused Parameters # -->
1005 @Returns: #G_TYPE_INVALID if registration failed or the new type identifier.
1006
1007
1008 <!-- ##### FUNCTION g_type_register_fundamental ##### -->
1009 <para>
1010 Registers @type_id as the predefined identifier and @type_name as the
1011 name of a fundamental type.  The type system uses the information
1012 contained in the #GTypeInfo structure pointed to by @info and the 
1013 #GTypeFundamentalInfo structure pointed to by @finfo to manage the
1014 type and its instances.  The value of @flags determines additional
1015 characteristics of the fundamental type.
1016 </para>
1017
1018 @type_id:       A predefined #GTypeFundamentals value.
1019 @type_name:     Null-terminated string used as the name of the new type.
1020 @info:          The #GTypeInfo structure for this type.
1021 @finfo:                 The #GTypeFundamentalInfo structure for this type.
1022 @flags:                 Bitwise combination of #GTypeFlags values.
1023 @Returns:       The predefined type identifier.
1024
1025
1026 <!-- ##### FUNCTION g_type_add_interface_static ##### -->
1027 <para>
1028 Adds the static @interface_type to @instantiable_type.  The information
1029 contained in the #GTypeInterfaceInfo structure pointed to by @info
1030 is used to manage the relationship.
1031 </para>
1032
1033 @instance_type:          #GType value of an instantiable type.
1034 @interface_type: #GType value of an interface type.
1035 @info:           The #GInterfaceInfo structure for this
1036                  (@instance_type, @interface_type) combination.
1037
1038
1039 <!-- ##### FUNCTION g_type_add_interface_dynamic ##### -->
1040 <para>
1041 </para>
1042
1043 @instance_type: 
1044 @interface_type: 
1045 @plugin: 
1046
1047
1048 <!-- ##### FUNCTION g_type_interface_add_prerequisite ##### -->
1049 <para>
1050
1051 </para>
1052
1053 @interface_type: 
1054 @prerequisite_type: 
1055
1056
1057 <!-- ##### FUNCTION g_type_get_plugin ##### -->
1058 <para>
1059 Returns the the #GTypePlugin structure for @type or
1060 #NULL if @type does not have a #GTypePlugin structure.
1061 </para>
1062
1063 @type:          The #GType to retrive the plugin for.
1064 @Returns:       The corresponding plugin if @type is a dynamic type,
1065                 NULL otherwise.
1066
1067
1068 <!-- ##### FUNCTION g_type_interface_get_plugin ##### -->
1069 <para>
1070 </para>
1071
1072 @instance_type: 
1073 @implementation_type: 
1074 @Returns: 
1075
1076
1077 <!-- ##### FUNCTION g_type_fundamental_next ##### -->
1078 <para>
1079 Returns the next free fundamental type id which can be used to
1080 register a new fundamental type with g_type_register_fundamental().
1081 The returned type ID represents the highest currently registered
1082 fundamental type identifier.
1083
1084 </para>
1085
1086 @Returns: The nextmost fundamental type ID to be registered,
1087           or 0 if the type system ran out of fundamental type IDs.
1088
1089
1090 <!-- ##### FUNCTION g_type_fundamental ##### -->
1091 <para>
1092 Internal function, used to extract the fundamental type ID portion.
1093 use G_TYPE_FUNDAMENTAL() instead.
1094 </para>
1095
1096 @type_id: valid type ID
1097 @Returns: fundamental type ID
1098
1099
1100 <!-- ##### FUNCTION g_type_create_instance ##### -->
1101 <para>
1102 Creates and initializes an instance of @type if @type is valid and can
1103 be instantiated. The type system only performs basic allocation and
1104 structure setups for instances, actual instance creation should happen
1105 through functions supplied by the type's fundamental type implementation.
1106 So use of g_type_create_instance() is reserved for implementators of
1107 fundamental types only. E.g. instances of the #GObject hierarchy
1108 should be created via g_object_new() and <emphasis>never</emphasis>
1109 directly through g_type_create_instance() which doesn't handle
1110 things like singleton objects or object construction.
1111 Note: Do <emphasis>not</emphasis> use this function, unless you're
1112 implementing a fundamental type. Also language bindings should <emphasis>not</emphasis>
1113 use this function but g_object_new() instead.
1114 </para>
1115
1116 @type:    An instantiabtable type to create an instance for.
1117 @Returns: An allocated and initialized instance, subject to further
1118           treatment by the fundamental type implementation.
1119
1120
1121 <!-- ##### FUNCTION g_type_free_instance ##### -->
1122 <para>
1123 </para>
1124
1125 @instance: 
1126
1127
1128 <!-- ##### FUNCTION g_type_add_class_cache_func ##### -->
1129 <para>
1130
1131 </para>
1132
1133 @cache_data: 
1134 @cache_func: 
1135
1136
1137 <!-- ##### FUNCTION g_type_remove_class_cache_func ##### -->
1138 <para>
1139
1140 </para>
1141
1142 @cache_data: 
1143 @cache_func: 
1144
1145
1146 <!-- ##### FUNCTION g_type_class_unref_uncached ##### -->
1147 <para>
1148
1149 </para>
1150
1151 @g_class: 
1152
1153
1154 <!-- ##### FUNCTION g_type_value_table_peek ##### -->
1155 <para>
1156 Returns the location of the #GTypeValueTable associated with @type.
1157 <emphasis>Note, this function should only be used from source code
1158 that implements or has internal knowledge of the implementation of
1159 @type.</emphasis>
1160 </para>
1161
1162 @type:    A #GType value.
1163 @Returns: Location of the #GTypeValueTable associated with @type or
1164           #NULL if there is no #GTypeValueTable associated with @type.
1165
1166