Main Page Modules Class Hierarchy Data Structures File List Data Fields Globals Related Pages

# OsclExclusiveArrayPtr< T > Class Template Reference
[OSCL Base]

The OsclExclusiveArrayPtr class is a template class that defines an array pointer like object intended to be assigned an address obtanined (directly or or indirectly) by new. When the OsclExclusiveArrayPtr expires, its destructor uses delete to free the memory. More...

`#include <oscl_exclusive_ptr.h>`

## Public Methods
| OsclExclusiveArrayPtr (T *inPtr=0)
| Default constructor Initializes the pointer and takes ownership.
| OsclExclusiveArrayPtr (OsclExclusiveArrayPtr< T > &_Y)
| Copy constructor.
OsclExclusiveArrayPtr< T > & | operator= (OsclExclusiveArrayPtr< T > &_Y)
| Assignment operator from an another OsclExclusiveArrayPtr.
virtual | ~OsclExclusiveArrayPtr ()
| Destructor.
T & | operator * () const
| The indirection operator (*) accesses a value indirectly, through a pointer.
T * | operator-> () const
| The indirection operator (->) accesses a value indirectly, through a pointer.
T * | get () const
| get() method returns the pointer, currently owned by the class.
T * | release ()
| release() method releases ownership of the pointer, currently owned by the class. It returns the pointer as well.
bool | set (T *ptr)
| set() method sets ownership to the pointer, passed. This method is needed when the class is created with a default constructor. Returns false in case the class is non-empty.
## Protected Attributes
T * | _Ptr

## Detailed Description

### template<class T>
class OsclExclusiveArrayPtr< T >

The OsclExclusiveArrayPtr class is a template class that defines an array pointer like object intended to be assigned an address obtanined (directly or or indirectly) by new. When the OsclExclusiveArrayPtr expires, its destructor uses delete to free the memory.

The purpose of this class is to provide a way to prevent accidental memory leaks in a class or a method, due to "not remembering to delete" variables allocated on the heap. Thus if you assign an address returned by new to an OsclExclusivePtr object, you don't have to remember to free the memory later, it will be freed automatically when the object goes out of scope. The OsclExclusivePtr is an example of a smart pointer, an object that acts like a pointer, but with additional features. The class is defined so that it acts like a regular pointer in most respects

## Constructor & Destructor Documentation

template<class T>
OsclExclusiveArrayPtr< T >::OsclExclusiveArrayPtr | ( | T * | inPtr = 0 | ) | `[inline, explicit]`

| Default constructor Initializes the pointer and takes ownership.

template<class T>
OsclExclusiveArrayPtr< T >::OsclExclusiveArrayPtr | ( | OsclExclusiveArrayPtr< T > & | _Y | ) | `[inline]`

| Copy constructor. Initializes the pointer and takes ownership from another OsclExclusiveArrayPtr. Note that the other class does NOT own the pointer any longer, and hence it is NOT its responsibility to free it.

template<class T>
virtual OsclExclusiveArrayPtr< T >::~OsclExclusiveArrayPtr | ( |  | ) | `[inline, virtual]`

| Destructor. The pointer is deleted in case this class still has ownership

## Member Function Documentation

template<class T>
T* OsclExclusiveArrayPtr< T >::get | ( |  | ) | const`[inline]`

| get() method returns the pointer, currently owned by the class.

template<class T>
T& OsclExclusiveArrayPtr< T >::operator * | ( |  | ) | const`[inline]`

| The indirection operator (*) accesses a value indirectly, through a pointer. This operator ensures that the OsclExclusiveArrayPtr can be used like the regular pointer that it was initialized with.

template<class T>
T* OsclExclusiveArrayPtr< T >::operator-> | ( |  | ) | const`[inline]`

| The indirection operator (->) accesses a value indirectly, through a pointer. This operator ensures that the OsclExclusiveArrayPtr can be used like the regular pointer that it was initialized with.

template<class T>
OsclExclusiveArrayPtr<T>& OsclExclusiveArrayPtr< T >::operator= | ( | OsclExclusiveArrayPtr< T > & | _Y | ) | `[inline]`

  | Assignment operator from an another OsclExclusiveArrayPtr. Parameters:
  _Y | The value parameter should be another OsclExclusiveArrayPtr
Returns: Returns a reference to this OsclExclusiveArrayPtr instance with pointer initialized. Precondition: The input class should be non-null and should point to a valid pointer. This assignment operator initializes the class to the contents of the OsclExclusiveArrayPtr given as the input parameter. The ownership of the pointer is transferred.

template<class T>
T* OsclExclusiveArrayPtr< T >::release | ( |  | ) | `[inline]`

| release() method releases ownership of the pointer, currently owned by the class. It returns the pointer as well.

template<class T>
bool OsclExclusiveArrayPtr< T >::set | ( | T * | ptr | ) | `[inline]`

| set() method sets ownership to the pointer, passed. This method is needed when the class is created with a default constructor. Returns false in case the class is non-empty.

## Field Documentation

template<class T>
T* OsclExclusiveArrayPtr< T >::_Ptr`[protected]`

The documentation for this class was generated from the following file:

- oscl_exclusive_ptr.h