com.io7m.smfj.format.binary.v1.SMFBV1HeaderByteBuffered Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of io7m-smfj-format-binary Show documentation
Show all versions of io7m-smfj-format-binary Show documentation
Sequential mesh format (Binary format)
The newest version!
package com.io7m.smfj.format.binary.v1;
import com.io7m.jpra.runtime.java.JPRACursorByteReadableType;
import com.io7m.jpra.runtime.java.JPRATypeModel;
import java.lang.Override;
import java.nio.ByteBuffer;
import java.util.Objects;
/**
* A {@code ByteBuffer} based implementation of the {@code SMFBV1Header} record type. */
public final class SMFBV1HeaderByteBuffered implements SMFBV1HeaderType {
private static final int SIZE_OCTETS = 56;
private static final int FIELD_SCHEMA_OFFSET_OCTETS = 0;
private static final int FIELD_VERTEX_COUNT_OFFSET_OCTETS = 16;
private static final int FIELD_TRIANGLE_COUNT_OFFSET_OCTETS = 24;
private static final int FIELD_TRIANGLE_INDEX_SIZE_BITS_OFFSET_OCTETS = 32;
private static final int FIELD_COORDINATE_SYSTEM_OFFSET_OCTETS = 36;
private static final int FIELD_META_COUNT_OFFSET_OCTETS = 44;
private static final int FIELD_ATTRIBUTE_COUNT_OFFSET_OCTETS = 48;
private final ByteBuffer buffer;
private final int base_offset;
private final JPRACursorByteReadableType pointer;
private final SMFBV1SchemaIDType field_schema;
private final JPRATypeModel.JPRAUserDefined meta_type_schema;
private final JPRATypeModel.JPRAIntegerUnsigned meta_type_vertex_count;
private final JPRATypeModel.JPRAIntegerUnsigned meta_type_triangle_count;
private final JPRATypeModel.JPRAIntegerUnsigned meta_type_triangle_index_size_bits;
private final SMFBV1CoordinateSystemsType field_coordinate_system;
private final JPRATypeModel.JPRAUserDefined meta_type_coordinate_system;
private final JPRATypeModel.JPRAIntegerUnsigned meta_type_meta_count;
private final JPRATypeModel.JPRAIntegerUnsigned meta_type_attribute_count;
private SMFBV1HeaderByteBuffered(final ByteBuffer in_buffer, final JPRACursorByteReadableType in_pointer, final int in_base_offset) {
this.buffer = Objects.requireNonNull(in_buffer, "Buffer");
this.pointer = Objects.requireNonNull(in_pointer, "Pointer");
this.base_offset = in_base_offset;
this.field_schema = SMFBV1SchemaIDByteBuffered.newValueWithOffset(in_buffer, in_pointer, in_base_offset + FIELD_SCHEMA_OFFSET_OCTETS);
this.meta_type_schema = JPRATypeModel.JPRAUserDefined.of(SMFBV1SchemaIDType.class);
this.meta_type_vertex_count = JPRATypeModel.JPRAIntegerUnsigned.of(64);
this.meta_type_triangle_count = JPRATypeModel.JPRAIntegerUnsigned.of(64);
this.meta_type_triangle_index_size_bits = JPRATypeModel.JPRAIntegerUnsigned.of(32);
this.field_coordinate_system = SMFBV1CoordinateSystemsByteBuffered.newValueWithOffset(in_buffer, in_pointer, in_base_offset + FIELD_COORDINATE_SYSTEM_OFFSET_OCTETS);
this.meta_type_coordinate_system = JPRATypeModel.JPRAUserDefined.of(SMFBV1CoordinateSystemsType.class);
this.meta_type_meta_count = JPRATypeModel.JPRAIntegerUnsigned.of(32);
this.meta_type_attribute_count = JPRATypeModel.JPRAIntegerUnsigned.of(64);
}
/**
* Construct a view of a type.
* @param in_buffer A byte buffer
* @param in_pointer A cursor
* @param in_base_offset The base offset from the cursor
* @return A view of a type
*/
public static SMFBV1HeaderType newValueWithOffset(final ByteBuffer in_buffer, final JPRACursorByteReadableType in_pointer, final int in_base_offset) {
return new SMFBV1HeaderByteBuffered(in_buffer, in_pointer, in_base_offset);
}
/**
* Construct a view of a type.
* @param in_buffer A byte buffer
* @param in_pointer A cursor
* @return A view of a type
*/
public static SMFBV1HeaderType newValue(final ByteBuffer in_buffer, final JPRACursorByteReadableType in_pointer) {
return new SMFBV1HeaderByteBuffered(in_buffer, in_pointer, 0);
}
@Override
public int sizeOctets() {
return SIZE_OCTETS;
}
/**
* @return The size of the type in octets
*/
public static int sizeInOctets() {
return SIZE_OCTETS;
}
private int getByteOffsetFor(final int field_offset) {
final int b = (int) this.pointer.getByteOffsetObservable().get();
return b + this.base_offset + field_offset;
}
@Override
public int metaSchemaOffsetFromType() {
return FIELD_SCHEMA_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code schema} from the start of the type
*/
public static int metaSchemaStaticOffsetFromType() {
return FIELD_SCHEMA_OFFSET_OCTETS;
}
@Override
public int metaSchemaOffsetFromCursor() {
return FIELD_SCHEMA_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAUserDefined metaSchemaType() {
return this.meta_type_schema;
}
@Override
public SMFBV1SchemaIDReadableType getSchemaReadable() {
return this.field_schema;
}
@Override
public SMFBV1SchemaIDType getSchemaWritable() {
return this.field_schema;
}
@Override
public int metaVertexCountOffsetFromType() {
return FIELD_VERTEX_COUNT_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code vertex_count} from the start of the type
*/
public static int metaVertexCountStaticOffsetFromType() {
return FIELD_VERTEX_COUNT_OFFSET_OCTETS;
}
@Override
public int metaVertexCountOffsetFromCursor() {
return FIELD_VERTEX_COUNT_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAIntegerUnsigned metaVertexCountType() {
return this.meta_type_vertex_count;
}
@Override
public long getVertexCount() {
return this.buffer.getLong(this.getByteOffsetFor(FIELD_VERTEX_COUNT_OFFSET_OCTETS));
}
@Override
public void setVertexCount(final long x) {
this.buffer.putLong(this.getByteOffsetFor(FIELD_VERTEX_COUNT_OFFSET_OCTETS), x);
}
@Override
public int metaTriangleCountOffsetFromType() {
return FIELD_TRIANGLE_COUNT_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code triangle_count} from the start of the type
*/
public static int metaTriangleCountStaticOffsetFromType() {
return FIELD_TRIANGLE_COUNT_OFFSET_OCTETS;
}
@Override
public int metaTriangleCountOffsetFromCursor() {
return FIELD_TRIANGLE_COUNT_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAIntegerUnsigned metaTriangleCountType() {
return this.meta_type_triangle_count;
}
@Override
public long getTriangleCount() {
return this.buffer.getLong(this.getByteOffsetFor(FIELD_TRIANGLE_COUNT_OFFSET_OCTETS));
}
@Override
public void setTriangleCount(final long x) {
this.buffer.putLong(this.getByteOffsetFor(FIELD_TRIANGLE_COUNT_OFFSET_OCTETS), x);
}
@Override
public int metaTriangleIndexSizeBitsOffsetFromType() {
return FIELD_TRIANGLE_INDEX_SIZE_BITS_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code triangle_index_size_bits} from the start of the type
*/
public static int metaTriangleIndexSizeBitsStaticOffsetFromType() {
return FIELD_TRIANGLE_INDEX_SIZE_BITS_OFFSET_OCTETS;
}
@Override
public int metaTriangleIndexSizeBitsOffsetFromCursor() {
return FIELD_TRIANGLE_INDEX_SIZE_BITS_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAIntegerUnsigned metaTriangleIndexSizeBitsType() {
return this.meta_type_triangle_index_size_bits;
}
@Override
public int getTriangleIndexSizeBits() {
return this.buffer.getInt(this.getByteOffsetFor(FIELD_TRIANGLE_INDEX_SIZE_BITS_OFFSET_OCTETS));
}
@Override
public void setTriangleIndexSizeBits(final int x) {
this.buffer.putInt(this.getByteOffsetFor(FIELD_TRIANGLE_INDEX_SIZE_BITS_OFFSET_OCTETS), x);
}
@Override
public int metaCoordinateSystemOffsetFromType() {
return FIELD_COORDINATE_SYSTEM_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code coordinate_system} from the start of the type
*/
public static int metaCoordinateSystemStaticOffsetFromType() {
return FIELD_COORDINATE_SYSTEM_OFFSET_OCTETS;
}
@Override
public int metaCoordinateSystemOffsetFromCursor() {
return FIELD_COORDINATE_SYSTEM_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAUserDefined metaCoordinateSystemType() {
return this.meta_type_coordinate_system;
}
@Override
public SMFBV1CoordinateSystemsReadableType getCoordinateSystemReadable() {
return this.field_coordinate_system;
}
@Override
public SMFBV1CoordinateSystemsType getCoordinateSystemWritable() {
return this.field_coordinate_system;
}
@Override
public int metaMetaCountOffsetFromType() {
return FIELD_META_COUNT_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code meta_count} from the start of the type
*/
public static int metaMetaCountStaticOffsetFromType() {
return FIELD_META_COUNT_OFFSET_OCTETS;
}
@Override
public int metaMetaCountOffsetFromCursor() {
return FIELD_META_COUNT_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAIntegerUnsigned metaMetaCountType() {
return this.meta_type_meta_count;
}
@Override
public int getMetaCount() {
return this.buffer.getInt(this.getByteOffsetFor(FIELD_META_COUNT_OFFSET_OCTETS));
}
@Override
public void setMetaCount(final int x) {
this.buffer.putInt(this.getByteOffsetFor(FIELD_META_COUNT_OFFSET_OCTETS), x);
}
@Override
public int metaAttributeCountOffsetFromType() {
return FIELD_ATTRIBUTE_COUNT_OFFSET_OCTETS;
}
/**
* @return The offset in octets of field {@code attribute_count} from the start of the type
*/
public static int metaAttributeCountStaticOffsetFromType() {
return FIELD_ATTRIBUTE_COUNT_OFFSET_OCTETS;
}
@Override
public int metaAttributeCountOffsetFromCursor() {
return FIELD_ATTRIBUTE_COUNT_OFFSET_OCTETS + this.base_offset;
}
@Override
public JPRATypeModel.JPRAIntegerUnsigned metaAttributeCountType() {
return this.meta_type_attribute_count;
}
@Override
public long getAttributeCount() {
return this.buffer.getLong(this.getByteOffsetFor(FIELD_ATTRIBUTE_COUNT_OFFSET_OCTETS));
}
@Override
public void setAttributeCount(final long x) {
this.buffer.putLong(this.getByteOffsetFor(FIELD_ATTRIBUTE_COUNT_OFFSET_OCTETS), x);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy