Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

ArrayData< T > Class Template Reference

#include <Image/ArrayData.H>

Collaboration diagram for ArrayData< T >:

Collaboration graph
[legend]
List of all members.

Detailed Description

template<class T>
class ArrayData< T >

Implements a ref-counted 2-D array, should only be used via ArrayHandle.

ArrayData implements a 2-D array, by storing:

All of these data members are immutable, with the exception of the reference count. This reflects the semantics that an ArrayData object is a fixed-size block of data; if a higher-level clients wants to resize(), it does so by creating a new ArrayData of the desired size, and releasing the old ArrayData. This simplifies the memory management: within ArrayData, memory is new[]'ed only in the constructor(s), and delete[]'ed only in the destructor.

ArrayData provides the basics needed to use STL-style iterator algorithms. In particular it offers two pairs of functions to get half-open iterator ranges:

Definition at line 173 of file ArrayData.H.

Public Member Functions

 ArrayData ()
 Default construct an empty (i.e. 0-by-0) array.
 ArrayData (const Dims &dims, const InitPolicy ip=NO_INIT)
 Construct with the specified dimensions and InitPolicy.
 ArrayData (const Dims &dims, const InitPolicy ip, const MemoryPolicy mp, const int device)
 Construct with the specified dimensions and InitPolicy and Memory Policy.
 ArrayData (const Dims &dims, const T *aa)
 Construct with the specified dimensions.
 ArrayData (const Dims &dims, const T *aa, const MemoryPolicy mp, const int device, const MemoryPolicy srcmp, const int srcdevice)
 Construct with the specified dimensions, input data, and memory policy.
 ArrayData (const Dims &dims, T *aa, const StoragePolicy s)
 Construct with the specified dimensions and storage policy.
 ArrayData (const Dims &dims, T *aa, const StoragePolicy s, const MemoryPolicy mp, const int device, const MemoryPolicy srcmp, const int srcdevice)
 Construct with the specified dimensions, storage and memory policies.
ArrayDataclone () const
 Return a new'ed copy of *this.
ArrayDataclone (const MemoryPolicy mp, const int device) const
 Return a new'ed copy of *this using the given memory policy.
 ~ArrayData () throw ()
 Release the pointed-to data if our storage policy is MAKE_OWN_COPY.
const T * data () const throw ()
 Returns a read-only pointer to the data array.
const T * end () const throw ()
 Returns a read-only pointer to one-past-the-end of the data array.
T * dataw () throw ()
 Returns a read-write pointer to the data array (the "w" means "write").
T * endw () throw ()
 Returns a read-write pointer to one-past-the-end of the data array.
const Dimsdims () const throw ()
 Returns the dimensions (i.e. width, height) of the 2-D data array.
int w () const throw ()
 Returns the width of the data array (i.e. the number of columns).
int h () const throw ()
 Returns the height of the data array (i.e. the number of rows).
void acquire () throw ()
 Increment the reference count.
void release () throw ()
 Decrement the reference count and delete self if the count goes to zero.
bool isShared () const throw ()
 Query whether this object is shared (i.e. ref count > 1).
int refCount () const throw ()
 For debugging/testing only.
MemoryPolicy getMemoryPolicy () const
 Return memory policy of underlying array data.
int getMemoryDevice () const
 Return memory policy of underlying array data.


Constructor & Destructor Documentation

template<class T>
ArrayData< T >::ArrayData  )  [inline]
 

Default construct an empty (i.e. 0-by-0) array.

Definition at line 661 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set().

Referenced by ArrayData< T >::clone().

template<class T>
ArrayData< T >::ArrayData const Dims dims,
const InitPolicy  ip = NO_INIT
[inline]
 

Construct with the specified dimensions and InitPolicy.

Definition at line 675 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set(), ArrayHelper< T, isTrivial >::minimal_initialize(), Dims::sz(), ArrayHelper< T, isTrivial >::zero_initialize(), and ZEROS.

template<class T>
ArrayData< T >::ArrayData const Dims dims,
const InitPolicy  ip,
const MemoryPolicy  mp,
const int  device
[inline]
 

Construct with the specified dimensions and InitPolicy and Memory Policy.

Definition at line 694 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set(), ArrayHelper< T, isTrivial >::minimal_initialize(), Dims::sz(), ArrayHelper< T, isTrivial >::zero_initialize(), and ZEROS.

template<class T>
ArrayData< T >::ArrayData const Dims dims,
const T *  aa
[inline]
 

Construct with the specified dimensions.

If the passed-in T* array is non-null, copy that data into the constructed object.

Definition at line 711 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set(), ArrayHelper< T, isTrivial >::copy_initialize(), and Dims::sz().

template<class T>
ArrayData< T >::ArrayData const Dims dims,
const T *  aa,
const MemoryPolicy  mp,
const int  device,
const MemoryPolicy  srcmp,
const int  srcdevice
[inline]
 

Construct with the specified dimensions, input data, and memory policy.

If the passed-in T* array is non-null, copy that data into the constructed object. Use the given memory policy

Definition at line 726 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set(), ArrayHelper< T, isTrivial >::copy_initialize(), and Dims::sz().

template<class T>
ArrayData< T >::ArrayData const Dims dims,
T *  aa,
const StoragePolicy  s
[inline]
 

Construct with the specified dimensions and storage policy.

If the passed-in T* array is non-null, then if the storage policy is MAKE_OWN_COPY we make a copy of the data, but if the storage policy is WRITE_THRU then we "borrow" the data.

