#include <OwnedPtr.h>
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 OwnedPtr & | operator= (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 |
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.
Definition at line 81 of file OwnedPtr.h.
void Caelum::OwnedPtr< PointedT, TraitsT >::reset | ( | const InnerPointerType & | newInner = TraitsT::getNullValue() |
) | [inline] |
Change the inner value.
This will destroy the old value and gain ownership of the new value.
Definition at line 94 of file OwnedPtr.h.
Referenced by Caelum::FlatCloudLayer::_ensureGeometry(), Caelum::OwnedPtr< Ogre::Material, Caelum::OwnedResourcePtrTraits< Ogre::Material, Ogre::MaterialPtr, Ogre::MaterialManager > >::operator=(), Caelum::OwnedPtr< Ogre::Material, Caelum::OwnedResourcePtrTraits< Ogre::Material, Ogre::MaterialPtr, Ogre::MaterialManager > >::OwnedPtr(), and Caelum::PointStarfield::PointStarfield().