Zen API

- Home
- Help Topics
- Types by Category
- All Types
- Files

All Classes Files Functions Variables Typedefs Macros Groups Pages
Public Member Functions
kType Class Reference
kApi

## Description

Represents metadata about a type (class, interface, or value).

When an assembly is constructed, one kType instance is created for every type defined in the assmebly. kAssembly methods can be used to discover the types in the assembly, and kType methods can be used to learn about individual types (e.g., type name, base class).

The kObject_Type method can be used to obtain type information for any object derived from kObject. The kTypeOf macro can be used to obtain type information for any class, interface, or value by compile-time type symbol.

kBool IsImageType(kObject object)
{
kType objectType = kObject_Type(object);
kType imageType = kTypeOf(kImage);
return objectType == imageType;
}
Inheritance diagram for kType:

## Public Member Functions
kAlloc | kObject_Alloc (kObject object)
| Gets the memory allocator associated with this object. More...
kStatus | kObject_Clone (kObject *object, kObject source, kAlloc allocator)
| Constructs a new object by copying an existing object, including any aggregated child elements. More...
kStatus | kObject_Destroy (kObject object)
| Destroys the object. More...
kStatus | kObject_Dispose (kObject object)
| Destroys the object and any aggregated child elements. More...
kBool | kObject_Equals (kObject object, kObject other)
| Determines whether the object is equal to another object. More...
kSize | kObject_HashCode (kObject object)
| Gets a hash code representing the state of this object. More...
kBool | kObject_Is (kObject object, kType type)
| Determines whether this object is an instance of the specified type. More...
kBool | kObject_IsShared (kObject object)
| Reports whether the object is currently shared (reference count greater than one). More...
kStatus | kObject_SetPool (kObject object, kObjectPool pool)
| Sets the object pool associated with this object. More...
kStatus | kObject_Share (kObject object)
| Increments the reference count associated with this object. More...
kSize | kObject_Size (kObject object)
| Estimates the memory consumed by this object, including any aggregated child elements. More...
kType | kObject_Type (kObject object)
| Returns the type of the object. More...
kAssembly | kType_Assembly (kType type)
| Gets the assembly to which the type belongs. More...
kType | kType_Base (kType type)
| Gets the base of a class or interface. More...
kBool | kType_Extends (kType type, kType baseType)
| Determines whether a type extends another type. More...
kBool | kType_Implements (kType type, kType interfaceType)
| Determines whether a type implements a specific interface. More...
kSize | kType_InnerSize (kType type)
| Gets the internal size of a type. More...
kBool | kType_Is (kType type, kType other)
| Determines whether a type is equivalent to another type. More...
kBool | kType_IsAbstract (kType type)
| Determines whether a type represents an abstract class. More...
kBool | kType_IsArrayValue (kType type)
| Reports whether the type is an 'array-value' type (e.g., kText32) More...
kBool | kType_IsBitEnum (kType type)
| Reports whether the type is an enumeration bitset. More...
kBool | kType_IsClass (kType type)
| Determines whether a type represents a class. More...
kBool | kType_IsEnum (kType type)
| Reports whether the type is an enumeration. More...
kBool | kType_IsInterface (kType type)
| Determines whether a type represents an interface. More...
kBool | kType_IsReference (kType type)
| Determines whether a type represents a class or interface. More...
kBool | kType_IsValue (kType type)
| Determines whether a type represents a value (primitive, struct, enum). More...
kFunction * | kType_IVTable (kType type, kType interfaceType)
| Gets a pointer to the type's virtual method table corresponding to the specified interface type. More...
const kChar * | kType_Name (kType type)
| Gets the name of the type. More...
kSize | kType_Size (kType type)
| Gets the external size of a type. More...
void * | kType_Static (kType type)
| Gets a pointer to the type's static data structure. More...
kBool | kType_StaticInitialized (kType type)
| Reports whether the type's static data structure has been successfully initialized. More...
kFunction * | kType_VTable (kType type)
| Gets a pointer to the type's primary virtual method table. More...

## Member Function Documentation

kAlloc kObject_Alloc | ( | kObject | object | ) |
| inherited

Gets the memory allocator associated with this object.

Most objects are constructed with an allocator, which is used to allocate the memory required by the object. Objects retain a reference to this allocator to enable further allocations and to free memory when the object is destroyed.

Parameters

  object | Object.

Returns
  Memory allocator.

