All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Types | Public Member Functions | List of all members
blaze::SharedPtr< Type > Class Template Reference

Implementation of a shared pointer handle.The SharedPtr class is a RAII class for resource management similar to the std::tr1::shared_ptr class. However, SharedPtr offers only a limited functionality for the purpose of the physics engine. More...

#include <SharedPtr.h>

Public Types

typedef Type ElementType
 Type of the wrapped element.
 
typedef Type * Pointer
 Pointer return type and type of the underlying pointer.
 
typedef Type & Reference
 Reference return type.
 

Public Member Functions

 SharedPtr ()
 Default constructor for SharedPtr. More...
 
template<typename Other >
 SharedPtr (Other *ptr)
 Binding an object to a shared pointer. More...
 
 SharedPtr (const SharedPtr &ptr)
 Copy constructor for SharedPtr. More...
 
template<typename Other >
 SharedPtr (const SharedPtr< Other > &ptr)
 Conversion constructor from different SharedPtr instances. More...
 
 ~SharedPtr ()
 Destructor for SharedPtr.
 
SharedPtroperator= (const SharedPtr &ptr)
 Copy assignment operator for SharedPtr. More...
 
template<typename Other >
SharedPtroperator= (const SharedPtr< Other > &ptr)
 
template<typename Other >
SharedPtr< Type > & operator= (const SharedPtr< Other > &ptr)
 Assignment operator for different instances of SharedPtr. More...
 
Access operators
Reference operator* () const
 Returns a reference to the bound object. More...
 
Pointer operator-> () const
 Returns a pointer to the bound object. More...
 
Utility functions
void swap (SharedPtr &ptr) throw ()
 Swapping the contents of two shared pointers. More...
 

Private Attributes

Member variables
Pointer ptr_
 Pointer to the bound object.
 
RefCount counter_
 Reference counter.
 

Detailed Description

template<typename Type>
class blaze::SharedPtr< Type >

Implementation of a shared pointer handle.

The SharedPtr class is a RAII class for resource management similar to the std::tr1::shared_ptr class. However, SharedPtr offers only a limited functionality for the purpose of the physics engine.

Constructor & Destructor Documentation

template<typename Type >
blaze::SharedPtr< Type >::SharedPtr ( )
inline

Default constructor for SharedPtr.

A default constructed shared pointer is not bound to any object.

template<typename Type >
template<typename Other >
blaze::SharedPtr< Type >::SharedPtr ( Other *  ptr)
inline

Binding an object to a shared pointer.

Parameters
ptrPointer to the object to be bound to the shared pointer.

This SharedPtr constructor binds the given object to a shared pointer. All shared pointers originating from this shared pointers will refer to the same bound object. If the last shared pointer goes out of scope, the bound object is destroyed.

template<typename Type >
blaze::SharedPtr< Type >::SharedPtr ( const SharedPtr< Type > &  ptr)
inline

Copy constructor for SharedPtr.

Parameters
ptrThe shared pointer to be copied.

The copy constructor creates a new shared pointer bound to the same object as the original shared pointer.

template<typename Type >
template<typename Other >
blaze::SharedPtr< Type >::SharedPtr ( const SharedPtr< Other > &  ptr)
inline

Conversion constructor from different SharedPtr instances.

Parameters
ptrThe shared pointer to be copied.

This constructor creates a new shared pointer bound to the same object as the original shared pointer.

Member Function Documentation

template<typename Type >
SharedPtr< Type >::Reference blaze::SharedPtr< Type >::operator* ( ) const
inline

Returns a reference to the bound object.

Returns
Reference to the bound object.
template<typename Type >
SharedPtr< Type >::Pointer blaze::SharedPtr< Type >::operator-> ( ) const
inline

Returns a pointer to the bound object.

Returns
Pointer to the bound object.
template<typename Type >
SharedPtr< Type > & blaze::SharedPtr< Type >::operator= ( const SharedPtr< Type > &  ptr)
inline

Copy assignment operator for SharedPtr.

Parameters
ptrThe shared pointer to be copied.
Returns
Reference to the assigned shared pointer.

The copy assignment operator binds this shared pointer to the object in the given shared pointer. If this shared pointer is the last reference to the object bound by this shared pointer, the object will be destroyed.

template<typename Type>
template<typename Other >
SharedPtr<Type>& blaze::SharedPtr< Type >::operator= ( const SharedPtr< Other > &  ptr)
inline

Assignment operator for different instances of SharedPtr.

Parameters
ptrThe shared pointer to be copied.
Returns
Reference to the assigned shared pointer.

The copy assignment operator binds this shared pointer to the object in the given shared pointer. If this shared pointer is the last reference to the object bound by this shared pointer, the object will be destroyed.

template<typename Type >
void blaze::SharedPtr< Type >::swap ( SharedPtr< Type > &  ptr) throw ()
inline

Swapping the contents of two shared pointers.

Parameters
ptrThe shared pointer to be swapped.
Returns
void
Exceptions
no-throwguarantee

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