OPtr - "owning" smart pointer used for newly created FObjects. More...
#include <funknown.h>
Public Member Functions | |
OPtr (I *p) | |
OPtr (const IPtr< I > &p) | |
OPtr (const OPtr< I > &p) | |
OPtr () | |
I * | operator= (I *_ptr) |
OPtr - "owning" smart pointer used for newly created FObjects.
FUnknown implementations are supposed to have a refCount of 1 right after creation. So using an IPtr on newly created objects would lead to a leak. Instead the OPtr can be used in this case.
Example:
OPtr<IPath> path = FHostCreate (IPath, hostClasses);
// no release is needed...
The assignment operator takes ownership of a new object and releases the old. So its safe to write:
OPtr<IPath> path = FHostCreate (IPath, hostClasses); path = FHostCreate (IPath, hostClasses); path = 0;
This is the difference to using an IPtr with addRef=false.
// DONT DO THIS: IPtr<IPath> path (FHostCreate (IPath, hostClasses), false); path = FHostCreate (IPath, hostClasses); path = 0;
This will lead to a leak!
OPtr | ( | I * | p | ) | [inline] |
OPtr | ( | ) | [inline] |
I* operator= | ( | I * | _ptr | ) | [inline] |
Reimplemented from IPtr< I >.