activemq-cpp-3.6.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) | |
Copy constructor. | |
template<typename T1 , typename R1 > | |
Pointer (const Pointer< T1, R1 > &value) | |
Copy constructor. | |
template<typename T1 , typename R1 > | |
Pointer (const Pointer< T1, R1 > &value, const STATIC_CAST_TOKEN &) | |
Static Cast constructor. | |
template<typename T1 , typename R1 > | |
Pointer (const Pointer< T1, R1 > &value, const DYNAMIC_CAST_TOKEN &) | |
Dynamic Cast constructor. | |
virtual | ~Pointer () |
void | reset (T *value=NULL) |
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) |
Exception Safe Swap Function. | |
Pointer & | operator= (const Pointer &right) |
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) |
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 |
|
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().
|
inlineexplicit |
Explicit Constructor, creates a Pointer that contains value with a single reference.
This object now has ownership until a call to release.
value | - The instance of the type we are containing here. |
|
inline |
Copy constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter.
value | Another instance of a Pointer<T> that this Pointer will copy. |
|
inline |
|
inline |
|
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 using a dynamic_cast. |
ClassCastException | if the dynamic cast returns NULL |
|
inlinevirtual |
|
inline |
|
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::Pointer< TransactionId >::operator!=(), decaf::lang::operator!=(), std::less< decaf::lang::Pointer< T > >::operator()(), decaf::lang::Pointer< TransactionId >::operator==(), decaf::lang::operator==(), decaf::util::concurrent::LinkedBlockingQueue< Pointer< Transport > >::peek(), and decaf::util::concurrent::ExecutorService::submit().
|
inline |
|
inline |
|
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 |
|
inline |
|
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 |
|
inline |
|
inline |
|
inline |
|
inline |
|
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.
Referenced by decaf::lang::Pointer< TransactionId >::Pointer(), and decaf::util::concurrent::ExecutorService::submit().
|
inline |
Resets the Pointer 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 value to contain or NULL to empty the pointer (default NULL if not set). |
Referenced by decaf::util::concurrent::CopyOnWriteArrayList< E >::CopyOnWriteArrayList(), decaf::util::StlMap< std::string, cms::Topic * >::entrySet(), decaf::util::HashMap< K, V, HASHCODE >::entrySet(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::entrySet(), decaf::util::StlMap< std::string, cms::Topic * >::keySet(), decaf::util::HashMap< K, V, HASHCODE >::keySet(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::keySet(), decaf::util::concurrent::CopyOnWriteArrayList< E >::removeAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::removeAt(), decaf::util::concurrent::CopyOnWriteArrayList< E >::retainAll(), decaf::util::StlMap< std::string, cms::Topic * >::values(), decaf::util::HashMap< K, V, HASHCODE >::values(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::values(), decaf::util::concurrent::CopyOnWriteArrayList< E >::ArrayListIterator::~ArrayListIterator(), and decaf::util::concurrent::CopyOnWriteArrayList< E >::~CopyOnWriteArrayList().
|
inline |
|
inline |
Exception Safe Swap Function.
value | The value to swap with this Pointer. |
Referenced by decaf::util::concurrent::CopyOnWriteArrayList< E >::add(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addAllAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< E >::addIfAbsent(), decaf::util::concurrent::CopyOnWriteArrayList< E >::clear(), decaf::util::concurrent::CopyOnWriteArrayList< E >::CopyOnWriteArrayList(), decaf::lang::Pointer< TransactionId >::operator=(), decaf::util::concurrent::CopyOnWriteArrayList< E >::removeAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::removeAt(), decaf::util::concurrent::CopyOnWriteArrayList< E >::retainAll(), decaf::util::concurrent::CopyOnWriteArrayList< E >::set(), and decaf::lang::Pointer< TransactionId >::swap().
|
friend |
|
friend |
|
friend |
|
friend |