ome-files 0.1.0

- Main Page
- Related Pages
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes | Private Types | List of all members
ome::files::VariantPixelBuffer Class Reference

Buffer for all pixel types. More...

`#include <ome/files/VariantPixelBuffer.h>`

## Classes
struct | make_buffer
| Convert T into a buffer. More...

## Public Types
typedef boost::make_variant_over< pixel_buffer_types >::type | variant_buffer_type
| Buffer type, allowing assignment of all buffer types.
typedef PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >::std_type | raw_type
| Raw pixel type used in public interfaces.
typedef boost::multi_array_types::size_type | size_type
| Size type.
typedef ome::compat::array< boost::multi_array_types::index, PixelBufferBase::dimensions > | indices_type
| Type used to index all dimensions in public interfaces.
typedef PixelBufferBase::storage_order_type | storage_order_type
| Storage ordering type for controlling pixel memory layout.
typedef PixelBufferBase::range_type | range_type
| Extent range type.

## Public Member Functions
| VariantPixelBuffer ()
| Default constructor. More...
template<class ExtentList >
| VariantPixelBuffer (const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
| Construct from extents (internal storage). More...
| VariantPixelBuffer (const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
| Construct from ranges (internal storage). More...
| VariantPixelBuffer (const VariantPixelBuffer &buffer)
| Copy constructor. More...
template<typename T >
| VariantPixelBuffer (ome::compat::shared_ptr< PixelBuffer< T > > &buffer)
| Construct from existing pixel buffer. More...
virtual | ~VariantPixelBuffer ()
| Destructor.
variant_buffer_type & | vbuffer ()
| Get a reference to the variant buffer. More...
const variant_buffer_type & | vbuffer () const
| Get a reference to the variant buffer. More...
template<class ExtentList >
void | setBuffer (const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
| Set the buffer from extents (helper). More...
void | setBuffer (const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
| Set the buffer from ranges (internal storage). More...
bool | managed () const
| Check if the buffer is internally managed. More...
size_type | num_elements () const
| Get the number of pixel elements in the multi-dimensional array.
size_type | num_dimensions () const
| Get the number of dimensions in the multi-dimensional array.
const size_type * | shape () const
| Get the shape of the multi-dimensional array. More...
const boost::multi_array_types::index * | strides () const
| Get the strides of the multi-dimensional array. More...
const boost::multi_array_types::index * | index_bases () const
| Get the index bases of the multi-dimensional array. More...
template<typename T >
const T * | origin () const
| Get the origin of the array. More...
const storage_order_type & | storage_order () const
| Get the array storage order. More...
::ome::xml::model::enums::PixelType | pixelType () const
| Get the type of pixels stored in the buffer.
EndianType | endianType () const
| Get the endianness of the pixel type stored in the buffer.
template<typename T >
PixelBuffer< T >::array_ref_type & | array ()
| Get the pixel data. More...
template<typename T >
const PixelBuffer< T >::array_ref_type & | array () const
| Get the pixel data. More...
raw_type * | data ()
| Get raw buffered data. More...
const raw_type * | data () const
| Get raw buffered data. More...
template<typename T >
T * | data ()
| Get raw buffered data. More...
template<typename T >
const T * | data () const
| Get raw buffered data. More...
bool | valid () const
| Check the buffer validity. More...
VariantPixelBuffer & | operator= (const VariantPixelBuffer &rhs)
| Assign a pixel buffer. More...
bool | operator== (const VariantPixelBuffer &rhs) const
| Compare a pixel buffer for equality. More...
bool | operator!= (const VariantPixelBuffer &rhs) const
| Compare a pixel buffer for inequality. More...
template<typename InputIterator >
void | assign (InputIterator begin, InputIterator end)
| Assign pixel values. More...
template<class charT , class traits >
void | read (std::basic_istream< charT, traits > &stream)
| Read raw pixel data from a stream in physical storage order. More...
template<class charT , class traits >
void | write (std::basic_ostream< charT, traits > &stream) const
| Write raw pixel data to a stream in physical storage order. More...
template<typename T >
PixelBuffer< T >::array_ref_type & | array ()
| Get the pixel data. More...
template<typename T >
const PixelBuffer< T >::array_ref_type & | array () const
| Get the pixel data. More...

## Static Protected Member Functions
template<class T , class ExtentList >
static variant_buffer_type | makeBuffer (const ExtentList &extents, const storage_order_type &storage,::ome::xml::model::enums::PixelType pixeltype)
| Create buffer from extents (helper). More...
template<class T >
static variant_buffer_type | makeBuffer (const range_type &range, const storage_order_type &storage,::ome::xml::model::enums::PixelType pixeltype)
| Create buffer from ranges (helper). More...
template<class ExtentList >
static variant_buffer_type | createBuffer (const ExtentList &extents,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
| Create buffer from extents (internal storage). More...
static variant_buffer_type | createBuffer (const range_type &range,::ome::xml::model::enums::PixelType pixeltype=::ome::xml::model::enums::PixelType::UINT8, const storage_order_type &storage=PixelBufferBase::default_storage_order())
| Create buffer from ranges (helper). More...

## Protected Attributes
variant_buffer_type | buffer
| Pixel storage.

## Private Types
typedef boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::INT8 >, PixelProperties< ::ome::xml::model::enums::PixelType::INT16 >, PixelProperties< ::ome::xml::model::enums::PixelType::INT32 >, PixelProperties< ::ome::xml::model::enums::PixelType::UINT8 >, PixelProperties< ::ome::xml::model::enums::PixelType::UINT16 >, PixelProperties< ::ome::xml::model::enums::PixelType::UINT32 >, PixelProperties< ::ome::xml::model::enums::PixelType::BIT > > | integer_pixel_types
| Integer pixel types.
typedef boost::mpl::vector< PixelProperties< ::ome::xml::model::enums::PixelType::FLOAT >, PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLE >, PixelProperties< ::ome::xml::model::enums::PixelType::COMPLEX >, PixelProperties< ::ome::xml::model::enums::PixelType::DOUBLECOMPLEX > > | float_pixel_types
| Floating-point pixel types.
typedef boost::mpl::joint_view< integer_pixel_types, float_pixel_types >::type | basic_pixel_types_view
| Aggregate view of all numeric types.
typedef boost::mpl::transform_view< basic_pixel_types_view, make_buffer< boost::mpl::_1 > >::type | pixel_buffer_types_view
| Aggregate view of all buffer types.
typedef boost::mpl::vector | empty_types
| Empty vector placeholder.
typedef boost::mpl::insert_range< empty_types, boost::mpl::end< empty_types >::type, pixel_buffer_types_view >::type | pixel_buffer_types
| List of all pixel buffer types.

## Detailed Description

Buffer for all pixel types.

The purpose of this class is to allow transfer of pixel data of any type and of any dimensionality.

This class uses Boost.Variant to support specializations of PixelBuffer for all combinations of pixel type (excluding endian variants).

For high performance access to the pixel data, use of a `boost::static_visitor` is recommended. This has the benefit of generalising the algorithm to operate on all PixelBuffer types, as well as allowing special casing for particular types (e.g. integer vs. float, signed vs. unsigned, simple vs. complex, or any other distinction which affects the algorithm). This will also allow subsetting of the data if required, again for all pixel types with special casing being possible.

Todo:
  Add support for subsetting dimensions.

## Constructor & Destructor Documentation

ome::files::VariantPixelBuffer::VariantPixelBuffer | ( |  | ) |
| inline explicit

Default constructor.

This constructs a pixel buffer of unspecified type, of size 1 in all dimensions. The desired type and size should be set after construction.

template<class ExtentList >

ome::files::VariantPixelBuffer::VariantPixelBuffer | ( | const ExtentList & | extents,
|  | ::ome::xml::model::enums::PixelType | pixeltype = `::ome::xml::model::enums::PixelType::UINT8`,
|  | const storage_order_type & | storage = `PixelBufferBase::default_storage_order()`
| ) |  |
| inline explicit

Construct from extents (internal storage).

Storage for the buffer will be allocated internally.

Parameters

  extents | the extent of each dimension.
  storage | the storage ordering, defaulting to C array storage ordering.
  pixeltype | the pixel type to store.

ome::files::VariantPixelBuffer::VariantPixelBuffer | ( | const range_type & | range,
|  | ::ome::xml::model::enums::PixelType | pixeltype = `::ome::xml::model::enums::PixelType::UINT8`,
|  | const storage_order_type & | storage = `PixelBufferBase::default_storage_order()`
| ) |  |
| inline explicit

Construct from ranges (internal storage).

Storage for the buffer will be allocated internally.

Parameters

  range | the range of each dimension.
  storage | the storage ordering, defaulting to C array storage ordering.
  pixeltype | the pixel type to store.

ome::files::VariantPixelBuffer::VariantPixelBuffer | ( | const VariantPixelBuffer & | buffer | ) |
| explicit

Copy constructor.

Note that due to the use of shared pointers this only performs a shallow copy.

Parameters

  buffer | the buffer to copy.

References buffer.

template<typename T >

ome::files::VariantPixelBuffer::VariantPixelBuffer | ( | ome::compat::shared_ptr< PixelBuffer< T > > & | buffer | ) |
| inline explicit

Construct from existing pixel buffer.

Use for referencing external data.

Parameters

  buffer | the buffer to contain.

## Member Function Documentation

template<typename T >

PixelBuffer<T>::array_ref_type& ome::files::VariantPixelBuffer::array | ( |  | ) |

Get the pixel data.

Returns
  the multidimensional pixel data array; this value will never be null.

Exceptions

  if | the contained PixelBuffer is not of the specified type.

template<typename T >

const PixelBuffer<T>::array_ref_type& ome::files::VariantPixelBuffer::array | ( |  | ) | const

Get the pixel data.

Returns
  the multidimensional pixel data array; this value will never be null.

Exceptions

  if | the contained PixelBuffer is not of the specified type.

template<typename T >

PixelBuffer<T>::array_ref_type& ome::files::VariantPixelBuffer::array | ( |  | ) |
| inline

Get the pixel data.

Returns
  the multidimensional pixel data array; this value will never be null.

Exceptions

  if | the contained PixelBuffer is not of the specified type.

References buffer.

template<typename T >

const PixelBuffer<T>::array_ref_type& ome::files::VariantPixelBuffer::array | ( |  | ) | const
| inline

Get the pixel data.

Returns
  the multidimensional pixel data array; this value will never be null.

Exceptions

  if | the contained PixelBuffer is not of the specified type.

References buffer.

template<typename InputIterator >

void ome::files::VariantPixelBuffer::assign | ( | InputIterator | begin,
|  | InputIterator | end
| ) |  |
| inline

Assign pixel values.

Assign all pixel values from an input iterator.

Note that the range to assign must be equal to num_elements().

Parameters

  begin | the start of the range to assign.
  end | the end of the range to assign.
  begin | the start of input.
  end | the end of input.

Exceptions

  if | the PixelBuffer is null or the PixelBuffer's data array is null.

References buffer.

template<class ExtentList >

static variant_buffer_type ome::files::VariantPixelBuffer::createBuffer | ( | const ExtentList & | extents,
|  | ::ome::xml::model::enums::PixelType | pixeltype = `::ome::xml::model::enums::PixelType::UINT8`,
|  | const storage_order_type & | storage = `PixelBufferBase::default_storage_order()`
| ) |  |
| inline static protected

Create buffer from extents (internal storage).

Storage for the buffer will be allocated internally.

Parameters

  extents | the extent of each dimension.
  pixeltype | the pixel type to store.
  storage | the storage ordering, defaulting to C array storage ordering.

Returns
  the new buffer contained in a variant.

Referenced by setBuffer().

Here is the caller graph for this function:

static variant_buffer_type ome::files::VariantPixelBuffer::createBuffer | ( | const range_type & | range,
|  | ::ome::xml::model::enums::PixelType | pixeltype = `::ome::xml::model::enums::PixelType::UINT8`,
|  | const storage_order_type & | storage = `PixelBufferBase::default_storage_order()`
| ) |  |
| inline static protected

Create buffer from ranges (helper).

Storage for the buffer will be allocated internally.

Parameters

  range | the range of each dimension.
  pixeltype | the pixel type to store.
  storage | the storage ordering, defaulting to C array storage ordering.

Returns
  the new buffer contained in a variant.

VariantPixelBuffer::raw_type * ome::files::VariantPixelBuffer::data | ( |  | ) |

Get raw buffered data.

Returns
  a pointer to the buffer start address.

References buffer.

const VariantPixelBuffer::raw_type * ome::files::VariantPixelBuffer::data | ( |  | ) | const

Get raw buffered data.

Returns
  a pointer to the buffer start address.

References buffer.

template<typename T >

T * ome::files::VariantPixelBuffer::data | ( |  | ) |
| inline

Get raw buffered data.

Returns
  a pointer to the buffer start address.

Exceptions

  if | the contained PixelBuffer is not of the specified type.

References buffer.

template<typename T >

const T * ome::files::VariantPixelBuffer::data | ( |  | ) | const
| inline

Get raw buffered data.

Returns
  a pointer to the buffer start address.

Exceptions

  if | the contained PixelBuffer is not of the specified type.

References buffer.

const boost::multi_array_types::index * ome::files::VariantPixelBuffer::index_bases | ( |  | ) | const

Get the index bases of the multi-dimensional array.

The index bases are the numeric index of the first element for each array dimension of the multi-dimensional array.

Returns
  an array of index bases (size is the dimension size).

References buffer.

template<class T , class ExtentList >

static variant_buffer_type ome::files::VariantPixelBuffer::makeBuffer | ( | const ExtentList & | extents,
|  | const storage_order_type & | storage,
|  | ::ome::xml::model::enums::PixelType | pixeltype
| ) |  |
| inline static protected

Create buffer from extents (helper).

Storage for the buffer will be allocated internally.

Parameters

  extents | the extent of each dimension.
  storage | the storage ordering, defaulting to C array storage ordering.
  pixeltype | the pixel type to store.

Returns
  the new buffer contained in a variant.

References ome::files::ENDIAN_NATIVE.

template<class T >

static variant_buffer_type ome::files::VariantPixelBuffer::makeBuffer | ( | const range_type & | range,
|  | const storage_order_type & | storage,
|  | ::ome::xml::model::enums::PixelType | pixeltype
| ) |  |
| inline static protected

Create buffer from ranges (helper).

Storage for the buffer will be allocated internally.

Parameters

  range | the range of each dimension.
  storage | the storage ordering, defaulting to C array storage ordering.
  pixeltype | the pixel type to store.

Returns
  the new buffer contained in a variant.

References ome::files::ENDIAN_NATIVE.

bool ome::files::VariantPixelBuffer::managed | ( |  | ) | const

Check if the buffer is internally managed.

Returns
  `true` if the `MultiArray` data is managed internally (i.e. is a `multi_array`) or `false` if not managed (i.e. is a `multi_array_ref`).

References buffer.

bool ome::files::VariantPixelBuffer::operator!= | ( | const VariantPixelBuffer & | rhs | ) | const

Compare a pixel buffer for inequality.

Parameters

  rhs | the pixel buffer to compare with.

Returns
  `true` if not equal, `false` if equal.

VariantPixelBuffer & ome::files::VariantPixelBuffer::operator= | ( | const VariantPixelBuffer & | rhs | ) |

Assign a pixel buffer.

The dimension extents must be compatible, but the storage ordering does not. The buffer contents will be assigned in the logical order rather than the storage order.

Parameters

  rhs | the pixel buffer to assign.

Returns
  the assigned buffer.

References buffer.

bool ome::files::VariantPixelBuffer::operator== | ( | const VariantPixelBuffer & | rhs | ) | const

Compare a pixel buffer for equality.

Parameters

  rhs | the pixel buffer to compare with.

Returns
  `true` if equal, `false` if not equal.

References buffer.

template<typename T >

const T * ome::files::VariantPixelBuffer::origin | ( |  | ) | const
| inline

Get the origin of the array.

This is the address of the element at ``[0][0][0][0][0][0][0][0][0]. Note that this is not always the buffer start address, depending upon the dimension ordering.

Returns
  the address of the array origin.

References buffer.

template<class charT , class traits >

void ome::files::VariantPixelBuffer::read | ( | std::basic_istream< charT, traits > & | stream | ) |
| inline

Read raw pixel data from a stream in physical storage order.

Note that the pixels will be read in the physical storage order. This will typically be a contiguous read, but this is not guaranteed. The current implementation iterates over each pixel and so may be slower than strictly necessary.

Parameters

  stream | the stream to read from.

References buffer.

template<class ExtentList >

void ome::files::VariantPixelBuffer::setBuffer | ( | const ExtentList & | extents,
|  | ::ome::xml::model::enums::PixelType | pixeltype = `::ome::xml::model::enums::PixelType::UINT8`,
|  | const storage_order_type & | storage = `PixelBufferBase::default_storage_order()`
| ) |  |
| inline

Set the buffer from extents (helper).

Storage for the buffer will be allocated internally.

Parameters

  extents | the extent of each dimension.
  pixeltype | the pixel type to store.
  storage | the storage ordering, defaulting to C array storage ordering.

References buffer, and createBuffer().

Referenced by ome::files::detail::CopySubchannelVisitor::operator()(), ome::files::tiff::IFD::readImage(), ome::files::tiff::IFD::readLookupTable(), and ome::files::detail::FormatReader::readPlane().

Here is the caller graph for this function:

void ome::files::VariantPixelBuffer::setBuffer | ( | const range_type & | range,
|  | ::ome::xml::model::enums::PixelType | pixeltype = `::ome::xml::model::enums::PixelType::UINT8`,
|  | const storage_order_type & | storage = `PixelBufferBase::default_storage_order()`
| ) |  |
| inline

Set the buffer from ranges (internal storage).

Storage for the buffer will be allocated internally.

Parameters

  range | the range of each dimension.
  pixeltype | the pixel type to store.
  storage | the storage ordering, defaulting to C array storage ordering.

References buffer, and createBuffer().

const boost::multi_array_types::size_type * ome::files::VariantPixelBuffer::shape | ( |  | ) | const

Get the shape of the multi-dimensional array.

The shape is the extent of each array dimension.

Returns
  an array of extents (size is the dimension size).

References buffer.

Referenced by ome::files::tiff::IFD::readImage(), ome::files::detail::FormatReader::readPlane(), and ome::files::tiff::IFD::writeImage().

Here is the caller graph for this function:

const VariantPixelBuffer::storage_order_type & ome::files::VariantPixelBuffer::storage_order | ( |  | ) | const

Get the array storage order.

Returns
  the storage order.

References buffer.

Referenced by ome::files::tiff::IFD::readImage(), ome::files::detail::FormatReader::readPlane(), and ome::files::tiff::IFD::writeImage().

Here is the caller graph for this function:

const boost::multi_array_types::index * ome::files::VariantPixelBuffer::strides | ( |  | ) | const

Get the strides of the multi-dimensional array.

The strides are the stride associated with each array dimension.

Returns
  an array of strides (size is the dimension size).

References buffer.

bool ome::files::VariantPixelBuffer::valid | ( |  | ) | const

Check the buffer validity.

This tests if the `MultiArray` is not null, and hence safe to use. Note that this is not a guarantee of safety in the case of using an externally managed data buffer, in which case the external buffer must still be valid in addition.

Returns
  `true` if not null, `false` if null.

References buffer.

variant_buffer_type& ome::files::VariantPixelBuffer::vbuffer | ( |  | ) |
| inline

Get a reference to the variant buffer.

Returns
  a reference to the buffer.

References buffer.

Referenced by ome::files::detail::CopySubchannelVisitor::operator()(), ome::files::detail::MergeSubchannelVisitor::operator()(), ome::files::tiff::IFD::readImage(), ome::files::tiff::IFD::readLookupTable(), ome::files::detail::FormatReader::readPlane(), and ome::files::tiff::IFD::writeImage().

Here is the caller graph for this function:

const variant_buffer_type& ome::files::VariantPixelBuffer::vbuffer | ( |  | ) | const
| inline

Get a reference to the variant buffer.

Returns
  a reference to the buffer.

References buffer.

template<class charT , class traits >

void ome::files::VariantPixelBuffer::write | ( | std::basic_ostream< charT, traits > & | stream | ) | const
| inline

Write raw pixel data to a stream in physical storage order.

Note that the pixels will be written in the physical storage order. This will typically be a contiguous read, but this is not guaranteed. The current implementation iterates over each pixel and so may be slower than strictly necessary.

Parameters

  stream | the stream to write to.

References buffer.

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

- ome/files/VariantPixelBuffer.h
- ome/files/VariantPixelBuffer.cpp