activemq-cpp-3.6.0
decaf::lang::ArrayPointer< T > Class Template Reference

Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the default Reference Counter is used. More...

#include <src/main/decaf/lang/ArrayPointer.h>

Data Structures

struct  ArrayData

Public Types

typedef T * PointerType
typedef T & ReferenceType
typedef const T & ConstReferenceType

Public Member Functions

 ArrayPointer ()
 Default Constructor.
 ArrayPointer (int size)
 Create a new ArrayPointer instance and allocates an internal array that is sized using the passed in size value.
 ArrayPointer (int size, const T &fillWith)
 Create a new ArrayPointer instance and allocates an internal array that is sized using the passed in size value.
 ArrayPointer (const PointerType value, int size)
 Explicit Constructor, creates an ArrayPointer that contains value with a single reference.
 ArrayPointer (const ArrayPointer &value)
 Copy constructor.
virtual ~ArrayPointer ()
void reset (T *value, int size=0)
 Resets the ArrayPointer to hold the new value.
T * release ()
 Releases the Pointer held and resets the internal pointer value to Null.
PointerType get () const
 Gets the real array pointer that is contained within this Pointer.
int length () const
 Returns the current size of the contained array or zero if the array is NULL.
void swap (ArrayPointer &value)
 Exception Safe Swap Function.
ArrayPointer clone () const
 Creates a new ArrayPointer instance that is a clone of the value contained in this ArrayPointer.
ArrayPointeroperator= (const ArrayPointer &right)
 Assigns the value of right to this Pointer and increments the reference Count.
template<typename T1 >
ArrayPointeroperator= (const ArrayPointer< T1 > &right)
ReferenceType operator[] (int index)
 Dereference Operator, returns a reference to the Contained value.
ConstReferenceType operator[] (int index) const
bool operator! () const
template<typename T1 >
bool operator== (const ArrayPointer< T1 > &right) const
template<typename T1 >
bool operator!= (const ArrayPointer< T1 > &right) const

Friends

bool operator== (const ArrayPointer &left, const T *right)
bool operator== (const T *left, const ArrayPointer &right)
bool operator!= (const ArrayPointer &left, const T *right)
bool operator!= (const T *left, const ArrayPointer &right)

Detailed Description

template<typename T>
class decaf::lang::ArrayPointer< T >

Decaf's implementation of a Smart Pointer that is a template on a Type and is Thread Safe if the default Reference Counter is used.

This Pointer type allows for the substitution of different Reference Counter implementations which provide a means of using invasive reference counting if desired using a custom implementation of ReferenceCounter.

The Decaf smart pointer provide comparison operators for comparing Pointer instances in the same manner as normal pointer, except that it does not provide an overload of operators ( <, <=, >, >= ). To allow use of a Pointer in a STL container that requires it, Pointer provides an implementation of std::less.

Since
1.0

Member Typedef Documentation

template<typename T>
typedef const T& decaf::lang::ArrayPointer< T >::ConstReferenceType
template<typename T>
typedef T* decaf::lang::ArrayPointer< T >::PointerType
template<typename T>
typedef T& decaf::lang::ArrayPointer< T >::ReferenceType

Constructor & Destructor Documentation

template<typename T>
decaf::lang::ArrayPointer< T >::ArrayPointer ( )
inline

Default Constructor.

Initialized the contained array pointer to NULL, using the subscript operator results in an exception unless reset to contain a real value.

Referenced by decaf::lang::ArrayPointer< HashMapEntry * >::clone(), and decaf::lang::ArrayPointer< HashMapEntry * >::reset().

template<typename T>
decaf::lang::ArrayPointer< T >::ArrayPointer ( int  size)
inline

Create a new ArrayPointer instance and allocates an internal array that is sized using the passed in size value.

Parameters
sizeThe size of the array to allocate for this ArrayPointer instance.
template<typename T>
decaf::lang::ArrayPointer< T >::ArrayPointer ( int  size,
const T &  fillWith 
)
inline

Create a new ArrayPointer instance and allocates an internal array that is sized using the passed in size value.

The array elements are initialized with the given value.

Parameters
sizeThe size of the array to allocate for this ArrayPointer instance.
fillWithThe value to initialize each element of the newly allocated array with.
template<typename T>
decaf::lang::ArrayPointer< T >::ArrayPointer ( const PointerType  value,
int  size 
)
inlineexplicit

Explicit Constructor, creates an ArrayPointer that contains value with a single reference.

This object now has ownership until a call to release.

