org.jocl.struct
Class Buffers

java.lang.Object
  extended by org.jocl.struct.Buffers

public class Buffers
extends java.lang.Object

A class containing methods for allocating buffers, and for reading and writing Struct and CLTypes.* objects from and to buffers.


Method Summary
static java.nio.ByteBuffer allocateBuffer(java.nio.ByteOrder byteOrder, Struct... structs)
          Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects, and has the given byte order.
static
<T extends org.jocl.struct.CLTypes.cl_vector_type>
java.nio.ByteBuffer
allocateBuffer(java.nio.ByteOrder byteOrder, T... elements)
          Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects, and has the given byte order.
static java.nio.ByteBuffer allocateBuffer(Struct... structs)
          Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects.
static
<T extends org.jocl.struct.CLTypes.cl_vector_type>
java.nio.ByteBuffer
allocateBuffer(T... elements)
          Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects.
static void readFromBuffer(java.nio.ByteBuffer sourceBuffer, Struct... structs)
          Reads the given objects from the given source buffer.
static
<T extends org.jocl.struct.CLTypes.cl_vector_type>
void
readFromBuffer(java.nio.ByteBuffer sourceBuffer, T... elements)
          Reads the given objects from the given source buffer.
static void writeToBuffer(java.nio.ByteBuffer targetBuffer, Struct... structs)
          Writes the given objects to the given target buffer.
static
<T extends org.jocl.struct.CLTypes.cl_vector_type>
void
writeToBuffer(java.nio.ByteBuffer targetBuffer, T... elements)
          Writes the given objects to the given target buffer.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

allocateBuffer

public static java.nio.ByteBuffer allocateBuffer(Struct... structs)
Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects. The Buffer will have the default (native) byte order.

Parameters:
structs - The objects for which the buffer should be allocated
Returns:
A newly allocated ByteBuffer

allocateBuffer

public static java.nio.ByteBuffer allocateBuffer(java.nio.ByteOrder byteOrder,
                                                 Struct... structs)
Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects, and has the given byte order.

Parameters:
byteOrder - The byte order for the buffer.
structs - The objects for which the buffer should be allocated
Returns:
A newly allocated ByteBuffer

writeToBuffer

public static void writeToBuffer(java.nio.ByteBuffer targetBuffer,
                                 Struct... structs)
Writes the given objects to the given target buffer.

Parameters:
targetBuffer - The buffer to write to
structs - The objects to write
Throws:
java.lang.IllegalArgumentException - If the given objects array is null, has a length of 0 or contains 'null' elements, or if the given buffer is null or has not enough bytes remaining to write the given objects to it.

readFromBuffer

public static void readFromBuffer(java.nio.ByteBuffer sourceBuffer,
                                  Struct... structs)
Reads the given objects from the given source buffer.

Parameters:
sourceBuffer - The buffer to read from
structs - The objects to read
Throws:
java.lang.IllegalArgumentException - If the given objects array is null, has a length of 0 or contains 'null' elements, or if the given buffer is null or has not enough bytes remaining to read the given objects from it.

allocateBuffer

public static <T extends org.jocl.struct.CLTypes.cl_vector_type> java.nio.ByteBuffer allocateBuffer(T... elements)
Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects. The Buffer will have the default (native) byte order.

Parameters:
elements - The objects for which the buffer should be allocated
Returns:
A newly allocated ByteBuffer

allocateBuffer

public static <T extends org.jocl.struct.CLTypes.cl_vector_type> java.nio.ByteBuffer allocateBuffer(java.nio.ByteOrder byteOrder,
                                                                                                    T... elements)
Allocates a new ByteBuffer that has a size and alignment that is sufficient to buffer the given objects, and has the given byte order.

Parameters:
byteOrder - The byte order for the buffer.
elements - The objects for which the buffer should be allocated
Returns:
A newly allocated ByteBuffer

writeToBuffer

public static <T extends org.jocl.struct.CLTypes.cl_vector_type> void writeToBuffer(java.nio.ByteBuffer targetBuffer,
                                                                                    T... elements)
Writes the given objects to the given target buffer.

Parameters:
targetBuffer - The buffer to write to
elements - The objects to write
Throws:
java.lang.IllegalArgumentException - If the given objects array is null, has a length of 0 or contains 'null' elements, or if the given buffer is null or has not enough bytes remaining to write the given objects to it.

readFromBuffer

public static <T extends org.jocl.struct.CLTypes.cl_vector_type> void readFromBuffer(java.nio.ByteBuffer sourceBuffer,
                                                                                     T... elements)
Reads the given objects from the given source buffer.

Parameters:
sourceBuffer - The buffer to read from
elements - The objects to read
Throws:
java.lang.IllegalArgumentException - If the given objects array is null, has a length of 0 or contains 'null' elements, or if the given buffer is null or has not enough bytes remaining to read the given objects from it.