public interface ArrayImpl
NDArray
Bridge pattern.
If you have an ArrayImpl
, you can make an NDArray
out of it using BridgeNDArray
.
This is the basic interface via which array implementations provide
services to the BridgeNDArray
class.
The BridgeNDArray
class is intended to be
the only client of ArrayImpl
instances,
and it does the necessary validation of arguments before passing them
to ArrayImpl, so that implementations of this interface can in
general assume that the arguments they receive make sense.
Thus it is not necessary for an ArrayImpl
implementation to check
that it is writable before attempting a write, or that a
requested offset is within the known bounds of the array.
BridgeNDArray
also makes guarantees about the order in which
calls will be made:
open()
; it will not
happen after a call to close
close()
canMap()
, getMapped()
, getAccess()
)
will only be made following an open call and before any close call
getAccess()
will not be called more than once if
multipleAccess()
returns false
getAccess
, canMap
or getMapped
.
The close
method should be used for corresponding tear-down
and/or tidying up of resources allocated at construction time; however
it cannot be guaranteed that a careless user will cause
close
to be invoked, so a responsible ArrayImpl
implementation
may wish to do such essential tear-down in the finalizer as well as
in close (But note: don't just do it in the finalizer,
since the finalizer may never be invoked either).NDArray
,
BridgeNDArray
Modifier and Type | Method and Description |
---|---|
boolean |
canMap()
Indicates whether mapped access is available.
|
void |
close()
Shuts down this ArrayImpl for pixel access.
|
AccessImpl |
getAccess()
Returns an object which can access the pixels of this ArrayImpl.
|
Number |
getBadValue()
The magic bad value for data.
|
Object |
getMapped()
Returns a single primitive array holding all the pixel data of
this array.
|
OrderedNDShape |
getShape()
Returns an object representing the shape (origin and dimensions)
and pixel sequence of this object.
|
Type |
getType()
Returns the primitive type of the data held by this object.
|
boolean |
isRandom()
Indicates whether random access is possible.
|
boolean |
isReadable()
Indicates whether read access is possible.
|
boolean |
isWritable()
Indicates whether write access is possible.
|
boolean |
multipleAccess()
Indicates whether the getAccess method may be called more than once.
|
void |
open()
Prepares this ArrayImpl for pixel access.
|
OrderedNDShape getShape()
Type getType()
Number getBadValue()
null
if there is no bad value.
The return value must not change over the lifetime of the object.boolean isReadable()
boolean isWritable()
boolean isRandom()
boolean multipleAccess()
void open() throws IOException
IOException
- if there is an IO errorboolean canMap()
Will only be called after an open call, and before any close call.
Object getMapped()
Will only be called if canMap returns true, and only after an open call and before any close call.
AccessImpl getAccess() throws IOException
This method will only be called after the sole call to open and before the sole call to close.
This method will only be called more than once if the multipleAccess method returns true.
It is the responsibility of the caller to close the returned AccessImpl when it is no longer required; this enables resources it may hold to be released.
IOException
- if there is an IO errorvoid close() throws IOException
IOException
- if there is an IO errorCopyright © 2024 Central Laboratory of the Research Councils. All Rights Reserved.