public class FieldManyToOne<T extends INdStruct> extends java.lang.Object implements IDestructableField, IRefCountedField
FieldManyToOne forms a one-to-many relationship with FieldOneToMany. Whenever a
FieldManyToOne points to an object, the inverse pointer is automatically inserted into the matching back
pointer list.| Modifier and Type | Field and Description |
|---|---|
static FieldInt |
BACKPOINTER_INDEX |
protected int |
offset |
boolean |
pointsToOwner
True iff the other end of this pointer should delete this object when its end of the pointer is cleared.
|
static FieldPointer |
TARGET |
| Modifier and Type | Method and Description |
|---|---|
static <T extends INdStruct,B extends INdStruct> |
create(StructDef<B> builder,
FieldOneToMany<B> forwardPointer) |
static <T extends INdStruct,B extends INdStruct> |
createNonNull(StructDef<B> builder,
FieldOneToMany<B> forwardPointer) |
static <T extends INdStruct,B extends INdStruct> |
createOwner(StructDef<B> builder,
FieldOneToMany<B> forwardPointer)
Creates a many-to-one pointer which points to this object's owner.
|
void |
destruct(Nd nd,
long address) |
protected void |
detachFromOldTarget(Nd nd,
long address,
long oldTargetAddress) |
T |
get(Nd nd,
long address) |
long |
getAddress(Nd nd,
long address) |
java.lang.String |
getFieldName()
Returns the name of the field.
|
int |
getOffset()
Returns the field offset, in bytes from the start of the struct.
|
int |
getRecordSize()
Returns the size of the field, in bytes.
|
boolean |
hasReferences(Nd nd,
long address)
Returns true if this field knows of any remaining incoming references to this object.
|
FieldManyToOne<T> |
permitNull(boolean permitted)
Sets whether or not this field permits nulls to be assigned.
|
void |
put(Nd nd,
long address,
long newTargetAddress) |
void |
put(Nd nd,
long address,
T value)
Directs this pointer to the given target.
|
protected void |
setFieldName(java.lang.String fieldName) |
void |
setOffset(int offset)
Sets the field offset (bytes from the start of the struct).
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetAlignmentpublic static final FieldPointer TARGET
public static final FieldInt BACKPOINTER_INDEX
public final boolean pointsToOwner
protected int offset
public static <T extends INdStruct,B extends INdStruct> FieldManyToOne<T> createNonNull(StructDef<B> builder, FieldOneToMany<B> forwardPointer)
public static <T extends INdStruct,B extends INdStruct> FieldManyToOne<T> create(StructDef<B> builder, FieldOneToMany<B> forwardPointer)
public static <T extends INdStruct,B extends INdStruct> FieldManyToOne<T> createOwner(StructDef<B> builder, FieldOneToMany<B> forwardPointer)
builder - the struct to which the field will be addedforwardPointer - the field which holds the pointer in the other directionpublic FieldManyToOne<T> permitNull(boolean permitted)
permitted - true iff the field permits nullspublic long getAddress(Nd nd, long address)
public void put(Nd nd, long address, T value)
public void put(Nd nd, long address, long newTargetAddress)
protected void detachFromOldTarget(Nd nd, long address, long oldTargetAddress)
public void destruct(Nd nd, long address)
destruct in interface IDestructableFieldpublic int getRecordSize()
IFieldgetRecordSize in interface IFieldpublic boolean hasReferences(Nd nd, long address)
IRefCountedFieldFieldManyToOne to determine whether or not
a refcounted object should be deleted after a reference is removed.
Implementations should return false if the refcount is 0 or true if the refcount is nonzero.
hasReferences in interface IRefCountedFieldprotected final void setFieldName(java.lang.String fieldName)
public final void setOffset(int offset)
IFieldpublic final int getOffset()
IFieldpublic final java.lang.String getFieldName()
IFieldgetFieldName in interface IField