Open 3D Engine AzCore API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::DataPatch Class Reference

#include <DataPatch.h>

Classes

struct  LegacyStreamWrapper
 

Public Types

enum  Flag : Flags {
  ForceOverrideSet = 1 << 0 , PreventOverrideSet = 1 << 1 , HidePropertySet = 1 << 2 , ForceOverrideEffect = 1 << 4 ,
  PreventOverrideEffect = 1 << 5 , HidePropertyEffect = 1 << 6 , SetMask = 0x0F , EffectMask = 0xF0
}
 
using Flags = AZ::u8
 
using AddressTypeElement = DataPatchInternal::AddressTypeElement
 Alias the DataPatchInternal::AddressType inside the DataPatch declaration for backwards compatibility with DataPatch::AddressType.
 
using AddressType = DataPatchInternal::AddressType
 
using PatchMap = DataPatchInternal::PatchMap
 
using ChildPatchMap = DataPatchInternal::ChildPatchMap
 
using FlagsMap = AZStd::unordered_map< AddressType, Flags >
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (DataPatch, SystemAllocator)
 
 DataPatch (const DataPatch &rhs)
 
 DataPatch (DataPatch &&rhs)
 
DataPatchoperator= (DataPatch &&rhs)
 
DataPatchoperator= (const DataPatch &rhs)
 
bool Create (const void *source, const Uuid &souceClassId, const void *target, const Uuid &targetClassId, const FlagsMap &sourceFlagsMap=FlagsMap(), const FlagsMap &targetFlagsMap=FlagsMap(), SerializeContext *context=nullptr)
 
template<class T , class U >
bool Create (const T *source, const U *target, const FlagsMap &sourceFlagsMap=FlagsMap(), const FlagsMap &targetFlagsMap=FlagsMap(), SerializeContext *context=nullptr)
 T and U should either be the same type a common base class.
 
void * Apply (const void *source, const Uuid &sourceClassId, SerializeContext *context=nullptr, const AZ::ObjectStream::FilterDescriptor &filterDesc=AZ::ObjectStream::FilterDescriptor(), const FlagsMap &sourceFlagsMap=FlagsMap(), const FlagsMap &targetFlagsMap=FlagsMap()) const
 
template<class T >
T * Apply (const T *source, SerializeContext *context=nullptr, const AZ::ObjectStream::FilterDescriptor &filterDesc=AZ::ObjectStream::FilterDescriptor(), const FlagsMap &sourceFlagsMap=FlagsMap(), const FlagsMap &targetFlagsMap=FlagsMap()) const
 
template<class U , class T >
U * Apply (const T *source, SerializeContext *context=nullptr, const AZ::ObjectStream::FilterDescriptor &filterDesc=AZ::ObjectStream::FilterDescriptor(), const FlagsMap &sourceFlagsMap=FlagsMap(), const FlagsMap &targetFlagsMap=FlagsMap()) const
 
bool IsValid () const
 
bool IsData () const
 

Static Public Member Functions

static Flags GetEffectOfParentFlagsOnThisAddress (Flags flagsAtParentAddress)
 
static Flags GetEffectOfSourceFlagsOnThisAddress (Flags flagsAtSourceAddress)
 
static Flags GetEffectOfTargetFlagsOnThisAddress (Flags flagsAtTargetAddress)
 Given data flags for target data at this address, return the effect on a DataPatch.
 
static void Reflect (ReflectContext *context)
 
static AZ_INLINE const AZ::Uuid GetLegacyDataPatchTypeId ()
 

Protected Attributes

Uuid m_targetClassId
 
unsigned int m_targetClassVersion
 
PatchMap m_patch
 

Detailed Description

Structure that contains patch data for a given class. The primary goal of this object is to help with tools (slices and undo/redo), this structure is not recommended to runtime due to efficiency. If you want dynamically configure objects, use data overlay which are more efficient and generic.

Member Typedef Documentation

◆ Flags

using AZ::DataPatch::Flags = AZ::u8

Data addresses can be tagged with flags to affect how patches are created and applied.

◆ FlagsMap

Data flags, mapped by the address where the flags are set. When patching, an address is affected not only by the flags set AT that address, but also the flags set at any parent address.

