decaf::lang::Pointer< 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/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) |
Detailed Description
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
class decaf::lang::Pointer< 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>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
Constructor & Destructor Documentation
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
Explicit Constructor, creates a Pointer that contains value with a single reference.
This object now has ownership until a call to release.
- Parameters:
-
| value | - The instance of the type we are containing here. |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
Copy constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter.
- Parameters:
-
| value | Another instance of a Pointer<T> that this Pointer will copy. |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
Copy constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter.
- Parameters:
-
| value | A different but compatible Pointer instance that this Pointer will copy. |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
Static Cast constructor.
Copies the value contained in the pointer to the new instance and increments the reference counter performing a static cast on the value contained in the source Pointer object.
- Parameters:
-
| value | Pointer instance to cast to this type using a static_cast. |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
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.
- Parameters:
-
| value | Pointer instance to cast to this type using a dynamic_cast. |
- Exceptions:
-
| ClassCastException | if the dynamic cast returns NULL |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
Member Function Documentation
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 >
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
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:
-
| NullPointerException | if the contained value is Null |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
Indirection Operator, returns a pointer to the Contained value.
This method throws an NullPointerException if the contained value is NULL.
- Returns:
- reference to the contained pointer.
- Exceptions:
-
| NullPointerException | if the contained value is Null |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 , typename R1 >
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
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 >
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
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.
- Parameters:
-
| 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< E, Set< E > *, HASHCODE >::entrySet(), decaf::util::concurrent::ConcurrentStlMap< Pointer< ProducerId >, Pointer< ProducerState >, ProducerId::COMPARATOR >::entrySet(), decaf::util::StlMap< std::string, cms::Topic * >::keySet(), decaf::util::HashMap< E, Set< E > *, 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< E, Set< E > *, 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().
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
template<typename T1 >
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
Exception Safe Swap Function.
- Parameters:
-
| 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().
Friends And Related Function Documentation
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
| bool operator!= |
( |
const T * |
left, |
|
|
const Pointer< T, REFCOUNTER > & |
right | |
|
) |
| | [friend] |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
| bool operator!= |
( |
const Pointer< T, REFCOUNTER > & |
left, |
|
|
const T * |
right | |
|
) |
| | [friend] |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
| bool operator== |
( |
const T * |
left, |
|
|
const Pointer< T, REFCOUNTER > & |
right | |
|
) |
| | [friend] |
template<typename T, typename REFCOUNTER = decaf::util::concurrent::atomic::AtomicRefCounter>
| bool operator== |
( |
const Pointer< T, REFCOUNTER > & |
left, |
|
|
const T * |
right | |
|
) |
| | [friend] |
The documentation for this class was generated from the following file: