Package de.linusdev.lutils.struct.mod
Class ModTrackingStructure
java.lang.Object
de.linusdev.lutils.struct.abstracts.Structure
de.linusdev.lutils.struct.mod.ModTrackingStructure
- All Implemented Interfaces:
MemorySizeable,NativeParsable
- Direct Known Subclasses:
ComplexStructure,StructureArray
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected ReentrantLockprotected final intprotected ModificationInfoprotected final booleanFields inherited from class de.linusdev.lutils.struct.abstracts.Structure
byteBuf, modified, mostParentStructure, offset -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidclaimBuffer(@NotNull ByteBuffer buffer) Will set theByteOrderto native order.@Nullable ModificationInfogetFirstModificationInfo(boolean clear) Get the firstModificationInfo.booleanhandleModifications(@NotNull ModTrackingStructure.ModificationsHandler handler) protected voidonModification(int offset, int size) Called on the most parental structure if on it or any of its childrenStructure.modified(int, int)is called.booleanWhether this structure tracks modifications usingModificationInfo.protected voidSet thisStructureto be a child ofmostParentStructure.Methods inherited from class de.linusdev.lutils.struct.abstracts.Structure
allocate, callUseBufferOf, generateStructCode, getAlignment, getByteBuffer, getInfo, getMostParentStructure, getOffset, getRequiredSize, isInitialised, isModified, modified, modified, toString, unmodifiedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface de.linusdev.lutils.struct.abstracts.NativeParsable
getPointer
-
Field Details
-
trackModifications
protected final boolean trackModifications -
modificationLock
-
modificationSplitOffset
protected final int modificationSplitOffset- See Also:
-
modInfo
-
-
Constructor Details
-
ModTrackingStructure
protected ModTrackingStructure(boolean trackModifications)
-
-
Method Details
-
useBuffer
Description copied from class:StructureSet thisStructureto be a child ofmostParentStructure. -
claimBuffer
Description copied from class:StructureWill set theByteOrderto native order. The most parental structure will bethis.- Overrides:
claimBufferin classStructure- Parameters:
buffer-ByteBufferto claim
-
onModification
protected void onModification(int offset, int size) Description copied from class:StructureCalled on the most parental structure if on it or any of its childrenStructure.modified(int, int)is called.- Overrides:
onModificationin classStructure- Parameters:
offset- modified region startsize- modified region size
-
getFirstModificationInfo
Get the firstModificationInfo. Only available if this structure wasmodifiedandtracks modifications.- Parameters:
clear-trueif the modifications should be cleared.- Returns:
ModificationInfoornull
-
tracksModifications
public boolean tracksModifications()Whether this structure tracks modifications usingModificationInfo. -
handleModifications
public boolean handleModifications(@NotNull @NotNull ModTrackingStructure.ModificationsHandler handler) CallsModTrackingStructure.ModificationsHandler.handle(ModificationInfo)for eachModificationInfo. If this structure was notmodified,falsewill be returned.- Parameters:
handler-ModTrackingStructure.ModificationsHandler- Returns:
trueif this structure wasmodified.
-