ArrayData< T > Class Template Reference

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

#include <Image/ArrayData.H>

Collaboration diagram for ArrayData< T >:
Collaboration graph
[legend]

List of all members.

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.

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.


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::ix86_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 674 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_set(), Dims::sz(), 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 692 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_set(), Dims::sz(), 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 709 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_set(), 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 724 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_set(), 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 739 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_set(), MAKE_OWN_COPY, 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 763 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_set(), MAKE_OWN_COPY, 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 810 of file ArrayData.H.

References 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 856 of file ArrayData.H.

References rutz::ix86_atomic_int::atomic_get(), and rutz::ix86_atomic_int::atomic_incr().

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 803 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 791 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 821 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 831 of file ArrayData.H.

Referenced by VideoFrame::fromStream(), VideoFrame::getFlippedHoriz(), VideoFrame::makeBobDeinterlaced(), MgzDecoder::readFrame(), and MgzJDecoder::readFrame().

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 841 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 826 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 836 of file ArrayData.H.

References Dims::sz().

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

Return memory policy of underlying array data.

Definition at line 893 of file ArrayData.H.

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

Return memory policy of underlying array data.

Definition at line 886 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 851 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 872 of file ArrayData.H.

References rutz::ix86_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 879 of file ArrayData.H.

References rutz::ix86_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 865 of file ArrayData.H.

References rutz::ix86_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 846 of file ArrayData.H.

References Dims::w().


The documentation for this class was generated from the following file:
Generated on Sun May 8 08:19:58 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3