activemq-cpp-3.3.0
|
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. | |
ArrayPointer & | operator= (const ArrayPointer &right) throw () |
Assigns the value of right to this Pointer and increments the reference Count. | |
template<typename T1 , typename R1 > | |
ArrayPointer & | operator= (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) |
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.
typedef const T& decaf::lang::ArrayPointer< T, REFCOUNTER >::ConstReferenceType |
typedef REFCOUNTER decaf::lang::ArrayPointer< T, REFCOUNTER >::CounterType |
typedef T* decaf::lang::ArrayPointer< T, REFCOUNTER >::PointerType |
typedef T& decaf::lang::ArrayPointer< T, REFCOUNTER >::ReferenceType |
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().
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.
size | The size of the array to allocate for this ArrayPointer instance. |
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.
size | The size of the array to allocate for this ArrayPointer instance. |
fillWith | The value to initialize each element of the newly allocated array with. |
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.
value | The pointer to the instance of the array we are taking ownership of. |
size | The size of the array this object is taking ownership of. |
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.
virtual decaf::lang::ArrayPointer< T, REFCOUNTER >::~ArrayPointer | ( | ) | throw () [inline, virtual] |
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.
PointerType decaf::lang::ArrayPointer< T, REFCOUNTER >::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.
Referenced by decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::add(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::addAll(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::addAllAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::addIfAbsent(), decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::clone(), decaf::lang::ArrayPointerComparator< T, R >::compare(), decaf::lang::operator!=(), decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::operator!=(), std::less< decaf::lang::ArrayPointer< T > >::operator()(), decaf::lang::ArrayPointerComparator< T, R >::operator()(), decaf::lang::operator==(), decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::operator==(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::removeAll(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::removeAt(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::retainAll(), and decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::set().
int decaf::lang::ArrayPointer< T, REFCOUNTER >::length | ( | ) | const [inline] |
Returns the current size of the contained array or zero if the array is NULL.
Referenced by decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::add(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::addAll(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::addAllAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::addIfAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< E >::ArrayListIterator::ArrayListIterator(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::contains(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::get(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::indexOf(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::lastIndexOf(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::removeAll(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::removeAt(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::retainAll(), decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::set(), and decaf::util::concurrent::CopyOnWriteArrayList< ServiceListener * >::toArray().
bool decaf::lang::ArrayPointer< T, REFCOUNTER >::operator! | ( | ) | const [inline] |
bool decaf::lang::ArrayPointer< T, REFCOUNTER >::operator!= | ( | const ArrayPointer< T1, R1 > & | right | ) | const [inline] |
ArrayPointer& decaf::lang::ArrayPointer< T, REFCOUNTER >::operator= | ( | const ArrayPointer< T1, R1 > & | right | ) | throw () [inline] |
ArrayPointer& decaf::lang::ArrayPointer< T, REFCOUNTER >::operator= | ( | const ArrayPointer< T, REFCOUNTER > & | right | ) | throw () [inline] |
bool decaf::lang::ArrayPointer< T, REFCOUNTER >::operator== | ( | const ArrayPointer< T1, R1 > & | right | ) | const [inline] |
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.
NullPointerException | if the contained value is Null |
ConstReferenceType decaf::lang::ArrayPointer< T, REFCOUNTER >::operator[] | ( | int | index | ) | const [inline] |
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.
value | - The new value to contain. |
Referenced by decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::ArrayPointer().
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.
value | The new array pointer value to contain. |
size | The size of the new array value this object now contains. |
void decaf::lang::ArrayPointer< T, REFCOUNTER >::swap | ( | ArrayPointer< T, REFCOUNTER > & | value | ) | throw () [inline] |
Exception Safe Swap Function.
value | - the value to swap with this. |
Referenced by decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::operator=(), and decaf::lang::ArrayPointer< decaf::util::LinkedList< Pointer< MessageDispatch > > >::swap().
bool operator!= | ( | const ArrayPointer< T, REFCOUNTER > & | left, |
const T * | right | ||
) | [friend] |
bool operator!= | ( | const T * | left, |
const ArrayPointer< T, REFCOUNTER > & | right | ||
) | [friend] |
bool operator== | ( | const ArrayPointer< T, REFCOUNTER > & | left, |
const T * | right | ||
) | [friend] |
bool operator== | ( | const T * | left, |
const ArrayPointer< T, REFCOUNTER > & | right | ||
) | [friend] |