NAME
OTC_VecPtr -
Smart pointer to help manage resources.
SYNOPSIS
#include <OTC/memory/vecptr.hh>
template<class T>
class OTC_VecPtr
{
public:
inline OTC_VecPtr(u_int theSize);
inline ~OTC_VecPtr();
inline T* item();
inline T const* item() const;
inline T& operator[](u_int theIndex);
inline T const& operator[](u_int theIndex) const;
inline operator T*();
inline operator T const*() const;
inline T& operator*();
inline T const& operator*() const;
inline u_int size() const;
inline OTC_Boolean isUndefined() const;
};
CLASS TYPE
Concrete
DESCRIPTION
Designed such that the array of objects being managed is only
created when required. Also deletes the array of objects when the
pointer class is destroyed.
CONSTRUCTION
inline OTC_VecPtr(u_int theSize);
Initialises the class to an undefined
state. The array of objects is only
created when it is required. theSize
is
the desired length of the array.
DESTRUCTION
inline ~OTC_VecPtr();
Deletes the array of objects if it had
be created.
ACCESS
inline T* item();
Returns the array of objects being pointed
at. If the array of objects had not already
been created, it will be created.
inline T const* item() const;
Returns the array of objects being pointed
at. If the array of objects had not already
been created, it will be created.
inline T& operator[](u_int theIndex);
Returns a reference to the object in
the array at position theIndex
.
No bounds checking is performed.
inline T const& operator[](u_int theIndex) const;
Returns a reference to the object in
the array at position theIndex
.
No bounds checking is performed.
inline operator T*();
Returns the array of objects being pointed
at.
inline operator T const*() const;
Returns the array of objects being pointed
at.
inline T& operator*();
Returns a reference to the first object in
the vector being held. If no item is held,
an exception is generated.
inline T const& operator*() const;
Returns a reference to the first object in
the vector being held. If no item is held,
an exception is generated.
QUERY
inline u_int size() const;
Returns the size of the array.
inline OTC_Boolean isUndefined() const;
Returns OTCLIB_TRUE
if the array of
items has not yet been created.
LIBRARY
OTC
AUTHOR(S)
Graham Dumpleton
COPYRIGHT
Copyright 1994 DUMPLETON SOFTWARE CONSULTING PTY LIMITED