public class FieldManyToOne<T extends NdNode> extends java.lang.Object implements IDestructableField, IField, 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 |
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 NdNode,B extends NdNode> |
create(StructDef<B> builder,
FieldOneToMany<B> forwardPointer) |
static <T extends NdNode,B extends NdNode> |
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) |
int |
getRecordSize() |
boolean |
hasReferences(Nd nd,
long address)
Returns true if this field knows of any remaining incoming references to this object.
|
void |
put(Nd nd,
long address,
long newTargetAddress) |
void |
put(Nd nd,
long address,
T value)
Directs this pointer to the given target.
|
void |
setOffset(int offset) |
public static final FieldPointer TARGET
public static final FieldInt BACKPOINTER_INDEX
public final boolean pointsToOwner
public static <T extends NdNode,B extends NdNode> FieldManyToOne<T> create(StructDef<B> builder, FieldOneToMany<B> forwardPointer)
public static <T extends NdNode,B extends NdNode> 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 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()
getRecordSize 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 IRefCountedField