NAME
OTC_CCtrPtr -
Const version of a amart pointer to help manage resources.
SYNOPSIS
#include <OTC/refcnt/cctrptr.hh>
template<class T>
class OTC_CCtrPtr
{
public:
OTC_CCtrPtr();
OTC_CCtrPtr(T const* theItem);
OTC_CCtrPtr(OTC_CCtrPtr<T> const& theCtrPtr);
~OTC_CCtrPtr();
inline T const* item() const;
inline T const* operator->() const;
inline operator T const*() const;
inline T const& operator*() const;
inline OTC_Boolean operator!() const;
inline OTC_Boolean operator==(int theItem) const;
inline OTC_Boolean operator!=(int theItem) const;
inline OTC_Boolean operator==(T const* theItem) const;
inline OTC_Boolean operator!=(T const* theItem) const;
void setItem(OTC_CCtrPtr<T> const& theCtrPtr);
void setItem(T const* theItem);
OTC_CCtrPtr<T>& operator=(OTC_CCtrPtr<T> const& theCtrPtr);
OTC_CCtrPtr<T>& operator=(T const* theItem);
u_int numRefs() const;
protected:
inline T* _item() const;
T* _itemNoNull() const;
};
CLASS TYPE
Concrete
DESCRIPTION
Designed to manage classes which do not contain the ability to
keep a reference count.
CONSTRUCTION
OTC_CCtrPtr();
Creates a nil pointer class.
OTC_CCtrPtr(T const* theItem);
Creates a pointer class for theItem.
OTC_CCtrPtr(OTC_CCtrPtr<T> const& theCtrPtr);
Creates a pointer class for the
object pointed to by theCtrPtr.
DESTRUCTION
~OTC_CCtrPtr();
Decrements the reference count associated
with the object, and destroys it if it is
no longer being used.
ACCESS
inline T const* item() const;
Returns the object being pointed at.
inline T const* operator->() const;
Returns the object being pointed at. If no
item is held, an exception is raised.
inline operator T const*() const;
Returns the object being pointed at.
inline T const& operator*() const;
Returns a reference to the item being
held. If no item is held, an exception
is raised.
inline OTC_Boolean operator!() const;
inline OTC_Boolean operator==(int theItem) const;
inline OTC_Boolean operator!=(int theItem) const;
inline OTC_Boolean operator==(T const* theItem) const;
inline OTC_Boolean operator!=(T const* theItem) const;
ASSIGNMENT
With all the following, the count on the currently held
object will be decremented, and if it is no longer required,
it will be deleted.
void setItem(OTC_CCtrPtr<T> const& theCtrPtr);
Sets this class to point at the object
held by theCtrPtr.
void setItem(T const* theItem);
Sets this class to point at theItem.
OTC_CCtrPtr<T>& operator=(OTC_CCtrPtr<T> const& theCtrPtr);
Sets this class to point at the object
held by theCtrPtr.
OTC_CCtrPtr<T>& operator=(T const* theItem);
Sets this class to point at theItem.
QUERY
u_int numRefs() const;
Returns the number of references to
the object held by this class.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1991 OTC LIMITED
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED