Ptex: PtexPtr< T > Class Template Reference

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
Smart-pointer for acquiring and releasing API objects.
Definition: Ptexture.h:1032
PtexTexture::open
static PtexTexture * open(const char *path, Ptex::String &error, bool premultiply=0)
Open a ptex file for reading.
Definition: PtexReader.cpp:59
Ptex::String
Memory-managed string.
Definition: Ptexture.h:296

Definition at line 1032 of file Ptexture.h.

## Constructor & Destructor Documentation

## ◆ PtexPtr() [1/2]

template<class T >

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

Constructor.

Definition at line 1036 of file Ptexture.h.

## ◆ ~PtexPtr()

template<class T >

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

Destructor, calls ptr->release().

Definition at line 1039 of file Ptexture.h.

References PtexPtr< T >::_ptr.

## ◆ PtexPtr() [2/2]

template<class T >

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

Copying prohibited.

## Member Function Documentation

## ◆ get()

template<class T >

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

Get pointer value.

Definition at line 1048 of file Ptexture.h.

References PtexPtr< T >::_ptr.

Referenced by PtexReader::getData().

## ◆ operator T*()

template<class T >

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

Use as pointer value.

Definition at line 1042 of file Ptexture.h.

References PtexPtr< T >::_ptr.

## ◆ operator->()

template<class T >

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

Access members of pointer.

Definition at line 1045 of file Ptexture.h.

References PtexPtr< T >::_ptr.

## ◆ operator=()

template<class T >

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

Assignment prohibited.

## ◆ 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 1059 of file Ptexture.h.

References PtexPtr< T >::_ptr.

## ◆ swap()

template<class T >

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

Swap pointer values.

Definition at line 1051 of file Ptexture.h.

References PtexPtr< T >::_ptr.

## Member Data Documentation

## ◆ _ptr

template<class T >

T* PtexPtr< T >::_ptr
| private

Definition at line 1033 of file Ptexture.h.

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

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

- Ptexture.h