This is a helper class to manage class instances implemented in plugins, provided for convenience.
The following two are equal:
{
Image *pMyImage = CreateInstance<Image>();
pMyImage->DoSomething();
delete pMyImage;
}
and
{ Instance<Image> pMyImage; pMyImage->DoSomething(); }
In the second case, the target object will be automatically deleted when the block ends. You can also use this class to define member variables in your classes. This way when the owner class is constructed, the instances of the needed classes will be created, and when the object destructed, those instances will be removed from the memory too. For example:
class MyClass { Instance<Image> m_pSourceImage, m_pDestinationImage; public: // member functions which work with the two images }
You can also create an Instance with an existing object. For example:
Node* pNode = CreateInstance<Node>(); Instance<Node> cInstance(pNode);
Here, cInstance takes ownership of pNode, and will delete it when cInstance goes out of scope.
#include <kernel.h>
Public Member Functions |
|
Instance (c *pObject) | |
Instance (void) | |
~Instance (void) | |
c * | operator-> (void) |
const c * | operator-> (void) const |
operator c * (void) const | |
c * | Release () |
Take ownership of m_pObject. |
Instance | ( | c * | pObject | ) | [inline] |
Instance | ( | void | ) | [inline] |
~Instance | ( | void | ) | [inline] |
const c* operator-> | ( | void | ) | const [inline] |
operator c * | ( | void | ) | const [inline] |
c* Release | ( | ) | [inline] |