See also
  kAlloc, kObject_Alloc_

kStatus kObject_Clone | ( | kObject * | object,
|  | kObject | source,
|  | kAlloc | allocator
| ) |  |
| inherited

Constructs a new object by copying an existing object, including any aggregated child elements.

If the source object is an object collection (e.g. kArrayList<kString>), any aggregated child objects are also cloned. In this case, the kObject_Dispose method can be used to free the cloned collection and its associated elements.

This method will fail if the source object (or an aggregated child element) does not support cloning.

Parameters

  object | Receives the constructed object.
  source | Source object.
  allocator | Memory allocator (or kNULL for default).

Returns
  Operation status.

See also
  kObject_Dispose

kStatus kObject_Destroy | ( | kObject | object | ) |
| inherited

Destroys the object.

The kObject_Destroy method destroys the object itself and any resources that are owned by the object. See Object Destruction for more information.

When an object is destroyed (or disposed), its reference count is decremented. The object is only truly destroyed when the reference count reaches zero. See Reference Counting for more information.

Parameters

  object | Object (or kNULL).

Returns
  Operation status.

See also
  Object Destruction, Reference Counting

kStatus kObject_Dispose | ( | kObject | object | ) |
| inherited

Destroys the object and any aggregated child elements.

The kObject_Dispose method destroys the object itself, any resources that are owned by the object, and if the object represents a collection of objects, any child objects in the collection. See Object Destruction for more information.

When an object is destroyed (or disposed), its reference count is decremented. The object is only truly destroyed when the reference count reaches zero. See Reference Counting for more information.

Parameters

  object | Object (or kNULL).

Returns
  Operation status.

See also
  Object Destruction, Reference Counting

kBool kObject_Equals | ( | kObject | object,
|  | kObject | other
| ) |  |
| inherited

Determines whether the object is equal to another object.

By default, objects are compared by reference; objects are considered equal if the given handles refer to the same object instance. However, some classes override the Equals method to provide a more meaningful comparison (e.g. kString).

Parameters

  object | Object.
  other | Object for comparison.

Returns
  kTRUE if the objects are equal.

kSize kObject_HashCode | ( | kObject | object | ) |
| inherited

Gets a hash code representing the state of this object.

By default, objects return a hash code based on the object handle value. However, some classes override the HashCode method to provide a more useful hash (e.g. kString).

Parameters

  object | Object.

Returns
  Hash code.

kBool kObject_Is | ( | kObject | object,
|  | kType | type
| ) |  |
| inherited

Determines whether this object is an instance of the specified type.

This function compares the type of this object with the given type. An object is considered to be an instance of a given type if a) the type represents a class and this object inherits from (or instantiates) that class, or b) the type represents an interface and this object implements the interface.

Parameters

  object | Object.
  type | Type.

Returns
  kTRUE if the object is of the specified type; otherwise kFALSE.

See also
  kObject_Is_, kType_Is

kBool kObject_IsShared | ( | kObject | object | ) |
| inherited

Reports whether the object is currently shared (reference count greater than one).

Objects are initialized with a reference count of one. The kObject_Share method can be used to increment the reference count. The kObject_Destroy and kObject_Dispose methods decrease the reference count, and when the reference count reaches zero, the object is actually destroyed/disposed.

This method can be used to determine if the reference count of an object is currently greater than one.

This method is thread-safe.

Parameters

  object | Object.

Returns
  kTRUE if the object is shared; kFALSE otherwise.

See also
  Reference Counting, kObject_Share

kStatus kObject_SetPool | ( | kObject | object,
|  | kObjectPool | pool
| ) |  |
| inherited

Sets the object pool associated with this object.

Object pools can be used to implement custom lifecycle management. If an object has an assigned pool, then the kObjectPool_Reclaim method will be called just prior to destruction, to provide an opportunity for the object to be reclaimed.

Parameters

  object | Object.
  pool | Pool object (or kNULL to clear the pool assignment).

Returns
  Operation status.

kStatus kObject_Share | ( | kObject | object | ) |
| inherited

Increments the reference count associated with this object.

This method is thread-safe.

Parameters

  object | Object.

Returns
  Operation status.

See also
  reference-counting

kSize kObject_Size | ( | kObject | object | ) |
| inherited

Estimates the memory consumed by this object, including any aggregated child elements.

This method can be optionally overridden by kObject-derived classes to report the amount of memory consumed by an object. The default implementation reports only the size of the class instance (additional allocations performed by the class are excluded).

