NAME
OTC_ResPtr -
Smart pointer to help manage a resource.
SYNOPSIS
#include <OTC/refcnt/resptr.hh>
template<class T>
class OTC_ResPtr : public OTC_CResPtr<T>
{
public:
inline OTC_ResPtr();
inline OTC_ResPtr(T* theItem);
inline OTC_ResPtr(OTC_ResPtr<T> const& theRP);
inline T* item() const;
inline T* operator->() const;
inline operator T*() const;
inline T& operator*() const;
inline OTC_ResPtr<T>& operator=(T* theItem);
inline OTC_ResPtr<T>& operator=(OTC_ResPtr<T> const& theRP);
};
CLASS TYPE
Concrete
DESCRIPTION
Designed to manage classes which contain the ability to keep a
reference count, such as classes derived from OTC_Resource
.
CONSTRUCTION
inline OTC_ResPtr();
Creates a nil pointer class.
inline OTC_ResPtr(T* theItem);
Creates a pointer class for theItem
.
inline OTC_ResPtr(OTC_ResPtr<T> const& theRP);
Creates a pointer class for the object
pointed to by theRP
.
ACCESS
inline T* item() const;
Returns the object being pointed at.
inline T* operator->() const;
Returns the object being pointed at. An
exception is generated if no item is held.
inline operator T*() const;
Returns the object being pointed at.
inline T& operator*() const;
Returns a reference to the object being
pointed at. An exception is generated if
no item is held.
ASSIGNMENT
With all the following, the object being assigned to this class
will have its reference count incremented, the count on the
currently held object will be decremented and if it is no longer
required, it will be deleted.
inline OTC_ResPtr<T>& operator=(T* theItem);
Sets this class to point at theItem
.
inline OTC_ResPtr<T>& operator=(OTC_ResPtr<T> const& theRP);
Sets this class to point at the object
held by theRP
.
SEE ALSO
OTC_Resource
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1991 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED