ai.djl.mxnet.jna.NativeSizeByReference Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mxnet-engine Show documentation
Show all versions of mxnet-engine Show documentation
Deep Java Library (DJL) Engine Adapter for Apache MXNet
package ai.djl.mxnet.jna;
import com.sun.jna.ptr.ByReference;
public class NativeSizeByReference extends ByReference {
public NativeSizeByReference() {
this(new NativeSize(0));
}
@SuppressWarnings("this-escape")
public NativeSizeByReference(NativeSize value) {
super(NativeSize.SIZE);
setValue(value);
}
public void setValue(NativeSize value) {
if (NativeSize.SIZE == 4) {
getPointer().setInt(0, value.intValue());
} else if (NativeSize.SIZE == 8) {
getPointer().setLong(0, value.longValue());
} else {
throw new IllegalArgumentException("size_t has to be either 4 or 8 bytes.");
}
}
public NativeSize getValue() {
if (NativeSize.SIZE == 4) {
return new NativeSize(getPointer().getInt(0));
} else if (NativeSize.SIZE == 8) {
return new NativeSize(getPointer().getLong(0));
} else {
throw new IllegalArgumentException("size_t has to be either 4 or 8 bytes.");
}
}
}