Parameters

  object | Object.

Returns
  Object size, in bytes.

kType kObject_Type | ( | kObject | object | ) |
| inherited

Returns the type of the object.

Each object is an instance of a specific class type. The type handle returned by this function can be used to learn about the class.

Parameters

  object | Object.

Returns
  Type.

See also
  kType, kObject_Type_

kAssembly kType_Assembly | ( | kType | type | ) |

Gets the assembly to which the type belongs.

Parameters

  type | Type.

Returns
  Assembly.

kType kType_Base | ( | kType | type | ) |

Gets the base of a class or interface.

Parameters

  type | Type.

Returns
  Base type (or kNULL if none).

kBool kType_Extends | ( | kType | type,
|  | kType | baseType
| ) |  |

Determines whether a type extends another type.

Parameters

  type | Type.
  baseType | Base type.

Returns
  kTRUE if type extends base type.

kBool kType_Implements | ( | kType | type,
|  | kType | interfaceType
| ) |  |

Determines whether a type implements a specific interface.

Parameters

  type | Type.
  interfaceType | Interface type.

Returns
  kTRUE if type implements interface.

kSize kType_InnerSize | ( | kType | type | ) |

Gets the internal size of a type.

The internal size of a value type reflects the size of the struct, value or enum. The internal size of a reference type is equal to the size of its class structure.

Returns
  Type size.

kBool kType_Is | ( | kType | type,
|  | kType | other
| ) |  |

Determines whether a type is equivalent to another type.

Checks type equality, inheritance, and interfaces.

Parameters

  type | Type to be compared.
  other | Type to which type is compared.

Returns
  kTRUE if type is equivalent.

kBool kType_IsAbstract | ( | kType | type | ) |

Determines whether a type represents an abstract class.

Parameters

  type | Class type.

Returns
  kTRUE if type is abstract.

kBool kType_IsArrayValue | ( | kType | type | ) |

Reports whether the type is an 'array-value' type (e.g., kText32)

Returns
  kTRUE if the type is an 'array-value' type; otherwise, kFALSE.

kBool kType_IsBitEnum | ( | kType | type | ) |

Reports whether the type is an enumeration bitset.

Returns
  kTRUE if the type is an enumeration bitset; otherwise, kFALSE.

kBool kType_IsClass | ( | kType | type | ) |

Determines whether a type represents a class.

Parameters

  type | Type.

Returns
  kTRUE if type represents a class.

kBool kType_IsEnum | ( | kType | type | ) |

Reports whether the type is an enumeration.

Returns
  kTRUE if the type is an enumeration; otherwise, kFALSE.

kBool kType_IsInterface | ( | kType | type | ) |

Determines whether a type represents an interface.

Parameters

  type | Type.

Returns
  kTRUE if type represents an interface.

kBool kType_IsReference | ( | kType | type | ) |

Determines whether a type represents a class or interface.

Parameters

  type | Type.

Returns
  kTRUE if type represents a reference.

kBool kType_IsValue | ( | kType | type | ) |

Determines whether a type represents a value (primitive, struct, enum).

Parameters

  type | Type.

Returns
  kTRUE if type represents a value.

kFunction * kType_IVTable | ( | kType | type,
|  | kType | interfaceType
| ) |  |

Gets a pointer to the type's virtual method table corresponding to the specified interface type.

Returns
  Interface virtual table pointer.

const kChar * kType_Name | ( | kType | type | ) |

Gets the name of the type.

Parameters

  type | Type.

Returns
  Type name.

kSize kType_Size | ( | kType | type | ) |

Gets the external size of a type.

The external size of a value type reflects the size of the struct, value or enum. The external size of a reference type is equal to the size of a pointer.

Returns
  Type size.

void * kType_Static | ( | kType | type | ) |

Gets a pointer to the type's static data structure.

Returns
  Pointer to static data.

kBool kType_StaticInitialized | ( | kType | type | ) |

Reports whether the type's static data structure has been successfully initialized.

This function can be helpful during startup, to determine whether the static data for a particular type has been initialized. This function is not thread-safe.

Returns
  kTRUE if static data has been initialized; otherwise, kFALSE.

kFunction * kType_VTable | ( | kType | type | ) |

Gets a pointer to the type's primary virtual method table.

Returns
  Virtual table pointer.

The documentation for this class was generated from the following file:

- kType.h