The header file
CFBase.h
defines several basic types, functions, and macros that can be used across Core Foundation. The
CFGetTypeID
function computes and returns an unsigned integer (typed as
CFTypeID
) that identifies the opaque type of any object referenced in the function's parameter. Each opaque type in Core Foundation defines a function of the form
Type
GetTypeID
to return that integer value (for example,
CFArrayGetTypeID
). In your code you can compare the value of the
CFTypeID
computed by
CFGetTypeID
with the value returned by a class-specific function to determine the opaque type of an object--an object, for example, such as might be encountered in a heterogeneous collection.
CFBase.h
also defines a "base" (or generic) object reference,
CFTypeRef
, that can serve as a placeholder type for parameters and return values that can accept objects of multiple Core Foundation types. (To use the object, the function's client or implementor usually must, of course, cast the
CFTypeRef
to an appropriate object reference.)
In addition to
CFGetTypeID
,
CFBase.h
includes a number of other "polymorphic" functions: functions that can take a reference to any Core Foundation object. For example,
CFEqual
determines if two objects are equal (what determines equality depends upon the opaque type of an object and, if it is a collection object, on the opaque types of its contained objects).
CFHash
returns a hash-code identifier of an object.
CFCopyTypeIDDescription
and
CFCopyDescription
are polymorphic functions useful in debugging. As with
CFGetTypeID
, opaque types define their own versions of these polymorphic functions which are then called by the polymorphic ones.
CFBase.h
also defines a number of polymorphic functions used in memory management; for more on these functions, see Memory Management.