activemq-cpp-3.3.0

decaf::lang::ArrayPointer< T, REFCOUNTER > 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
typedef REFCOUNTER CounterType

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) throw ()
 Copy constructor.
virtual ~ArrayPointer () throw ()
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) throw ()
 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) throw ()
 Assigns the value of right to this Pointer and increments the reference Count.
template<typename T1 , typename R1 >
ArrayPointeroperator= (const ArrayPointer< T1, R1 > &right) throw ()
ReferenceType operator[] (int index)
 Dereference Operator, returns a reference to the Contained value.
ConstReferenceType operator[] (int index) const
bool operator! () const
template<typename T1 , typename R1 >
bool operator== (const ArrayPointer< T1, R1 > &right) const
template<typename T1 , typename R1 >
bool operator!= (const ArrayPointer< T1, R1 > &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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
class decaf::lang::ArrayPointer< T, REFCOUNTER >

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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
typedef const T& decaf::lang::ArrayPointer< T, REFCOUNTER >::ConstReferenceType
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
typedef REFCOUNTER decaf::lang::ArrayPointer< T, REFCOUNTER >::CounterType
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
typedef T* decaf::lang::ArrayPointer< T, REFCOUNTER >::PointerType
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
typedef T& decaf::lang::ArrayPointer< T, REFCOUNTER >::ReferenceType

Constructor & Destructor Documentation

template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
decaf::lang::ArrayPointer< T, REFCOUNTER >::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< decaf::util::LinkedList< Pointer< MessageDispatch > > >::clone(), and decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::reset().

template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
decaf::lang::ArrayPointer< T, REFCOUNTER >::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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
decaf::lang::ArrayPointer< T, REFCOUNTER >::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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
decaf::lang::ArrayPointer< T, REFCOUNTER >::ArrayPointer ( const PointerType  value,
int  size 
) [inline, explicit]

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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
decaf::lang::ArrayPointer< T, REFCOUNTER >::ArrayPointer ( const ArrayPointer< T, REFCOUNTER > &  value) throw () [inline]

Copy constructor.

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

template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
virtual decaf::lang::ArrayPointer< T, REFCOUNTER >::~ArrayPointer ( ) throw () [inline, virtual]

Member Function Documentation

template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
ArrayPointer decaf::lang::ArrayPointer< T, REFCOUNTER >::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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
PointerType decaf::lang::ArrayPointer< T, REFCOUNTER >::get ( ) const [inline]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
bool decaf::lang::ArrayPointer< T, REFCOUNTER >::operator! ( ) const [inline]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
bool decaf::lang::ArrayPointer< T, REFCOUNTER >::operator!= ( const ArrayPointer< T1, R1 > &  right) const [inline]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
ArrayPointer& decaf::lang::ArrayPointer< T, REFCOUNTER >::operator= ( const ArrayPointer< T1, R1 > &  right) throw () [inline]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
ArrayPointer& decaf::lang::ArrayPointer< T, REFCOUNTER >::operator= ( const ArrayPointer< T, REFCOUNTER > &  right) throw () [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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
bool decaf::lang::ArrayPointer< T, REFCOUNTER >::operator== ( const ArrayPointer< T1, R1 > &  right) const [inline]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
ReferenceType decaf::lang::ArrayPointer< T, REFCOUNTER >::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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
ConstReferenceType decaf::lang::ArrayPointer< T, REFCOUNTER >::operator[] ( int  index) const [inline]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
T* decaf::lang::ArrayPointer< T, REFCOUNTER >::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.

Referenced by decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::ArrayPointer().

template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
void decaf::lang::ArrayPointer< T, REFCOUNTER >::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, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
void decaf::lang::ArrayPointer< T, REFCOUNTER >::swap ( ArrayPointer< T, REFCOUNTER > &  value) throw () [inline]

Friends And Related Function Documentation

template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
bool operator!= ( const ArrayPointer< T, REFCOUNTER > &  left,
const T *  right 
) [friend]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
bool operator!= ( const T *  left,
const ArrayPointer< T, REFCOUNTER > &  right 
) [friend]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
bool operator== ( const ArrayPointer< T, REFCOUNTER > &  left,
const T *  right 
) [friend]
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
bool operator== ( const T *  left,
const ArrayPointer< T, REFCOUNTER > &  right 
) [friend]

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