Member Enumeration Documentation

◆ Flag

Bit fields for data flags. These options affect how patches are created and applied. There are two categories of flags:

  1. Set: These flags are manually set by users at a specific address. They are serialized to disk.
  2. Effect: These flags denote the addresses influenced by a "Set" flag. They are runtime-only and should not be serialized to disk.
Enumerator
ForceOverrideSet 

Data at this address always overrides data from the source.

PreventOverrideSet 

Data at this address can't be overridden by a target.

HidePropertySet 

The property associated with this address will be hidden when viewing a target.

ForceOverrideEffect 

Data at this address is affected by ForceOverride and always overrides its source.

PreventOverrideEffect 

Data at this address is affected by PreventOverride and cannot override its source.

HidePropertyEffect 

Data at this address is affected by HideProperty and cannot be seen when viewing the target.

Member Function Documentation

◆ Apply()

void * AZ::DataPatch::Apply ( const void *  source,
const Uuid sourceClassId,
SerializeContext context = nullptr,
const AZ::ObjectStream::FilterDescriptor filterDesc = AZ::ObjectStream::FilterDescriptor(),
const FlagsMap sourceFlagsMap = FlagsMap(),
const FlagsMap targetFlagsMap = FlagsMap() 
) const

Apply the patch to a source instance and generate a patched instance, from a source instance. If patch can't be applied a null pointer is returned. Currently the only reason for that is if the resulting class ID doesn't match the stored root of the patch.

Parameters
sourcepointer to the source instance.
sourceClassIDid of the class source is pointing to.
contextif null we will grab the default serialize context.
filterDesccustomizable filter for data in patch (ex: filter out classes and assets)
sourceFlagsMapflags for source data. These may affect how a patch is applied (ex: prevent patching of specific addresses)
targetFlagsMapflags for target data. These may affect how a patch is applied.

◆ AZ_CLASS_ALLOCATOR()

AZ::DataPatch::AZ_CLASS_ALLOCATOR ( DataPatch  ,
SystemAllocator   
)

Data Patches have been updated to be human readable. For backwards compatibility the DataPatch type Uuid has been modified and a deprecation converter is used to convert.

◆ Create()

bool AZ::DataPatch::Create ( const void *  source,
const Uuid souceClassId,
const void *  target,
const Uuid targetClassId,
const FlagsMap sourceFlagsMap = FlagsMap(),
const FlagsMap targetFlagsMap = FlagsMap(),
SerializeContext context = nullptr 
)

Create a patch structure which generate the delta (patcher) from source to the target type.

Parameters
sourceobject we will use a base for the delta
souceClassIdclass of the source type, either the same as targetClassId or a base class
targetobject we want to have is we have source and apply the returned patcher.
targetClassIdclass of the target type, either the same as sourceClassId or a base class
sourceFlagsMap(optional) flags for source data. These may affect how the patch is created (ex: prevent patches at specific addresses)
targetFlagsMap(optional) flags for target data. These may affect how the patch is created (ex: force patches at specific addresses)
contextif null we will grab the default serialize context.

◆ GetEffectOfParentFlagsOnThisAddress()

static Flags AZ::DataPatch::GetEffectOfParentFlagsOnThisAddress ( Flags  flagsAtParentAddress)
static

Given data flags affecting the parent address, return the effect upon the child address. An example of a parent and child would be a vector and an element in that vector.

◆ GetEffectOfSourceFlagsOnThisAddress()

static Flags AZ::DataPatch::GetEffectOfSourceFlagsOnThisAddress ( Flags  flagsAtSourceAddress)
static

Given data flags for source data at this address, return the effect on a DataPatch. An example of source data would be the slice upon which a slice-instance is based.

◆ IsData()

bool AZ::DataPatch::IsData ( ) const
inline
Returns
true of the patch actually contains data for patching otherwise false.

◆ IsValid()

bool AZ::DataPatch::IsValid ( ) const
inline
Returns
true if this is a valid patch.

◆ Reflect()

static void AZ::DataPatch::Reflect ( ReflectContext context)
static

Reflect a patch for serialization.


The documentation for this class was generated from the following file: