public abstract class MappedObject
extends java.lang.Object
MappedObjectTransformer.register(Class)
.
Subclasses may only specify the default constructor. Any code
inside that constructor is optional, but will not run when the
view is instantiated, see runViewConstructor()
.
Bounds checking may be enabled through a JVM system property: org.lwjgl.util.mapped.Checks=trueModifier and Type | Field and Description |
---|---|
long |
baseAddress
The mapped object base memory address, in bytes.
|
static int |
SIZEOF
Holds the value of sizeof of the sub-type of this MappedObject
The behavior of this (transformed) method does not follow the normal Java behavior. Vec2.SIZEOF will yield 8 (2 floats)Vec3.SIZEOF will yield 12 (3 floats)This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access"). Using Java 5.0's static-import on this method will break functionality. |
int |
view
The mapped object view offset, in elements.
|
long |
viewAddress
The mapped object view memory address, in bytes.
|
Modifier | Constructor and Description |
---|---|
protected |
MappedObject() |
Modifier and Type | Method and Description |
---|---|
<T extends MappedObject> |
asArray() |
java.nio.ByteBuffer |
backingByteBuffer()
Returns the
ByteBuffer that backs this mapped object. |
int |
capacity()
Returns the number of mapped objects that fit in the mapped buffer.
|
<T extends MappedObject> |
copyRange(T target,
int instances)
Copies and amount of
SIZEOF * instances bytes, from the
current mapped object, to the specified mapped object. |
<T extends MappedObject> |
copyTo(T target)
Copies and amount of
SIZEOF - padding bytes, from the current
mapped object, to the specified mapped object. |
<T extends MappedObject> |
dup()
Creates an identical new MappedObject instance, comparable to the
contract of
ByteBuffer.duplicate() . |
static <T extends MappedObject> |
foreach(T mapped)
Creates an
Iterable capacity() views, leaving the view at
the last valid value.For convenience you are encouraged to static-import this specific method: import static org.lwjgl.util.mapped.MappedObject.foreach; |
static <T extends MappedObject> |
foreach(T mapped,
int elementCount)
Creates an
Iterable elementCount views, leaving the view at
the last valid value.For convenience you are encouraged to static-import this specific method: import static org.lwjgl.util.mapped.MappedObject.foreach; |
int |
getAlign()
Returns the mapped object memory alignment, in bytes.
|
int |
getSizeof()
Returns the mapped object memory sizeof, in bytes.
|
protected long |
getViewAddress(int view) |
static <T extends MappedObject> |
malloc(int elementCount)
Creates a MappedObject instance, mapping the memory region of an allocated direct ByteBuffer with a capacity of
elementCount*SIZEOF
The behavior of this (transformed) method does not follow the normal Java behavior.Vec2.malloc(int) will return a mapped Vec2 instance.Vec3.malloc(int) will return a mapped Vec3 instance.This (required) notation might cause compiler warnings, which can be suppressed with @SuppressWarnings("static-access"). Using Java 5.0's static-import on this method will break functionality. |
static <T extends MappedObject> |
map(java.nio.ByteBuffer bb)
Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer.
|
static <T extends MappedObject> |
map(long address,
int capacity)
Creates a MappedObject instance, mapping the memory region specified.
|
void |
next()
Moves the current view to the next element.
|
void |
runViewConstructor()
Any code in the default constructor will not run automatically.
|
void |
setViewAddress(long address) |
<T extends MappedObject> |
slice()
Creates a new MappedObject instance, with a base offset equal to
the offset of the current view, comparable to the contract of
ByteBuffer.slice() . |
public long baseAddress
public long viewAddress
public static int SIZEOF
Vec2.SIZEOF
will yield 8 (2 floats)Vec3.SIZEOF
will yield 12 (3 floats)public int view
viewAddress
.protected final long getViewAddress(int view)
public final void setViewAddress(long address)
public final int getAlign()
public final int getSizeof()
public final int capacity()
public static <T extends MappedObject> T map(java.nio.ByteBuffer bb)
Vec2.map(buffer)
will return a mapped Vec2 instance.Vec3.map(buffer)
will return a mapped Vec3 instance.public static <T extends MappedObject> T map(long address, int capacity)
Vec2.map(buffer)
will return a mapped Vec2 instance.Vec3.map(buffer)
will return a mapped Vec3 instance.public static <T extends MappedObject> T malloc(int elementCount)
elementCount*SIZEOF
The behavior of this (transformed) method does not follow the normal Java behavior.Vec2.malloc(int)
will return a mapped Vec2 instance.Vec3.malloc(int)
will return a mapped Vec3 instance.public final <T extends MappedObject> T dup()
ByteBuffer.duplicate()
. This is useful when more than one
views of the mapped object are required at the same time, e.g. in
multithreaded access.public final <T extends MappedObject> T slice()
ByteBuffer.slice()
.public final void runViewConstructor()
public final void next()
public final <T extends MappedObject> void copyTo(T target)
SIZEOF - padding
bytes, from the current
mapped object, to the specified mapped object.public final <T extends MappedObject> void copyRange(T target, int instances)
SIZEOF * instances
bytes, from the
current mapped object, to the specified mapped object. Note that
this includes any padding bytes that are part of SIZEOF.public static <T extends MappedObject> java.lang.Iterable<T> foreach(T mapped)
Iterable
capacity()
views, leaving the view
at
the last valid value.import static org.lwjgl.util.mapped.MappedObject.foreach;
public static <T extends MappedObject> java.lang.Iterable<T> foreach(T mapped, int elementCount)
Iterable
elementCount
views, leaving the view
at
the last valid value.import static org.lwjgl.util.mapped.MappedObject.foreach;
public final <T extends MappedObject> T[] asArray()
public final java.nio.ByteBuffer backingByteBuffer()
ByteBuffer
that backs this mapped object.Copyright © 2002-2009 lwjgl.org. All Rights Reserved.