Class: TOnlyPointerTo

Declaration: SafePointers.h

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.

Member Function: TOnlyPointerTo::TOnlyPointerTo

  1. TOnlyPointerTo (AType * adopt =NIL)
  2. TOnlyPointerTo (TOnlyPointerTo < AType > & transfer)

Interface Category:

API.

Purpose:

  1. Adopts the object specified.
  2. Transfers ownership of an object from the parameter to this object.

Calling Context:

  1. Call this function directly to adopt an object.
  2. Call this function directly to transfer ownership of an object from one TOnlyPointerTo to another TOnlyPointerTo.

Parameters:

Return Value:

None.

Exceptions:

Throws no exceptions.

Concurrency:

Not multithread safe.

Other Considerations:

None.

Member Function: TOnlyPointerTo::~TOnlyPointerTo

~ 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.

Member Function: TOnlyPointerTo::operator=

  1. TOnlyPointerTo < AType > & operator =(AType * adopt)
  2. TOnlyPointerTo < AType > & operator =(TOnlyPointerTo < AType > & transfer)

Interface Category:

API.

Purpose:

  1. Adopts the object specified, and destroys any previously adopted object.
  2. Transfers ownership of the object from the parameter to this object, and destroys any previously adopted object.

Calling Context:

  1. Call this function directly to adopt an object.
  2. 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==

  1. bool operator ==(const AType * r) const
  2. 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!=

  1. bool operator != (const AType * r) const
  2. 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.

Member Function: TOnlyPointerTo::Orphan

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.