NAME
OTC_Ptr -
Pointer which creates object only when required.
SYNOPSIS
#include <OTC/memory/ptr.hh>
template<class T>
class OTC_Ptr
{
public:
inline OTC_Ptr();
inline ~OTC_Ptr();
inline T* item();
inline T const* item() const;
inline T* operator->();
inline T const* operator->() const;
inline operator T*();
inline operator T const*() const;
inline T& operator*();
inline T const& operator*() const;
inline OTC_Boolean isUndefined() const;
};
CLASS TYPE
Concrete
DESCRIPTION
Designed such that the object being managed is only created
when required. Also deletes the object when pointer class
is destroyed.
CONSTRUCTION
inline OTC_Ptr();
Initialises the class to an undefined
state. The object is only created when it
is first required.
DESTRUCTION
inline ~OTC_Ptr();
Destroys the object if it has been
created.
ACCESS
inline T* item();
Returns the object being pointed at. If
the object had not previously been
created, it will be created.
inline T const* item() const;
Returns the object being pointed at. If
the object had not previously been
created, it will be created.
inline T* operator->();
Returns the object being pointed at.
inline T const* operator->() const;
Returns the object being pointed at.
inline operator T*();
Returns the object being pointed at.
inline operator T const*() const;
Returns the object being pointed at.
inline T& operator*();
Returns a reference to the item being
pointed at.
inline T const& operator*() const;
Returns a reference to the item being
pointed at.
QUERY
inline OTC_Boolean isUndefined() const;
Returns OTCLIB_TRUE
if the object
has not yet been created.
NOTES
Argument T
must be a class object. A builtin type or pointer
cannot be used for T
.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED