Package mpi
Class Struct
- java.lang.Object
-
- mpi.Struct
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
Struct.Data
Base class for reading/writing data in a struct stored in a byte buffer.
-
Constructor Summary
Constructors Constructor Description Struct()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description int
addByte()
Adds a byte field to this struct.int
addByte(int length)
Adds a byte array to this struct.int
addChar()
Adds a char field to this struct.int
addChar(int length)
Adds a char array to this struct.int
addData(Datatype type)
Adds a field of the specified data type.int
addData(Datatype type, int length)
Adds an array of the specified data type.int
addDouble()
Adds a double field to this struct.int
addDouble(int length)
Adds a double array to this struct.int
addFloat()
Adds a float field to this struct.int
addFloat(int length)
Adds a float array to this struct.int
addInt()
Adds an int field to this struct.int
addInt(int length)
Adds an int array to this struct.int
addLong()
Adds a long field to this struct.int
addLong(int length)
Adds a long array to this struct.int
addShort()
Adds a short field to this struct.int
addShort(int length)
Adds a short array to this struct.int
addStruct(Struct struct)
Adds a struct field to this struct.int
addStruct(Struct struct, int length)
Adds an array of structs to this struct.<T extends Struct.Data>
TgetData(byte[] array)
<T extends Struct.Data>
TgetData(byte[] array, int index)
<T extends Struct.Data>
TgetData(java.nio.ByteBuffer buffer)
<T extends Struct.Data>
TgetData(java.nio.ByteBuffer buffer, int index)
int
getExtent()
Returns the extent of the struct data type.Datatype
getType()
Returns the data type of the struct.protected abstract Struct.Data
newData()
Creates a Data object.Struct
setOffset(int offset)
Sets the offset of the next field.
-
-
-
Method Detail
-
getExtent
public final int getExtent() throws MPIException
Returns the extent of the struct data type.- Returns:
- Extent of the struct data type.
- Throws:
MPIException
- Signals that an MPI exception of some sort has occurred.
-
getType
public final Datatype getType() throws MPIException
Returns the data type of the struct.- Returns:
- The data type of the struct.
- Throws:
MPIException
- Signals that an MPI exception of some sort has occurred.
-
newData
protected abstract Struct.Data newData()
Creates a Data object.- Returns:
- New Data object.
-
getData
public final <T extends Struct.Data> T getData(java.nio.ByteBuffer buffer) throws MPIException
- Throws:
MPIException
-
getData
public final <T extends Struct.Data> T getData(java.nio.ByteBuffer buffer, int index) throws MPIException
- Throws:
MPIException
-
getData
public final <T extends Struct.Data> T getData(byte[] array) throws MPIException
- Throws:
MPIException
-
getData
public final <T extends Struct.Data> T getData(byte[] array, int index) throws MPIException
- Throws:
MPIException
-
setOffset
public final Struct setOffset(int offset)
Sets the offset of the next field.The offset must be greater or equal to the accumulated extent.
- Parameters:
offset
- offset of the next field- Returns:
- this object in order to allow adding fields in a chained expression
-
addByte
public final int addByte()
Adds a byte field to this struct.- Returns:
- Offset of the new field.
-
addByte
public final int addByte(int length)
Adds a byte array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addChar
public final int addChar()
Adds a char field to this struct.- Returns:
- Offset of the new field.
-
addChar
public final int addChar(int length)
Adds a char array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addShort
public final int addShort()
Adds a short field to this struct.- Returns:
- Offset of the new field.
-
addShort
public final int addShort(int length)
Adds a short array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addInt
public final int addInt()
Adds an int field to this struct.- Returns:
- Offset of the new field.
-
addInt
public final int addInt(int length)
Adds an int array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addLong
public final int addLong()
Adds a long field to this struct.- Returns:
- Offset of the new field.
-
addLong
public final int addLong(int length)
Adds a long array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addFloat
public final int addFloat()
Adds a float field to this struct.- Returns:
- Offset of the new field.
-
addFloat
public final int addFloat(int length)
Adds a float array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addDouble
public final int addDouble()
Adds a double field to this struct.- Returns:
- Offset of the new field.
-
addDouble
public final int addDouble(int length)
Adds a double array to this struct.- Parameters:
length
- Length of the array.- Returns:
- Offset of the new field.
-
addStruct
public final int addStruct(Struct struct) throws MPIException
Adds a struct field to this struct.- Parameters:
struct
- Type of the field.- Returns:
- Offset of the new field.
- Throws:
MPIException
- Signals that an MPI exception of some sort has occurred.
-
addStruct
public final int addStruct(Struct struct, int length) throws MPIException
Adds an array of structs to this struct.- Parameters:
struct
- Type of the array.length
- Length of the array.- Returns:
- Offset of the new field.
- Throws:
MPIException
- Signals that an MPI exception of some sort has occurred.
-
addData
public final int addData(Datatype type) throws MPIException
Adds a field of the specified data type.- Parameters:
type
- Data type.- Returns:
- Offset of the new field.
- Throws:
MPIException
- Signals that an MPI exception of some sort has occurred.
-
addData
public final int addData(Datatype type, int length) throws MPIException
Adds an array of the specified data type.- Parameters:
type
- Data type.length
- Length of the array.- Returns:
- Offset of the new field.
- Throws:
MPIException
- Signals that an MPI exception of some sort has occurred.
-
-