Definition at line 741 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set(), ArrayHelper< T, isTrivial >::copy_initialize(), MAKE_OWN_COPY, ArrayHelper< T, isTrivial >::minimal_initialize(), and Dims::sz().

template<class T>
ArrayData< T >::ArrayData const Dims dims,
T *  aa,
const StoragePolicy  s,
const MemoryPolicy  mp,
const int  device,
const MemoryPolicy  srcmp,
const int  srcdevice
[inline]
 

Construct with the specified dimensions, storage and memory policies.

If the passed-in T* array is non-null, then if the storage policy is MAKE_OWN_COPY we make a copy of the data, but if the storage policy is WRITE_THRU then we "borrow" the data.

Definition at line 765 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_set(), ArrayHelper< T, isTrivial >::copy_initialize(), LFATAL, MAKE_OWN_COPY, ArrayHelper< T, isTrivial >::minimal_initialize(), and Dims::sz().

template<class T>
ArrayData< T >::~ArrayData  )  throw () [inline]
 

Release the pointed-to data if our storage policy is MAKE_OWN_COPY.

Definition at line 812 of file ArrayData.H.

References ArrayHelper< T, isTrivial >::destruct(), MAKE_OWN_COPY, Dims::sz(), and wrap_invt_deallocate().


Member Function Documentation

template<class T>
void ArrayData< T >::acquire  )  throw () [inline]
 

Increment the reference count.

Definition at line 858 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_get(), rutz::mutex_atomic_int::atomic_incr(), and check_acquisition().

template<class T>
ArrayData< T > * ArrayData< T >::clone const MemoryPolicy  mp,
const int  device
const [inline]
 

Return a new'ed copy of *this using the given memory policy.

The cloned copy will always be MAKE_OWN_COPY, even if *this is WRITE_THRU.

Definition at line 805 of file ArrayData.H.

References ArrayData< T >::ArrayData().

template<class T>
ArrayData< T > * ArrayData< T >::clone  )  const [inline]
 

Return a new'ed copy of *this.

The cloned copy will always be MAKE_OWN_COPY, even if *this is WRITE_THRU.

Definition at line 793 of file ArrayData.H.

References ArrayData< T >::ArrayData(), CUDA_HOST_DEVICE_NUM, and HOST_MEMORY.

template<class T>
const T * ArrayData< T >::data  )  const throw () [inline]
 

Returns a read-only pointer to the data array.

With end(), forms an STL-style half-open const_iterator range.

Definition at line 823 of file ArrayData.H.

template<class T>
T * ArrayData< T >::dataw  )  throw () [inline]
 

Returns a read-write pointer to the data array (the "w" means "write").

With endw(), forms an STL-style half-open iterator range.

Definition at line 833 of file ArrayData.H.

Referenced by VideoFrame::fromStream(), VideoFrame::getFlippedHoriz(), VideoFrame::makeBobDeinterlaced(), MgzDecoder::readFrame(), RGB24_to_RGB32(), RGB24_to_RGB555(), RGB24_to_RGB565(), 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().

template<class T>
const Dims & ArrayData< T >::dims  )  const throw () [inline]
 

Returns the dimensions (i.e. width, height) of the 2-D data array.

Definition at line 843 of file ArrayData.H.

template<class T>
const T * ArrayData< T >::end  )  const throw () [inline]
 

Returns a read-only pointer to one-past-the-end of the data array.

With data(), forms an STL-style half-open const_iterator range.

Definition at line 828 of file ArrayData.H.

References Dims::sz().

template<class T>
T * ArrayData< T >::endw  )  throw () [inline]
 

Returns a read-write pointer to one-past-the-end of the data array.

With dataw(), forms an STL-style half-open iterator range.

Definition at line 838 of file ArrayData.H.

References Dims::sz().

Referenced by RGB24_to_RGB32(), RGB24_to_RGB555(), RGB24_to_RGB565(), YUV24_to_UYVYx(), YUV24_to_YUV411(), YUV24_to_YUV444(), and YUV24_to_YUYV().

template<class T>
int ArrayData< T >::getMemoryDevice  )  const [inline]
 

Return memory policy of underlying array data.

Definition at line 895 of file ArrayData.H.

template<class T>
MemoryPolicy ArrayData< T >::getMemoryPolicy  )  const [inline]
 

Return memory policy of underlying array data.

Definition at line 888 of file ArrayData.H.

template<class T>
int ArrayData< T >::h  )  const throw () [inline]
 

Returns the height of the data array (i.e. the number of rows).

Definition at line 853 of file ArrayData.H.

References Dims::h().

template<class T>
bool ArrayData< T >::isShared  )  const throw () [inline]
 

Query whether this object is shared (i.e. ref count > 1).

Definition at line 874 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_get().

template<class T>
int ArrayData< T >::refCount  )  const throw () [inline]
 

For debugging/testing only.

Returns the current reference count.

Definition at line 881 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_get().

template<class T>
void ArrayData< T >::release  )  throw () [inline]
 

Decrement the reference count and delete self if the count goes to zero.

Definition at line 867 of file ArrayData.H.

References rutz::mutex_atomic_int::atomic_decr_test_zero().

template<class T>
int ArrayData< T >::w  )  const throw () [inline]
 

Returns the width of the data array (i.e. the number of columns).

Definition at line 848 of file ArrayData.H.

References Dims::w().


The documentation for this class was generated from the following file:
Generated on Sun Nov 22 13:45:22 2009 for iLab Neuromorphic Vision Toolkit by  doxygen 1.4.4