Skip to content

Conversation

@ctrueden
Copy link
Member

And add default method implementations delegating to the wrapped Img.

I lifted the methods to implement from an existing class implementing WrappedImg and Img with the delegation pattern.

I'm not sure this is actually a good idea. It would slightly reduce the flexibility of the WrappedImg interface, such that you could no longer implement the two interfaces with different type parameters e.g. WrappedImg< FloatType > and Img< DoubleType >. One scenario where you might want to do that, I guess, could be if you are creating adapter classes from one type to another? E.g. if we consider the Converters utility method:

< A, B extends Type< B > > WriteConvertedRandomAccessibleInterval< A, B > convert(
			final RandomAccessibleInterval< A > source,
			final SamplerConverter< ? super A, B > converter )

And one can imagine a similar function accepting an Img< A > source instead and returns a WriteConvertedImg< A, B > that implements WrappedImg< A > and Img< B >.

A way around that could be to instead introduce a new interface WrappedImgImg< T > extends WrappedImg< T >, Img< T > and have the default delegation methods at this layer. Then folks who want the convenience of these delegators could implement WrappedImgImg instead of the two lower-level interfaces.

Thoughts?

And add default method implementations delegating to the wrapped Img.

I lifted the methods to implement from an existing class
implementing WrappedImg and Img with the delegation pattern:
https://github.com/imglib/imglib2-appose/blob/d1f5ce29ba6e8ac2a0fb172120f9af61a0413248/src/main/java/net/imglib2/appose/SharedMemoryImg.java#L120-L198
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants