C++ API Reference

Auto pointer for cl_mem objects. More...

#include <MOpenCLAutoPtr.h>

Public Member Functions

 MAutoCLMem ()
 Construct a NULL MAutoCLMem.
 
 ~MAutoCLMem ()
 Destructor.
 
 MAutoCLMem (const MAutoCLMem &other)
 The copy ctor increments the reference count of the cl_mem. More...
 
MAutoCLMemoperator= (const MAutoCLMem &other)
 The assignment operator increments the reference count of the cl_mem. More...
 
 MAutoCLMem (cl_mem value, NoRef dummy)
 This ctor does not increment the reference count of value. More...
 
void attach (cl_mem value)
 This method causes the "this" object to take over lifetime management for value. More...
 
cl_mem detach ()
 This method causes the "this" object to stop managing the lifetime of its current cl_mem. More...
 
void reset ()
 This method causes the "this" object to stop managing the lifetime of its current cl_mem. More...
 
cl_mem get () const
 This method returns the current cl_mem whose lifetime is being managed by the "this" object. More...
 
bool isNull () const
 This method checks if the "this" object actually manages a non-null cl_mem object. More...
 
const cl_mem * getReadOnlyRef () const
 This method returns a const pointer to the cl_mem whose lifetime is being managed by the "this" object. More...
 
cl_mem * getReferenceForAssignment ()
 This method returns a pointer to the memory appropriate for storing a cl_mem. More...
 
bool operator== (const MAutoCLMem &other) const
 operator equal More...
 
bool operator== (cl_mem other) const
 operator equal More...
 
bool operator! () const
 operator not More...
 
void swap (MAutoCLMem &other)
 This method swaps the cl_mem managed by the "this" object with the cl_mem managed by the other object. More...
 
bool operator< (const MAutoCLMem &other) const
 operator less than More...
 

Detailed Description

Auto pointer for cl_mem objects.

cl_mem objects in openCL are reference-counted objects. When created, a cl_mem has a preexisting reference count of 1. An MAutoCLMem object does not need to increment the reference count when it takes over ownership of a cl_mem from OpenCL. An MAutoCLMem object does need to increment the reference count of a cl_mem object when the cl_mem is shared between MAutoCLMem objects.

Always use MAutoCLMem objects in user code. Only use the raw cl_mem handle when you use the OpenCL API.

Assignment or construction with a raw cl_mem DOES NOT increment the reference count. Assignment or construction from another MAutoCLMem DOES increment the reference count.

Examples:
basicMorphNode/basicMorphNode.cpp, and offsetNode/offsetNode.cpp.

Constructor & Destructor Documentation

MAutoCLMem ( const MAutoCLMem other)

The copy ctor increments the reference count of the cl_mem.

Parameters
[in]otherThe MAutoCLMem to be copied.
MAutoCLMem ( cl_mem  value,
NoRef  dummy 
)

This ctor does not increment the reference count of value.

The dummy parameter is included to prevent accidental use the ctor.

Parameters
[in]valueThe cl_mem that the "this" object manages of the lifetime of.
[in]dummyA dummy parameter to make this ctor difficult to call by accident.

Member Function Documentation

MAutoCLMem & operator= ( const MAutoCLMem other)

The assignment operator increments the reference count of the cl_mem.

Parameters
[in]otherThe MAutoCLMem to be assigned to the "this" object.
void attach ( cl_mem  value)

This method causes the "this" object to take over lifetime management for value.

The reference count of value is not modified by attach(). If "this" object already manages the lifetime of a cl_mem object, the reference count of the old cl_mem is decremented.

Parameters
[in]valueThe cl_mem the "this" object should manage the lifetime of.
cl_mem detach ( )

This method causes the "this" object to stop managing the lifetime of its current cl_mem.

The reference count of the cl_mem is not modified by detach().

Returns
The cl_mem that was being managed by the "this" object.
void reset ( )

This method causes the "this" object to stop managing the lifetime of its current cl_mem.

The reference count of the cl_mem is decremented.

cl_mem get ( ) const

This method returns the current cl_mem whose lifetime is being managed by the "this" object.

The reference count of the cl_mem is not modified by get().

Returns
The cl_mem being managed by the "this" object.
Examples:
basicMorphNode/basicMorphNode.cpp, and offsetNode/offsetNode.cpp.
bool isNull ( ) const

This method checks if the "this" object actually manages a non-null cl_mem object.

Returns
True if the "this" object manages a non-null cl_mem object.
const cl_mem * getReadOnlyRef ( ) const

This method returns a const pointer to the cl_mem whose lifetime is being managed by the "this" object.

The reference count of the cl_mem is not modified.

Returns
A pointer to the cl_mem managed by the "this" object.
cl_mem * getReferenceForAssignment ( )

This method returns a pointer to the memory appropriate for storing a cl_mem.

getReferenceForAssignment() decrements the reference count of the cl_mem before returning, which means it is not safe to dereference the returned value. The "this" object manages the lifetime of the cl_mem stored in the returned pointer.

Returns
A pointer to memory appropriate for storing a cl_mem.
bool operator== ( const MAutoCLMem other) const

operator equal

Parameters
[in]otherThe MAutoCLMem to compare with the "this" object.
Returns
True if the cl_mem managed by the "this" object is the same as the cl_mem managed by the other object.
bool operator== ( cl_mem  other) const

operator equal

Parameters
[in]otherThe cl_mem that compares with the "this" object.
Returns
True if the cl_mem managed by the "this" object is other.
bool operator! ( ) const

operator not

Returns
True if the cl_mem managed by the "this" object is NULL.
void swap ( MAutoCLMem other)

This method swaps the cl_mem managed by the "this" object with the cl_mem managed by the other object.

swap() does not modify the reference counts of either cl_mem object.

Parameters
[in]otherThe MAutoCLMem to swap cl_mem's with.
bool operator< ( const MAutoCLMem other) const

operator less than

Parameters
[in]otherthe MAutoCLMem with which the "this" object is compared.
Returns
True if the "this" object is arbitrarily less than the other object.

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