
#include <Image/ArrayData.H>
NOTE: Most clients will not need to use ArrayHandle<T> directly, but can rather use Image<T>, which wraps and expands the ArrayHandle interface. Nevertheless, these notes may be of interest because the ref-counting and copy-on-write semantics that ArrayHandle<T> offers are transferred through to Image<T>.
As long as clients access ArrayData<T> through an ArrayHandle<T>, the proper copy-on-write semantics are guaranteed. This is by virtue of the fact that the only way to extract a non-const ArrayData<T>& from an ArrayHandle<T> is to call uniq(), which in turn checks to see if the ArrayData is shared (i.e. ref count > 1). If it is shared, then that ArrayData is clone()'d before returning a reference to it.
The only caveat: you should not store non-const references to an ArrayData or to the elements of an ArrayData object for "long" periods of time. In this case, "long" means "longer than you are sure you have a unique reference", which in practice means "you can keep such references up until a new copy of the ArrayHandle<T> is made". This goes along with sensible coding practices anyway; a typical usage pattern would be:
Definition at line 326 of file ArrayData.H.
Public Member Functions | |
| ArrayHandle () | |
| Default construct with an empty array (i.e. 0-by-0). | |
| ArrayHandle (const ArrayData< T > *p) throw () | |
| Construct with a new ArrayData, which the ArrayHandle now owns. | |
| ArrayHandle (const ArrayData< T > *p, const MemoryPolicy mp, const int dev) throw () | |
| Construct with a new ArrayData, which the ArrayHandle now owns. | |
| ArrayHandle (const ArrayHandle &r) throw () | |
| Copy construct; no deep-copy is incurred, just bumps the ref-count. | |
| ~ArrayHandle () throw () | |
| Destruct; delete's the ArrayData<T> if its ref count goes to zero. | |
| void | swap (ArrayHandle< T > &other) throw () |
| Swap contents with another ArrayHandle. | |
| ArrayHandle & | operator= (const ArrayHandle &r) throw () |
| Assignment; no deep-copy is incurred, just bumps the ref-count. | |
| const ArrayData< T > & | get () const throw () |
| Get a read-only reference to the ArrayData object. | |
| ArrayData< T > & | uniq (const MemoryPolicy mp, const int dev) |
| Get a unique read-write reference to the ArrayData object. | |
| ArrayData< T > & | uniq () |
| Get a unique read-write reference to the ArrayData object. | |
| bool | isShared () const throw () |
| See if the ArrayData object is shared (i.e. ref-count > 1). | |
| bool | hasSameData (const ArrayHandle< T > &b) const throw () |
| For testing/debugging only. | |
| int | refCount () const throw () |
| For testing/debugging only. | |
|
|||||||||
|
Default construct with an empty array (i.e. 0-by-0).
Definition at line 909 of file ArrayData.H. |
|
||||||||||
|
Construct with a new ArrayData, which the ArrayHandle now owns.
Definition at line 917 of file ArrayData.H. |
|
||||||||||||||||||||
|
Construct with a new ArrayData, which the ArrayHandle now owns.
Definition at line 927 of file ArrayData.H. |
|
||||||||||
|
Copy construct; no deep-copy is incurred, just bumps the ref-count.
Definition at line 938 of file ArrayData.H. |
|
|||||||||
|
Destruct; delete's the ArrayData<T> if its ref count goes to zero.
Definition at line 946 of file ArrayData.H. |
|
|||||||||
|
Get a read-only reference to the ArrayData object. This is a "cheap" operation, since the ArrayData will never be copied in this operation. Definition at line 969 of file ArrayData.H. Referenced by RealVoxel< T >::impl(). |
|
||||||||||
|
For testing/debugging only. See if we are pointing to the same ArrayData<T> as is the other ArrayHandle<T>. Definition at line 1005 of file ArrayData.H. Referenced by RealVoxel< T >::hasSameData(). |
|
|||||||||
|
See if the ArrayData object is shared (i.e. ref-count > 1).
Definition at line 1000 of file ArrayData.H. Referenced by RealVoxel< T >::clear(), and RealVoxel< T >::isShared(). |
|
||||||||||
|
Assignment; no deep-copy is incurred, just bumps the ref-count.
Definition at line 962 of file ArrayData.H. |
|
|||||||||
|
For testing/debugging only. Returns the current reference count of the our ArrayData<T>. Definition at line 1010 of file ArrayData.H. Referenced by RealVoxel< T >::refCount(). |
|
||||||||||
|
Swap contents with another ArrayHandle.
Definition at line 953 of file ArrayData.H. Referenced by RealVoxel< T >::attach(), RealVoxel< T >::detach(), TCPmessage::freeMem(), TCPmessage::operator=(), RealVoxel< T >::resize(), RealVoxel< T >::swap(), and ArrayHandle< T >::uniq(). |
|
|||||||||
|
Get a unique read-write reference to the ArrayData object. This is a potentially "expensive" operation, since in order to get a unique ArrayData object, the current one may have to be clone()'d if it is shared (i.e. ref-count > 1). Definition at line 987 of file ArrayData.H. References ArrayHandle< T >::swap(). |
|
||||||||||||||||
|
Get a unique read-write reference to the ArrayData object. This is a potentially "expensive" operation, since in order to get a unique ArrayData object, the current one may have to be clone()'d if it is shared (i.e. ref-count > 1). Definition at line 974 of file ArrayData.H. References ArrayHandle< T >::swap(). Referenced by VideoFrame::fromStream(), VideoFrame::getFlippedHoriz(), VideoFrame::makeBobDeinterlaced(), MgzDecoder::readFrame(), RGB24_to_RGB32(), RGB24_to_RGB555(), RGB24_to_RGB565(), RealVoxel< T >::uniq(), YUV24_to_UYVYx(), YUV24_to_YUV410P(), YUV24_to_YUV411(), YUV24_to_YUV411P(), YUV24_to_YUV420P(), YUV24_to_YUV422P(), YUV24_to_YUV444(), YUV24_to_YUV444P(), YUV24_to_YUYV(), yuv411p_to_VideoFrame(), yuv420p_to_VideoFrame(), and yuv422p_to_VideoFrame(). |
1.4.4