Orxonox  0.0.5 Codename: Arcturus
Public Member Functions | Private Attributes | List of all members
orxonox::StrongPtr< T > Class Template Reference

A strong pointer which wraps a pointer to an object and keeps this object alive as long as the strong pointer exists. More...

#include </home/jenkins/workspace/orxonox_doxygen_trunk/src/libraries/core/CorePrereqs.h>

Public Member Functions

 StrongPtr ()
 Constructor: Initializes the strong pointer with a null pointer. More...
 
 StrongPtr (T *pointer)
 Constructor: Initializes the strong pointer with a pointer to an object. More...
 
 StrongPtr (const StrongPtr &other)
 Copy-constructor. More...
 
template<class O >
 StrongPtr (const StrongPtr< O > &other)
 Copy-constructor for strong pointers to objects of another class. More...
 
template<class O >
 StrongPtr (const WeakPtr< O > &other)
 Constructor: Initializes the strong pointer with the pointer that is stored in a WeakPtr. More...
 
 StrongPtr (StrongPtr &&other)
 Move-constructor. More...
 
 ~StrongPtr ()
 Destructor: Decrements the reference counter. More...
 
T * get () const
 Returns the wrapped pointer as T*. More...
 
DestroyablegetBase () const
 Returns the wrapped pointer as Destroyable*. More...
 
 operator bool () const
 Returns true if the pointer is not nullptr. More...
 
 operator T * () const
 Implicitly converts the StrongPtr to a pointer of type T*. More...
 
T & operator* () const
 Overloaded operator, returns a reference to the stored object. More...
 
T * operator-> () const
 Overloaded operator, returns a pointer to the stored object. More...
 
StrongPtroperator= (T *pointer)
 Assigns a new pointer. More...
 
StrongPtroperator= (StrongPtr other)
 Assigns the wrapped pointer of another StrongPtr. More...
 
template<class O >
StrongPtroperator= (const StrongPtr< O > &other)
 Assigns the wrapped pointer of a StrongPtr of another class. More...
 
template<class O >
StrongPtroperator= (const WeakPtr< O > &other)
 Assigns the wrapped pointer of a WeakPtr. More...
 
void reset ()
 Resets the strong pointer (equivalent to assigning a nullptr). More...
 
void swap (StrongPtr &other)
 Swaps the contents of two strong pointers. More...
 

Private Attributes

Destroyablebase_
 The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, StrongPtr couln't be used with forward declarations) More...
 
T * pointer_
 The wrapped pointer to an object of type T. More...
 

Detailed Description

template<class T>
class orxonox::StrongPtr< T >

A strong pointer which wraps a pointer to an object and keeps this object alive as long as the strong pointer exists.

See also
See this description for more information and an example.

Constructor & Destructor Documentation

template<class T>
orxonox::StrongPtr< T >::StrongPtr ( )
inline

Constructor: Initializes the strong pointer with a null pointer.

template<class T>
orxonox::StrongPtr< T >::StrongPtr ( T *  pointer)
inline

Constructor: Initializes the strong pointer with a pointer to an object.

Parameters
pointerThe pointer
template<class T>
orxonox::StrongPtr< T >::StrongPtr ( const StrongPtr< T > &  other)
inline

Copy-constructor.

template<class T>
template<class O >
orxonox::StrongPtr< T >::StrongPtr ( const StrongPtr< O > &  other)
inline

Copy-constructor for strong pointers to objects of another class.

template<class T>
template<class O >
orxonox::StrongPtr< T >::StrongPtr ( const WeakPtr< O > &  other)
inline

Constructor: Initializes the strong pointer with the pointer that is stored in a WeakPtr.

template<class T>
orxonox::StrongPtr< T >::StrongPtr ( StrongPtr< T > &&  other)
inline

Move-constructor.

template<class T>
orxonox::StrongPtr< T >::~StrongPtr ( )
inline

Destructor: Decrements the reference counter.

Member Function Documentation

template<class T>
T* orxonox::StrongPtr< T >::get ( ) const
inline

Returns the wrapped pointer as T*.

template<class T>
Destroyable* orxonox::StrongPtr< T >::getBase ( ) const
inline

Returns the wrapped pointer as Destroyable*.

template<class T>
orxonox::StrongPtr< T >::operator bool ( ) const
inlineexplicit

Returns true if the pointer is not nullptr.

template<class T>
orxonox::StrongPtr< T >::operator T * ( ) const
inline

Implicitly converts the StrongPtr to a pointer of type T*.

template<class T>
T& orxonox::StrongPtr< T >::operator* ( ) const
inline

Overloaded operator, returns a reference to the stored object.

template<class T>
T* orxonox::StrongPtr< T >::operator-> ( ) const
inline

Overloaded operator, returns a pointer to the stored object.

template<class T>
StrongPtr& orxonox::StrongPtr< T >::operator= ( T *  pointer)
inline

Assigns a new pointer.

template<class T>
StrongPtr& orxonox::StrongPtr< T >::operator= ( StrongPtr< T >  other)
inline

Assigns the wrapped pointer of another StrongPtr.

template<class T>
template<class O >
StrongPtr& orxonox::StrongPtr< T >::operator= ( const StrongPtr< O > &  other)
inline

Assigns the wrapped pointer of a StrongPtr of another class.

template<class T>
template<class O >
StrongPtr& orxonox::StrongPtr< T >::operator= ( const WeakPtr< O > &  other)
inline

Assigns the wrapped pointer of a WeakPtr.

template<class T>
void orxonox::StrongPtr< T >::reset ( )
inline

Resets the strong pointer (equivalent to assigning a nullptr).

template<class T>
void orxonox::StrongPtr< T >::swap ( StrongPtr< T > &  other)
inline

Swaps the contents of two strong pointers.

Member Data Documentation

template<class T>
Destroyable* orxonox::StrongPtr< T >::base_
private

The wrapped pointer, casted up to Destroyable (this is needed because with just a T* pointer, StrongPtr couln't be used with forward declarations)

template<class T>
T* orxonox::StrongPtr< T >::pointer_
private

The wrapped pointer to an object of type T.


The documentation for this class was generated from the following files: