ExternalInterface class
Support for external interfaces.
Contents
- Reference
Software using DIPlib might want to control how the image data is allocated. Such software
should derive a class from this one, and assign a pointer to it into each of the images that
it creates, through dip::Image::SetExternalInterface. The caller will maintain ownership of
the interface.
See Define an image’s allocator for details on how to use the external interfaces.
Derived classes
-
class dip::
AlignedAllocInterface dip::ExternalInterfacethat allocates aligned data. more...-
class dip_opencv::
ExternalInterface - This class is the
dip::ExternalInterfacefor the OpenCV interface. more... -
class dml::
MatlabInterface - This class is the
dip::ExternalInterfacefor the MATLAB interface. more...
Functions
- auto AllocateData(void*& origin, dip::DataType dataType, dip::UnsignedArray const& sizes, dip::IntegerArray& strides, dip::Tensor const& tensor, dip::sint& tensorStride) -> dip::DataSegment pure virtual
- Allocates the data for an image. more...
- auto Name() const -> dip::String virtual
- Overriding the
Namefunction allows the user to find out what the external interface attached to an image is.
Function documentation
dip::DataSegment AllocateData( void*& origin, dip::DataType dataType, dip::UnsignedArray const& sizes, dip::IntegerArray& strides, dip::Tensor const& tensor, dip::sint& tensorStride) pure virtual
Allocates the data for an image.
This function is called when dip::Image::Forge is called on an image with this
external interface. It should be overridden by a function that will allocate space
according to dataType, sizes and tensor.Elements().
strides and tensorStride might have been set by the user before calling forging,
and should be honored if possible.
The function is required to set strides,
tensorStride and origin, and return a dip::DataSegment that owns the
allocated data segment. origin does not need to be the same pointer as
stored in the returned dip::DataSegment. For example, the latter can point
to a container object (e.g. std::vector), and origin can point to data
owned by the container object (e.g. std::vector::data()).
There are two possible failure modes:
- The function can throw an exception, which will not be caught, and causes the call to
Forgeto fail. - The function can return a
nullptr, which tellsForgeto use the default allocator instead.
dip::String Name( ) const virtual
Overriding the Name function allows the user to find out what the external interface attached
to an image is.