Ptex

Public Member Functions | Private Member Functions | Private Attributes | List of all members
PtexPtr< T > Class Template Reference

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

`#include <Ptexture.h>`

## Public Member Functions
| PtexPtr (T *ptr=0)
| Constructor.
| ~PtexPtr ()
| Destructor, calls ptr->release().
| operator T* () const
| Use as pointer value.
T * | operator-> () const
| Access members of pointer.
T * | get () const
| 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.

## Private Member Functions
| PtexPtr (const PtexPtr &p)
| Copying prohibited.
void | operator= (PtexPtr &p)
| Assignment prohibited.

## Private Attributes
T * | _ptr

## 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.

Example:

{
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);
}
}
PtexPtr::PtexPtr
PtexPtr(T *ptr=0)
Constructor.
Definition Ptexture.h:1071
PtexTexture::open
static PtexTexture * open(const char *path, Ptex::String &error, bool premultiply=0)
Open a ptex file for reading.
Definition PtexReader.cpp:61
Ptex::String
Memory-managed string.
Definition Ptexture.h:299

Definition at line 1067 of file Ptexture.h.

## Constructor & Destructor Documentation

## ◆ PtexPtr() [1/2]

template<class T>

PtexPtr< T >::PtexPtr | ( | T * | ptr = 0 | ) |
| inline

Constructor.

Definition at line 1071 of file Ptexture.h.

References _ptr.

Referenced by operator=(), PtexPtr(), and swap().

## ◆ ~PtexPtr()

template<class T>

PtexPtr< T >::~PtexPtr | ( |  | ) |
| inline

Destructor, calls ptr->release().

Definition at line 1074 of file Ptexture.h.

References _ptr.

## ◆ PtexPtr() [2/2]

template<class T>

PtexPtr< T >::PtexPtr | ( | const PtexPtr< T > & | p | ) |
| private

Copying prohibited.

References PtexPtr().

## Member Function Documentation

## ◆ get()

template<class T>

T * PtexPtr< T >::get | ( |  | ) | const
| inline

Get pointer value.

Definition at line 1083 of file Ptexture.h.

References _ptr.

Referenced by PtexReader::getData().

## ◆ operator T*()

template<class T>

PtexPtr< T >::operator T* | ( |  | ) | const
| inline

Use as pointer value.

Definition at line 1077 of file Ptexture.h.

References _ptr.

## ◆ operator->()

template<class T>

T * PtexPtr< T >::operator-> | ( |  | ) | const
| inline

Access members of pointer.

Definition at line 1080 of file Ptexture.h.

References _ptr.

## ◆ operator=()

template<class T>

void PtexPtr< T >::operator= | ( | PtexPtr< T > & | p | ) |
| private

Assignment prohibited.

References PtexPtr().

## ◆ reset()

template<class T>

void PtexPtr< T >::reset | ( | T * | ptr = 0 | ) |
| inline

Deallocate object pointed to, and optionally set to new value.

Definition at line 1094 of file Ptexture.h.

References _ptr.

## ◆ swap()

template<class T>

void PtexPtr< T >::swap | ( | PtexPtr< T > & | p | ) |
| inline

Swap pointer values.

Definition at line 1086 of file Ptexture.h.

References _ptr, and PtexPtr().

## Member Data Documentation

## ◆ _ptr

template<class T>

T* PtexPtr< T >::_ptr
| private

Definition at line 1068 of file Ptexture.h.

Referenced by get(), operator T*(), operator->(), PtexPtr(), reset(), swap(), and ~PtexPtr().

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

- Ptexture.h