FBX C++ API Reference
FbxAutoPtr< Type, Policy > Class Template Reference

#include <fbxalloc.h>

Class Description

template<class Type, class Policy = FbxDeletionPolicyDefault<Type>>
class FbxAutoPtr< Type, Policy >

FbxAutoPtr mimics the auto_ptr class template implementation available in the C++ Standard Library.

The auto_ptr template class describes an object that stores a pointer to a single allocated object of type Type* that ensures that the object to which it points gets destroyed automatically when control leaves a scope.

Examples:
ViewScene/SceneContext.cxx.

Definition at line 190 of file fbxalloc.h.

Public Member Functions

 FbxAutoPtr (Type *pPtr=0)
 Construct from a pointer. More...
 
 ~FbxAutoPtr ()
 Destructor. More...
 
Type * Get () const
 Retrieve the pointer it holds. More...
 
Type * operator-> () const
 Member access operator. More...
 
 operator Type * () const
 Convert to a Type pointer. More...
 
Type & operator* () const
 Dereference operator. More...
 
bool operator! () const
 Logical not operator. More...
 
 operator bool () const
 Convert to boolean value. More...
 
void Reset (Type *pPtr=0)
 Reset the scoped pointer by swapping with another pointer. More...
 
void Swap (FbxAutoPtr &pOther)
 Swap with another pointer. More...
 
Type * Release ()
 Release the pointer, so that it won't perform deletion in its destruction. More...
 

Constructor & Destructor Documentation

◆ FbxAutoPtr()

FbxAutoPtr ( Type *  pPtr = 0)
inlineexplicit

Construct from a pointer.

Definition at line 194 of file fbxalloc.h.

194 : mPtr(pPtr){}

◆ ~FbxAutoPtr()

~FbxAutoPtr ( )
inline

Destructor.

Definition at line 197 of file fbxalloc.h.

197 { Policy::DeleteIt(&mPtr); }

Member Function Documentation

◆ Get()

Type* Get ( ) const
inline

Retrieve the pointer it holds.

Definition at line 200 of file fbxalloc.h.

200 { return mPtr; }

◆ operator->()

Type* operator-> ( ) const
inline

Member access operator.

Definition at line 203 of file fbxalloc.h.

203 { return mPtr; }

◆ operator Type *()

operator Type * ( ) const
inline

Convert to a Type pointer.

Definition at line 206 of file fbxalloc.h.

206 { return mPtr; }

◆ operator*()

Type& operator* ( ) const
inline

Dereference operator.

Definition at line 209 of file fbxalloc.h.

209 { return *mPtr; }

◆ operator!()

bool operator! ( ) const
inline

Logical not operator.

Definition at line 212 of file fbxalloc.h.

212 { return mPtr == 0; }

◆ operator bool()

operator bool ( ) const
inline

Convert to boolean value.

Definition at line 215 of file fbxalloc.h.

215 { return mPtr != 0; }

◆ Reset()

void Reset ( Type *  pPtr = 0)
inline

Reset the scoped pointer by swapping with another pointer.

Definition at line 218 of file fbxalloc.h.

219  {
220  FBX_ASSERT(pPtr == 0 || pPtr != mPtr); //Catch self-reset errors
221  FbxAutoPtr<Type, Policy>(pPtr).Swap(*this);
222  }
FbxAutoPtr mimics the auto_ptr class template implementation available in the C++ Standard Library...
Definition: fbxalloc.h:190
void Swap(FbxAutoPtr &pOther)
Swap with another pointer.
Definition: fbxalloc.h:225

◆ Swap()

void Swap ( FbxAutoPtr< Type, Policy > &  pOther)
inline

Swap with another pointer.

Definition at line 225 of file fbxalloc.h.

226  {
227  Type* TmpPtr = pOther.mPtr;
228  pOther.mPtr = mPtr;
229  mPtr = TmpPtr;
230  }

◆ Release()

Type* Release ( )
inline

Release the pointer, so that it won't perform deletion in its destruction.

Definition at line 233 of file fbxalloc.h.

234  {
235  Type* TmpPtr = mPtr;
236  mPtr = NULL;
237  return TmpPtr;
238  }
#define NULL
Definition: fbxarch.h:210

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