Parameters
valueThe pointer to the instance of the array we are taking ownership of.
sizeThe size of the array this object is taking ownership of.
template<typename T>
decaf::lang::ArrayPointer< T >::ArrayPointer ( const ArrayPointer< T > &  value)
inline

Copy constructor.

Copies the value contained in the ArrayPointer to the new instance and increments the reference counter.

template<typename T>
virtual decaf::lang::ArrayPointer< T >::~ArrayPointer ( )
inlinevirtual

Member Function Documentation

template<typename T>
ArrayPointer decaf::lang::ArrayPointer< T >::clone ( ) const
inline

Creates a new ArrayPointer instance that is a clone of the value contained in this ArrayPointer.

Returns
an ArrayPointer that contains a copy of the data in this ArrayPointer.
template<typename T>
PointerType decaf::lang::ArrayPointer< T >::get ( ) const
inline

Gets the real array pointer that is contained within this Pointer.

This is not really safe since the caller could delete or alter the pointer but it mimics the STL auto_ptr and gives access in cases where the caller absolutely needs the real Pointer. Use at your own risk.

Returns
the contained pointer.

Referenced by decaf::lang::ArrayPointer< HashMapEntry * >::clone(), decaf::lang::ArrayPointerComparator< T >::compare(), decaf::lang::ArrayPointer< HashMapEntry * >::operator!=(), decaf::lang::operator!=(), decaf::lang::ArrayPointerComparator< T >::operator()(), std::less< decaf::lang::ArrayPointer< T > >::operator()(), decaf::lang::ArrayPointer< HashMapEntry * >::operator==(), and decaf::lang::operator==().

template<typename T>
bool decaf::lang::ArrayPointer< T >::operator! ( ) const
inline
template<typename T>
template<typename T1 >
bool decaf::lang::ArrayPointer< T >::operator!= ( const ArrayPointer< T1 > &  right) const
inline
template<typename T>
ArrayPointer& decaf::lang::ArrayPointer< T >::operator= ( const ArrayPointer< T > &  right)
inline

Assigns the value of right to this Pointer and increments the reference Count.

Parameters
right- Pointer on the right hand side of an operator= call to this.
template<typename T>
template<typename T1 >
ArrayPointer& decaf::lang::ArrayPointer< T >::operator= ( const ArrayPointer< T1 > &  right)
inline
template<typename T>
template<typename T1 >
bool decaf::lang::ArrayPointer< T >::operator== ( const ArrayPointer< T1 > &  right) const
inline
template<typename T>
ReferenceType decaf::lang::ArrayPointer< T >::operator[] ( int  index)
inline

Dereference Operator, returns a reference to the Contained value.

This method throws an NullPointerException if the contained value is NULL.

Returns
reference to the contained pointer.
Exceptions
NullPointerExceptionif the contained value is Null
template<typename T>
ConstReferenceType decaf::lang::ArrayPointer< T >::operator[] ( int  index) const
inline
template<typename T>
T* decaf::lang::ArrayPointer< T >::release ( )
inline

Releases the Pointer held and resets the internal pointer value to Null.

This method is not guaranteed to be safe if the Pointer is held by more than one object or this method is called from more than one thread.

Parameters
value- The new value to contain.
Returns
The pointer instance that was held by this Pointer object, the pointer is no longer owned by this Pointer and won't be freed when this Pointer goes out of scope.
template<typename T>
void decaf::lang::ArrayPointer< T >::reset ( T *  value,
int  size = 0 
)
inline

Resets the ArrayPointer to hold the new value.

Before the new value is stored reset checks if the old value should be destroyed and if so calls delete. Call reset with a value of NULL is supported and acts to set this Pointer to a NULL pointer.

Parameters
valueThe new array pointer value to contain.
sizeThe size of the new array value this object now contains.
template<typename T>
void decaf::lang::ArrayPointer< T >::swap ( ArrayPointer< T > &  value)
inline

Exception Safe Swap Function.

Parameters
value- the value to swap with this.

Referenced by decaf::lang::ArrayPointer< HashMapEntry * >::operator=(), and decaf::lang::ArrayPointer< HashMapEntry * >::swap().

Friends And Related Function Documentation

template<typename T>
bool operator!= ( const ArrayPointer< T > &  left,
const T *  right 
)
friend
template<typename T>
bool operator!= ( const T *  left,
const ArrayPointer< T > &  right 
)
friend
template<typename T>
bool operator== ( const ArrayPointer< T > &  left,
const T *  right 
)
friend
template<typename T>
bool operator== ( const T *  left,
const ArrayPointer< T > &  right 
)
friend

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