mudbox::Instance< c > Class Template Reference

#include <kernel.h>

List of all members.


Detailed Description

template<typename c>
class mudbox::Instance< c >

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
    }

Public Member Functions

  Instance (void)
  ~Instance (void)
c *  operator-> (void)
const c *  operator-> (void) const
  operator c * (void)

Constructor & Destructor Documentation

template<typename c>
mudbox::Instance< c >::Instance void   )  [inline]
 
00674 { m_pObject = CreateInstance<c>(); };
template<typename c>
mudbox::Instance< c >::~Instance void   )  [inline]
 
00675 { delete m_pObject; };

Member Function Documentation

template<typename c>
c* mudbox::Instance< c >::operator-> void   )  [inline]
 
00676 { return m_pObject; };
template<typename c>
const c* mudbox::Instance< c >::operator-> void   )  const [inline]
 
00677 { return m_pObject; };
template<typename c>
mudbox::Instance< c >::operator c * void   )  [inline]
 
00678 { return m_pObject; };