Caelum::OwnedPtr< PointedT, TraitsT > Class Template Reference

Template for smart pointers with strict unique ownership. More...

#include <OwnedPtr.h>

List of all members.

Public Member Functions

void reset (const InnerPointerType &newInner=TraitsT::getNullValue())
 Change the inner value.
 OwnedPtr ()
 Constructor; always initialize to 0.
 ~OwnedPtr ()
 Non-virtual destructor (don't derive from this).
 OwnedPtr (OwnedPtr &rhs)
 Copy constructor; clears right-hand-side.
const OwnedPtroperator= (OwnedPtr &rhs)
 Assignment.
bool isNull () const
 Check if this is null.
void setNull ()
 Set to null and destroy contents (if any).
PointedT * getPointer () const
PointedT * get () const
PointedT * operator-> () const
PointedT & operator* () const


Detailed Description

template<class PointedT, typename TraitsT = DefaultOwnedPtrTraits<PointedT>>
class Caelum::OwnedPtr< PointedT, TraitsT >

Template for smart pointers with strict unique ownership.

A lot of objects in Ogre are created and destroyed through other "Manager" objects. Even though the memory for such objects is never actually leaked better lifetime control is frequently useful.

OwnedPtr is very similar in behaviour to std::auto_ptr but tries to mimic Ogre::SharedPtr method names. Only one OwnedPtr must exist to a certain object at any one time. Assignment and copy construction will in fact pass away ownership and set the original OwnedPtr to null.

This very limited functionality makes OwnedPtr very efficient; it should have no overhead compared to doing the same thing manually.

OwnedPtr supports customization through a static traits class which can customize what happens when the OwnedPtr is destroyed. This makes it possible to use OwnedPtr classes for fine control over the lifetime of objects which are otherwise managed by an external class.

See also:
DefaultOwnedPtrTraits

Definition at line 81 of file OwnedPtr.h.


Member Function Documentation

template<class PointedT, typename TraitsT = DefaultOwnedPtrTraits<PointedT>>
void Caelum::OwnedPtr< PointedT, TraitsT >::reset ( const InnerPointerType &  newInner = TraitsT::getNullValue()  )  [inline]


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

Generated on Mon Jan 19 09:15:32 2009 for Caelum by  doxygen 1.5.6