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/Pointer.h>
Public Types | |
typedef T * | PointerType |
typedef T & | ReferenceType |
typedef REFCOUNTER | CounterType |
Public Member Functions | |
Pointer () | |
Default Constructor. | |
Pointer (const PointerType value) | |
Explicit Constructor, creates a Pointer that contains value with a single reference. | |
Pointer (const Pointer &value) throw () | |
Copy constructor. | |
template<typename T1 , typename R1 > | |
Pointer (const Pointer< T1, R1 > &value) throw () | |
Copy constructor. | |
template<typename T1 , typename R1 > | |
Pointer (const Pointer< T1, R1 > &value, const STATIC_CAST_TOKEN &) throw () | |
Static Cast constructor. | |
template<typename T1 , typename R1 > | |
Pointer (const Pointer< T1, R1 > &value, const DYNAMIC_CAST_TOKEN &) | |
Dynamic Cast constructor. | |
virtual | ~Pointer () throw () |
void | reset (T *value) |
Resets the Pointer 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 pointer that is contained within this Pointer. | |
void | swap (Pointer &value) throw () |
Exception Safe Swap Function. | |
Pointer & | operator= (const Pointer &right) throw () |
Assigns the value of right to this Pointer and increments the reference Count. | |
template<typename T1 , typename R1 > | |
Pointer & | operator= (const Pointer< T1, R1 > &right) throw () |
ReferenceType | operator* () |
Dereference Operator, returns a reference to the Contained value. | |
ReferenceType | operator* () const |
PointerType | operator-> () |
Indirection Operator, returns a pointer to the Contained value. | |
PointerType | operator-> () const |
bool | operator! () const |
template<typename T1 , typename R1 > | |
bool | operator== (const Pointer< T1, R1 > &right) const |
template<typename T1 , typename R1 > | |
bool | operator!= (const Pointer< T1, R1 > &right) const |
template<typename T1 > | |
Pointer< T1, CounterType > | dynamicCast () const |
template<typename T1 > | |
Pointer< T1, CounterType > | staticCast () const |
Friends | |
bool | operator== (const Pointer &left, const T *right) |
bool | operator== (const T *left, const Pointer &right) |
bool | operator!= (const Pointer &left, const T *right) |
bool | operator!= (const T *left, const Pointer &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 REFCOUNTER decaf::lang::Pointer< T, REFCOUNTER >::CounterType |
typedef T* decaf::lang::Pointer< T, REFCOUNTER >::PointerType |
typedef T& decaf::lang::Pointer< T, REFCOUNTER >::ReferenceType |
decaf::lang::Pointer< T, REFCOUNTER >::Pointer | ( | ) | [inline] |
Default Constructor.
Initialized the contained pointer to NULL, using the -> operator results in an exception unless reset to contain a real value.
Referenced by decaf::lang::Pointer< TransactionId >::reset().
decaf::lang::Pointer< T, REFCOUNTER >::Pointer | ( | const PointerType | value | ) | [inline, explicit] |
Explicit Constructor, creates a Pointer that contains value with a single reference.
This object now has ownership until a call to release.
value | - instance of the type we are containing here. |
decaf::lang::Pointer< T, REFCOUNTER >::Pointer | ( | const Pointer< T, REFCOUNTER > & | value | ) | throw () [inline] |
Copy constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter.
decaf::lang::Pointer< T, REFCOUNTER >::Pointer | ( | const Pointer< T1, R1 > & | value | ) | throw () [inline] |
Copy constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter.
decaf::lang::Pointer< T, REFCOUNTER >::Pointer | ( | const Pointer< T1, R1 > & | value, |
const STATIC_CAST_TOKEN & | |||
) | throw () [inline] |
decaf::lang::Pointer< T, REFCOUNTER >::Pointer | ( | const Pointer< T1, R1 > & | value, |
const DYNAMIC_CAST_TOKEN & | |||
) | [inline] |
Dynamic Cast constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter performing a dynamic cast on the value contained in the source Pointer object. If the cast fails and return NULL then this method throws a ClassCastException.
value | - Pointer instance to cast to this type. |
ClassCastException | if the dynamic cast returns NULL |
virtual decaf::lang::Pointer< T, REFCOUNTER >::~Pointer | ( | ) | throw () [inline, virtual] |
Pointer<T1, CounterType> decaf::lang::Pointer< T, REFCOUNTER >::dynamicCast | ( | ) | const [inline] |
PointerType decaf::lang::Pointer< T, REFCOUNTER >::get | ( | ) | const [inline] |
Gets the real 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 activemq::commands::ActiveMQMessageTemplate< cms::ObjectMessage >::equals(), activemq::state::ConnectionState::getTransactionState(), decaf::lang::operator!=(), decaf::lang::Pointer< TransactionId >::operator!=(), std::less< decaf::lang::Pointer< T > >::operator()(), decaf::lang::operator==(), decaf::lang::Pointer< TransactionId >::operator==(), decaf::util::concurrent::LinkedBlockingQueue< E >::peek(), activemq::state::CommandVisitorAdapter::processRemoveInfo(), and activemq::state::ConnectionState::removeTempDestination().
bool decaf::lang::Pointer< T, REFCOUNTER >::operator! | ( | ) | const [inline] |
bool decaf::lang::Pointer< T, REFCOUNTER >::operator!= | ( | const Pointer< T1, R1 > & | right | ) | const [inline] |
ReferenceType decaf::lang::Pointer< T, REFCOUNTER >::operator* | ( | ) | const [inline] |
ReferenceType decaf::lang::Pointer< T, REFCOUNTER >::operator* | ( | ) | [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 |
PointerType decaf::lang::Pointer< T, REFCOUNTER >::operator-> | ( | ) | [inline] |
Indirection Operator, returns a pointer to the Contained value.
This method throws an NullPointerException if the contained value is NULL.
NullPointerException | if the contained value is Null |
PointerType decaf::lang::Pointer< T, REFCOUNTER >::operator-> | ( | ) | const [inline] |
Pointer& decaf::lang::Pointer< T, REFCOUNTER >::operator= | ( | const Pointer< T, REFCOUNTER > & | right | ) | throw () [inline] |
Pointer& decaf::lang::Pointer< T, REFCOUNTER >::operator= | ( | const Pointer< T1, R1 > & | right | ) | throw () [inline] |
bool decaf::lang::Pointer< T, REFCOUNTER >::operator== | ( | const Pointer< T1, R1 > & | right | ) | const [inline] |
T* decaf::lang::Pointer< 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::Pointer< TransactionId >::Pointer().
void decaf::lang::Pointer< T, REFCOUNTER >::reset | ( | T * | value | ) | [inline] |
Pointer<T1, CounterType> decaf::lang::Pointer< T, REFCOUNTER >::staticCast | ( | ) | const [inline] |
void decaf::lang::Pointer< T, REFCOUNTER >::swap | ( | Pointer< T, REFCOUNTER > & | value | ) | throw () [inline] |
Exception Safe Swap Function.
value | - the value to swap with this. |
Referenced by decaf::lang::Pointer< TransactionId >::operator=(), and decaf::lang::Pointer< TransactionId >::swap().
bool operator!= | ( | const Pointer< T, REFCOUNTER > & | left, |
const T * | right | ||
) | [friend] |
bool operator!= | ( | const T * | left, |
const Pointer< T, REFCOUNTER > & | right | ||
) | [friend] |
bool operator== | ( | const Pointer< T, REFCOUNTER > & | left, |
const T * | right | ||
) | [friend] |
bool operator== | ( | const T * | left, |
const Pointer< T, REFCOUNTER > & | right | ||
) | [friend] |