class ManagedSerializableDelta

Inherits: IReflectable

Handles creation and applying of managed deltas.

A delta contains differences between two objects of identical types. If the initial state of an object is known the recorded differences can be saved and applied to the original state to restore the modified object.

Differences are recorded per primitive field in an object. Complex objects are recursed. Special handling is implemented to properly generate deltas for individual entries within arrays, lists and dictionaries.

All primitive types supported by managed serialization are supported (see ScriptPrimitiveType).

Public

Constructors

ManagedSerializableDelta

ManagedSerializableDelta()

Methods

~ManagedSerializableDelta

~ManagedSerializableDelta() noexcept = default

staticCreate

static SPtr<ManagedSerializableDelta> Create(const ManagedSerializableObject *original, const ManagedSerializableObject *modified, RTTIOperationContext *context = nullptr)

Generates a new managed delta by comparing two objects.

Caller must ensure both objects are not null and of identical types.

original
Original object to compared with . This is the object you can apply the delta to to convert it to .
modified
Modified object. Any values in this object that differ from the original object will be recorded in the delta.

Returns: Returns null if objects are identical.

Apply

void Apply(const SPtr<ManagedSerializableObject> &object)

Applies the delta stored in this object to the specified object, modifying all fields in the object to correspond to the delta.

staticGetRttiStatic

static RTTIType *GetRttiStatic()

GetRtti

RTTIType *GetRtti() const override

Returns an interface you can use to access class' Run Time Type Information.

Private

Methods

GenerateObjectDelta

SPtr<ModifiedObject> GenerateObjectDelta(const ManagedSerializableObject *original, const ManagedSerializableObject *modified, RTTIOperationContext *context)

Recursively generates a delta between all fields of the specified objects.

Returns null if objects are identical.

GenerateFieldDelta

SPtr<Modification> GenerateFieldDelta(const SPtr<ManagedSerializableFieldData> &original, const SPtr<ManagedSerializableFieldData> &modified, u32 fieldTypeId, RTTIOperationContext *context)

Generates a delta between two fields.

Fields can be of any type and the system will generate the delta appropriately. Delta is generated recursively on all complex objects. Returns null if fields contain identical data.

ApplyObjectDelta

SPtr<ManagedSerializableFieldData> ApplyObjectDelta(const SPtr<ModifiedObject> &delta, const SPtr<ManagedSerializableObject> &object)

Applies an object modification to a managed object.

Modifications are applied recursively.

delta
Object modification to apply.
object
Object to apply the modification to.

Returns: New field data in the case modification needed the object to be re-created instead of just modified.

ApplyArrayDelta

SPtr<ManagedSerializableFieldData> ApplyArrayDelta(const SPtr<ModifiedArray> &delta, const SPtr<ManagedSerializableArray> &object)

Applies an array modification to a managed array.

Modifications are applied recursively.

delta
Array modification to apply.
object
Array to apply the modification to.

Returns: New field data in the case modification needed the array to be re-created instead of just modified.

ApplyListDelta

SPtr<ManagedSerializableFieldData> ApplyListDelta(const SPtr<ModifiedArray> &delta, const SPtr<ManagedSerializableList> &object)

Applies an list modification to a managed list.

Modifications are applied recursively.

delta
List modification to apply.
object
List to apply the modification to.

Returns: New field data in the case modification needed the list to be re-created instead of just modified.

ApplyDictionaryDelta

SPtr<ManagedSerializableFieldData> ApplyDictionaryDelta(const SPtr<ModifiedDictionary> &delta, const SPtr<ManagedSerializableDictionary> &object)

Applies an dictionary modification to a managed dictionary.

Modifications are applied recursively.

delta
Dictionary modification to apply.
object
Dictionary to apply the modification to.

Returns: New field data in the case modification needed the dictionary to be re-created instead of just modified.

ApplyDiff

SPtr<ManagedSerializableFieldData> ApplyDiff(const SPtr<Modification> &delta, const SPtr<ManagedTypeInfo> &fieldType, const SPtr<ManagedSerializableFieldData> &fieldData)

Applies a modification to a single field.

Field type is determined and the modification is applied to the specific field type as needed. Modifications are applied recursively.

delta
Modification to apply.
fieldType
Type of the field we're applying the modification to.
fieldData
Original data of the field, to apply the modification to.

Returns: New field data in the case modification needed the field data to be re-created instead of just modified.

Fields

mModificationRoot

SPtr<ModifiedObject> mModificationRoot