Base Framework
Public Member Functions | List of all members
ProtectedReference< TYPE > Class Template Reference

Automation pointer that counts the number of references to an object. More...

#include <base/mem/ProtectedReference.h>

Public Member Functions

 ProtectedReference (TYPE *_value)
 
 ProtectedReference (const ProtectedReference &copy) noexcept
 
template<class POLY >
 ProtectedReference (const ProtectedReference< POLY > &copy)
 
template<class POLY >
ProtectedReference< POLY > cast ()
 
template<class POLY >
const ProtectedReference< POLY > cast () const
 
ProtectedReferenceoperator= (const ProtectedReference &assign)
 
template<class POLY >
ProtectedReferenceoperator= (const ProtectedReference< POLY > &assign)
 
bool operator== (const ProtectedReference &compare) const noexcept
 
bool operator!= (const ProtectedReference &compare) const noexcept
 
bool isMultiReferenced () const noexcept
 
void copyOnWrite ()
 
TYPE * operator-> () noexcept
 
const TYPE * operator-> () const noexcept
 
 ~ProtectedReference ()
 

Detailed Description

template<class TYPE>
class ProtectedReference< TYPE >

Automation pointer that counts the number of references to an object.

Automation pointer for reference counting objects. This class is responsible for counting the total number of references to an object. The pointer automatically deletes a reference counted object when the number of references reaches zero. This pointer can only be used to reference count objects of type ReferenceCountedObject but is faster than ReferenceCounter. The ProtectedReference class is relocateable.

See also
ReferenceCountedObject ReferenceCounter
Version
1.0

Constructor & Destructor Documentation

◆ ProtectedReference() [1/3]

template<class TYPE >
ProtectedReference< TYPE >::ProtectedReference ( TYPE *  _value)
inline

Initializes an automation pointer with the specified pointer value. The automation pointer may be implicitly initialized. Raises NullPointer is value is invalid.

Parameters
valueThe desired pointer value.

◆ ProtectedReference() [2/3]

template<class TYPE >
ProtectedReference< TYPE >::ProtectedReference ( const ProtectedReference< TYPE > &  copy)
inlinenoexcept

Initialization of automation pointer from other automation pointer.

◆ ProtectedReference() [3/3]

template<class TYPE >
template<class POLY >
ProtectedReference< TYPE >::ProtectedReference ( const ProtectedReference< POLY > &  copy)
inline

Initialization of automation pointer from other automation pointer using compile time polymorphism.

◆ ~ProtectedReference()

template<class TYPE >
ProtectedReference< TYPE >::~ProtectedReference ( )
inline

Destroys the automation pointer. Raises the exceptions raised by the destructor of the object.

Member Function Documentation

◆ cast() [1/2]

template<class TYPE >
template<class POLY >
ProtectedReference<POLY> ProtectedReference< TYPE >::cast ( )
inline

Dynamic cast. Raises CastException if unable to cast.

◆ cast() [2/2]

template<class TYPE >
template<class POLY >
const ProtectedReference<POLY> ProtectedReference< TYPE >::cast ( ) const
inline

Dynamic cast. Raises CastException if unable to cast.

◆ copyOnWrite()

template<class TYPE >
void ProtectedReference< TYPE >::copyOnWrite ( )
inline

Makes a new copy of the reference counted object if referenced by more than one automation pointer. This member function is invocated by some classes before a object is modified. The reference counted object must implement the default copy constructor for this to work. Raises the exceptions raised by the default copy constructor of the object.

◆ isMultiReferenced()

template<class TYPE >
bool ProtectedReference< TYPE >::isMultiReferenced ( ) const
inlinenoexcept

Returns true if the reference counted object is referenced by more than one automation pointer.

Returns
False if the pointer is invalid (i.e. not pointing to an object).

◆ operator!=()

template<class TYPE >
bool ProtectedReference< TYPE >::operator!= ( const ProtectedReference< TYPE > &  compare) const
inlinenoexcept

Returns true if the references are non-equal.

◆ operator->() [1/2]

template<class TYPE >
const TYPE* ProtectedReference< TYPE >::operator-> ( ) const
inlinenoexcept

Returns the reference counted object for non-modifying access.

◆ operator->() [2/2]

template<class TYPE >
TYPE* ProtectedReference< TYPE >::operator-> ( )
inlinenoexcept

Returns the reference counted object for modifying access.

◆ operator=() [1/2]

template<class TYPE >
ProtectedReference& ProtectedReference< TYPE >::operator= ( const ProtectedReference< TYPE > &  assign)
inline

Assignment of automation pointer to this automation pointer using compile time polymorphism. Raises the exceptions raised by the destructor of the object.

◆ operator=() [2/2]

template<class TYPE >
template<class POLY >
ProtectedReference& ProtectedReference< TYPE >::operator= ( const ProtectedReference< POLY > &  assign)
inline

Assignment of automation pointer to this automation pointer using compile time polymorphism. Raises the exceptions raised by the destructor of the object.

◆ operator==()

template<class TYPE >
bool ProtectedReference< TYPE >::operator== ( const ProtectedReference< TYPE > &  compare) const
inlinenoexcept

Returns true if the references are equal.