|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.lwjgl.util.mapped.MappedObject
public abstract class MappedObject
Base superclass of all mapped objects. Classes that require
data mapping should extend this class and registered with
MappedObjectTransformer.register(Class)
.
runViewConstructor()
.
Bounds checking may be enabled through a JVM system property: org.lwjgl.util.mapped.Checks=true
Field Summary | |
---|---|
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. |
int |
view
The mapped object view offset, in elements. |
long |
viewAddress
The mapped object view memory address, in bytes. |
Constructor Summary | |
---|---|
protected |
MappedObject()
|
Method Summary | ||
---|---|---|
|
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. |
|
|
copyRange(T target,
int instances)
Copies and amount of SIZEOF * instances bytes, from the
current mapped object, to the specified mapped object. |
|
|
copyTo(T target)
Copies and amount of SIZEOF - padding bytes, from the current
mapped object, to the specified mapped object. |
|
|
dup()
Creates an identical new MappedObject instance, comparable to the contract of ByteBuffer.duplicate() . |
|
static
|
foreach(T mapped)
Creates an Iterable capacity() views, leaving the view at
the last valid value. |
|
static
|
foreach(T mapped,
int elementCount)
Creates an Iterable elementCount views, leaving the view at
the last valid value. |
|
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
|
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. |
|
static
|
map(java.nio.ByteBuffer bb)
Creates a MappedObject instance, mapping the memory region of the specified direct ByteBuffer. |
|
static
|
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)
|
|
|
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() . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
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
.
Constructor Detail |
---|
protected MappedObject()
Method Detail |
---|
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.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |