Functions



OSCheckTypeInst

Abstract: Is the target object a subclass of the reference object?
public:

Parameters

NameDescription
typeinstReference instance of an object, desired type.
instInstance of object to check for type compatibility.
Result: false if typeinst or inst are 0 or inst is not a subclass of typeinst's class. true otherwise.

OSDynamicCast

Abstract: Roughly analagous to (type *) inst, but check if valid first.
public:

OSDynamicCast is an attempt to implement a rudimentary equivalent to rtti's dynamic_cast operator. Embedded-C++ doesn't allow the use of rtti. OSDynamicCast is build on the OSMetaClass mechanism. Note it is safe to call this with a 0 paramter.

Parameters

NameDescription
typename of desired class name. Notice that it is assumed that you desire to cast to a pointer to an object of this type. Also type qualifiers, like const, are not recognised and will cause an, usually obscure, compile error.
instPointer to object that you wish to attempt to type cast. May be 0.
Result: inst if object non-zero and it is of the desired type, otherwise 0.

OSObject

Abstract: Disable implicit copy constructor by making private
private:

OSObject(OSObject &src);

Parameters

NameDescription
srcReference to source object that isn't allowed to be copied

OSTypeID

Abstract: Given the name of a class return it's typeID
public:

Parameters

NameDescription
typeName of the desired type, eg. OSObject.
Result: 'this' if object is of desired type, otherwise 0.

OSTypeIDInst

Abstract: Given a pointer to an object return it's typeID
public:

Parameters

NameDescription
typeinstAn instance of an OSObject subclass.
Result: The typeID, ie. OSMetaClass *.

free

Abstract: The last reference is gone so clean up your resources.
protected:

virtual void free();

Release all resources held by the object, then call your parent's free().



Caution:
1> You can not assume that you have completed initialisation before your free is called, so be very careful in your implementation.
2> The implementation is OSObject::free() { delete this; } so do not call super::free() until just before you return.
3> Free is not allowed to fail all resource must be released on completion.


getRetainCount

Abstract: How many times has this object been retained?
public:

virtual int getRetainCount() const;

Result: Current retain count

init

Abstract: Mac OS X kernel's primary mechanism for constructing objects.
protected:

virtual bool init();

Your responsibility as a subclass author is to override the init method of your parent. In general most of our implementations call ::init() before doing local initialisation, if the parent fails then return false immediately. If you have a failure during you local initialisation then return false.

Result: OSObject::init Always returns true, but subclasses will return false on init failure.

isEqualTo

Abstract: Is this == anObj?
public:

virtual bool isEqualTo(const OSObject *anObj) const;

OSObject::isEqualTo implements this as a shallow pointer comparison. The OS container classes do a more meaningful comparison. Your mileage may vary.

Parameters

NameDescription
anObjObject to compare 'this' to.
Result: true if the objects are equivalent, false otherwise.

metaCast

Abstract: Check to see if this object is or inherits from the given type.
public:

OSObject *metaCast(const OSMetaClass *toMeta) const;

This function is the guts of the OSMetaClass system. IODynamicCast, qv, is implemented using this function.

Parameters

NameDescription
toMetaPointer to a constant OSMetaClass for the desired target type.
Result: 'this' if object is of desired type, otherwise 0.

metaCast

Abstract: See OSObject::metaCast(const OSMetaClass *)
public:

OSObject *metaCast(const OSSymbol *toMeta) const;

Parameters

NameDescription
toMetaOSSymbol of the desired class' name.
Result: 'this' if object is of desired type, otherwise 0.

metaCast

Abstract: See OSObject::metaCast(const OSMetaClass *)
public:

OSObject *metaCast(const OSString *toMeta) const;

Parameters

NameDescription
toMetaOSString of the desired class' name.
Result: 'this' if object is of desired type, otherwise 0.

metaCast

Abstract: See OSObject::metaCast(const OSMetaClass *)
public:

OSObject *metaCast(const char *toMeta) const;

Parameters

NameDescription
toMetaconst char * C String of the desired class' name.
Result: 'this' if object is of desired type, otherwise 0.

operator =

Abstract: Disable implicit copy constructor by making private
private:

void operator =(OSObject &src);

Parameters

NameDescription
srcReference to source object that isn't allowed to be copied

operator delete

Abstract: Release the 'operator new'ed memory.
protected:

static void operator delete(void *mem, size_t size);

Never attempt to delete an object that inherits from OSObject directly use $link release().

Parameters

NameDescription
mempointer to block of memory
sizesize of block of memory

operator new

Abstract: Allocator for all objects that inherit from OSObject
public:

static void *operator new(size_t size);

Parameters

NameDescription
sizenumber of bytes to allocate
Result: returns pointer to block of memory if avaialable, 0 otherwise.

release

Abstract: Primary implementation of the release mechanism.
protected:

void release(int when) const;

If $link retainCount <= the when argument then call $link free(). This indirect implementation of $link release allows the developer to break reference circularity. An example of this sort of problem is a parent/child mutual reference, either the parent or child can implement: void release() { release(2); } thus breaking the cirularity.

Parameters

NameDescription
whenWhen retainCount == when then call free().

release

Abstract: Release a reference to this object
public:

virtual void release() const;


retain

Abstract: Retain a reference in this object.
public:

virtual void retain() const;


serialize

public:

virtual bool serialize(OSSerialize *s) const;


© 2000 Apple Computer, Inc. — (Last Updated 2/23/2000)