PtexPtr< T > Class Template Reference

Smart-pointer for acquiring and releasing API objects. More...

#include <Ptexture.h>

List of all members.

Public Member Functions

 PtexPtr (T *ptr=0)
 ~PtexPtr ()
 Destructor, calls ptr->release().
 operator T * ()
 Use as pointer value.
T * operator-> ()
 Access members of pointer.
T * get ()
 Get pointer value.
void swap (PtexPtr &p)
 Swap pointer values.
void reset (T *ptr=0)
 Deallocate object pointed to, and optionally set to new value.

Detailed Description

template<class T>
class PtexPtr< T >

Smart-pointer for acquiring and releasing API objects.

All public API objects must be released back to the Ptex library via the release() method. This smart-pointer class can wrap any of the Ptex API objects and will automatically release the object when the pointer goes out of scope. Usage of PtexPtr is optional, but recommended.

Note: for efficiency and safety, PtexPtr is noncopyable. However, ownership can be transferred between PtexPtr instances via the PtexPtr::swap member function.


          Ptex::String error;
          PtexPtr<PtexTexture> inptx(PtexTexture::open(inptxname, error));
          if (!inptx) {
              std::cerr << error << std::endl;
          else {
              // read some data
              inptx->getData(faceid, buffer, stride);

Generated on 14 Dec 2015 for Ptex by  doxygen 1.6.1