Taxonomy Categories:
Member Functions:
Interface Category:
API.
Inherits From:
TPointerTo.
Inherited By:
None.
Purpose:
Contains a pointer to an object, and owns that object. Copying a TOnlyPointerTo transfers ownership of the object to the target pointer. Destroying a TInstanceOf destroys the object (if any) to which it points. Like all classes derived from TPointerTo, it can be dereferenced (operator * or operator ->) like a regular pointer; but if it contains NIL (0), dereferencing it throws an exception.
Instantiation:
Allocate on the heap or the stack.
Deriving Classes:
You should not derive any classes from TOnlyPointerTo.
Concurrency:
Not multithread safe.
Resource Use:
No special requirements.
Other Considerations:
TOnlyPointerTo can only point to a class whose destructor is public.
- TOnlyPointerTo (AType * adopt =NIL)
- TOnlyPointerTo (TOnlyPointerTo < AType > & transfer)
Interface Category:
API.
Purpose:
- Adopts the object specified.
- Transfers ownership of an object from the parameter to this object.
Calling Context:
- Call this function directly to adopt an object.
- Call this function directly to transfer ownership of an object from one TOnlyPointerTo to another TOnlyPointerTo.
Parameters:
- AType * adopt =NIL -The object to be adopted.
- TOnlyPointerTo < AType > & transfer -The object from which to transfer ownership.
Return Value:
None.
Exceptions:
Throws no exceptions.
Concurrency:
Not multithread safe.
Other Considerations:
None.
~ TOnlyPointerTo ()
Interface Category:
API.
Purpose:
Destroys this object and the object (if any) to which it points.
Calling Context:
Call this function directly to destroy this object and the object (if any) to which it points.
Parameters:
Return Value:
None.
Exceptions:
Throws no exceptions, passes all exceptions through.
Concurrency:
Not multithread safe.
Other Considerations:
None.
- TOnlyPointerTo < AType > & operator =(AType * adopt)
- TOnlyPointerTo < AType > & operator =(TOnlyPointerTo < AType > & transfer)
Interface Category:
API.
Purpose:
- Adopts the object specified, and destroys any previously adopted object.
- Transfers ownership of the object from the parameter to this object, and destroys any previously adopted object.
Calling Context:
- Call this function directly to adopt an object.
- Call this function directly to transfer ownership of any object.
Parameters:
Return Value:
A reference to this object.
Exceptions:
Throws no exceptions.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TOnlyPointerTo::operator==
- bool operator ==(const AType * r) const
- bool operator ==(const TOnlyPointerTo < AType > & r) const
Interface Category:
API.
Purpose:
Compare pointers for equality.
Calling Context:
Call this function directly to determine if two pointers are identical.
Parameters:
Return Value:
Returns true if this object and the parameter both point to the same object, or if both contain NIL.
Exceptions:
Throws no exceptions.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Member Function: TOnlyPointerTo::operator!=
- bool operator != (const AType * r) const
- bool operator != (const TOnlyPointerTo < AType > & r) const
Interface Category:
API.
Purpose:
Compare pointers for inequality.
Calling Context:
Call this function directly to determine if two pointers are different.
Parameters:
Return Value:
Returns true if this object and the parameter point to different objects, or if one but not both contain NIL.
Exceptions:
Throws no exceptions.
Concurrency:
Not multithread safe.
Other Considerations:
None.
AType * Orphan ()
Interface Category:
API.
Purpose:
Returns a copy of the pointer contained in this object, and changes this object to contain NIL. The object (if any) to which this object pointed is not affected.
Calling Context:
Call this function directly to release a adopted object.
Parameters:
Return Value:
A copy of the pointer that was contained in this object.
Exceptions:
Throws no exceptions.
Concurrency:
Not multithread safe.
Other Considerations:
None.
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.