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::IdUtils::Remapper< IdType, AllowDuplicates > Struct Template Reference

#include <IdUtils.h>

Public Types

using IdGenerator = AZStd::function< IdType()>
 
using IdMapper = AZStd::function< IdType(const IdType &originalId, bool replaceId, const IdGenerator &idGenerator)>
 
using IdReplacer = AZStd::function< IdType(const IdType &originalId)>
 

Public Member Functions

unsigned int ReplaceIdsAndIdRefs (SliceComponent::InstantiatedContainer *container, const Remapper< EntityId >::IdMapper &mapper, SerializeContext *context)
 

Static Public Member Functions

static unsigned int RemapIds (void *classPtr, const AZ::Uuid &classUuid, const IdMapper &mapper, AZ::SerializeContext *context, bool replaceId)
 
template<typename T >
static unsigned int RemapIds (T *classPtr, const IdMapper &mapper, AZ::SerializeContext *context, bool replaceId)
 
static unsigned int ReplaceIdsAndIdRefs (void *classPtr, const AZ::Uuid &classUuid, const IdMapper &mapper, AZ::SerializeContext *context=nullptr)
 
template<typename T >
static unsigned int ReplaceIdsAndIdRefs (T *classPtr, const IdMapper &mapper, AZ::SerializeContext *context=nullptr)
 
static unsigned int RemapIdsAndIdRefs (void *classPtr, const AZ::Uuid &classUuid, const IdReplacer &mapper, AZ::SerializeContext *context=nullptr)
 
template<typename T >
static unsigned int RemapIdsAndIdRefs (T *classPtr, const IdReplacer &mapper, AZ::SerializeContext *context=nullptr)
 
template<typename T , typename MapType >
static void GenerateNewIdsAndFixRefs (T *object, MapType &newIdMap, AZ::SerializeContext *context=nullptr)
 
template<class T , class MapType >
static T * CloneObjectAndGenerateNewIdsAndFixRefs (const T *object, MapType &newIdMap, AZ::SerializeContext *context=nullptr)
 

Detailed Description

template<typename IdType, bool AllowDuplicates = false>
struct AZ::IdUtils::Remapper< IdType, AllowDuplicates >
Parameters
AllowDuplicates- If true allows the same id to be registered multiple times, with the newer value overwriting the stored value. If false, duplicates are not allowed and the first stored value is kept.The default is false.

Member Typedef Documentation

◆ IdGenerator

template<typename IdType , bool AllowDuplicates = false>
using AZ::IdUtils::Remapper< IdType, AllowDuplicates >::IdGenerator = AZStd::function<IdType()>

Signature of function that gets passed to the IdMapper to generate a new Id of type IdType The function is retrieved from a AZ::Edit::Attributes::IdGeneratorFunction attribute when processing EditData Data element.

◆ IdMapper

template<typename IdType , bool AllowDuplicates = false>
using AZ::IdUtils::Remapper< IdType, AllowDuplicates >::IdMapper = AZStd::function<IdType(const IdType& originalId, bool replaceId, const IdGenerator& idGenerator)>

Signature of function that is invoked by RemapIds to either generate a new id or to return an existing id

Parameters
originalId- the original Id being remapped
replaceId- boolean that indicates the id supplied should have a new id generated for it
idGenerator- function object which can be invoked to generate a new id. The supplied idGenerator function can be empty, so an empty function check should be performed before invoking

◆ IdReplacer

template<typename IdType , bool AllowDuplicates = false>
using AZ::IdUtils::Remapper< IdType, AllowDuplicates >::IdReplacer = AZStd::function<IdType(const IdType& originalId)>

Signature of function that is invoked by RemapIds to return an existing id

Parameters
originalId- the original Id being remapped

Member Function Documentation

◆ CloneObjectAndGenerateNewIdsAndFixRefs()

template<typename IdType , bool AllowDuplicates = false>
template<class T , class MapType >
static T * AZ::IdUtils::Remapper< IdType, AllowDuplicates >::CloneObjectAndGenerateNewIdsAndFixRefs ( const T *  object,
MapType &  newIdMap,
AZ::SerializeContext context = nullptr 
)
inlinestatic

Clones the supplied object, enumerate over the cloned object and generate new ids of IdType using the newIdMap as both a data source and data sink for remapping ids

Parameters
object- the object to clone
newIdMap- An input/output map container for storing mappings of old IdType values to new IdType values.
context- The serialize context for enumerating the @classPtr elements
Returns
- cloned object with newly remapped ids of type IdType

◆ GenerateNewIdsAndFixRefs()

template<typename IdType , bool AllowDuplicates = false>
template<typename T , typename MapType >
static void AZ::IdUtils::Remapper< IdType, AllowDuplicates >::GenerateNewIdsAndFixRefs ( T *  object,
MapType &  newIdMap,
AZ::SerializeContext context = nullptr 
)
inlinestatic

Enumerates object and generates new ids of IdType using the newIdMap as a data source for remapping ids as well as updating the newIdMap with the remapped Ids

Parameters
object- the object to enumerate
newIdMap- An input/output map container for storing mappings of old IdType values to new IdType values.
context- The serialize context for enumerating the @classPtr elements

◆ RemapIds() [1/2]

template<typename IdType , bool AllowDuplicates = false>
template<typename T >
static unsigned int AZ::IdUtils::Remapper< IdType, AllowDuplicates >::RemapIds ( T *  classPtr,
const IdMapper mapper,
AZ::SerializeContext context,
bool  replaceId 
)
inlinestatic

Template id remap function which which retrieves the type uuid from the supplied object and forwards to the non-template method. Enumerates all elements in the object's hierarchy invoking the IdMapper function on any element that matches @IdType If the IdMapper returns a value different than the originalId that element is updated with the new value

Parameters
classPtr- the object instance to enumerate
mapper- function object which is invoked to retrieve an id mapped from the originalId
context- The serialize context for enumerating the @classPtr elements
replaceId- boolean passed into @mapper function to that indicate that a new id should be generated for the original id. otherwise an id from a map can be returned.

◆ RemapIds() [2/2]

template<typename IdType , bool AllowDuplicates = false>
static unsigned int AZ::IdUtils::Remapper< IdType, AllowDuplicates >::RemapIds ( void *  classPtr,
const AZ::Uuid classUuid,
const IdMapper mapper,
AZ::SerializeContext context,
bool  replaceId 
)
static

Enumerates all elements in the object's hierarchy invoking the IdMapper function on any element that matches @IdType If the IdMapper returns a value different than the originalId that element is updated with the new value

Parameters
classPtr- the object instance to enumerate
classUuid- the object's type id
mapper- function object which is invoked to retrieve an id mapped from the originalId
context- The serialize context for enumerating the @classPtr elements
replaceId- boolean passed into @mapper function to that indicate that a new id should be generated for the original id. otherwise an id from a map can be returned.

◆ RemapIdsAndIdRefs() [1/2]

template<typename IdType , bool AllowDuplicates = false>
template<typename T >
static unsigned int AZ::IdUtils::Remapper< IdType, AllowDuplicates >::RemapIdsAndIdRefs ( T *  classPtr,
const IdReplacer mapper,
AZ::SerializeContext context = nullptr 
)
inlinestatic

Template version of RemapIdsAndIdRefs which retrieves the type uuid from the supplied object and forwards to the non-template method Convenience function for remapping ids in a single pass. Requires that there will be no new id generation, only mapping

Parameters
classPtr- the object instance to enumerate
mapper- function object which is invoked to retrieve an id mapped from the originalId
context- The serialize context for enumerating the @classPtr elements

◆ RemapIdsAndIdRefs() [2/2]

template<typename IdType , bool AllowDuplicates = false>
static unsigned int AZ::IdUtils::Remapper< IdType, AllowDuplicates >::RemapIdsAndIdRefs ( void *  classPtr,
const AZ::Uuid classUuid,
const IdReplacer mapper,
AZ::SerializeContext context = nullptr 
)
static

Convenience function for remapping ids in a single pass. Requires that there will be no new id generation, only mapping

Parameters
classPtr- the object instance to enumerate
classUuid- the object's type id
mapper- function object which is invoked to retrieve an id mapped from the originalId
context- The serialize context for enumerating the @classPtr elements

◆ ReplaceIdsAndIdRefs() [1/2]

template<typename IdType , bool AllowDuplicates = false>
template<typename T >
static unsigned int AZ::IdUtils::Remapper< IdType, AllowDuplicates >::ReplaceIdsAndIdRefs ( T *  classPtr,
const IdMapper mapper,
AZ::SerializeContext context = nullptr 
)
inlinestatic

Template version of ReplaceIdsAndIdRefs which retrieves the type uuid from the supplied object and forwards to the non-template method Convenience function for remapping ids with by supplying both true and false to the @RemapIds function. True indicates that an id is the main instance id and should have a new value generated for it. False indicates that an id is a reference to the main instance id and should retrieve a new value from a map of original Id -> new Id*. First the replaceId parameter is true in RemapIds in order to allow population of an old Id -> new Id Map using the IdMapper functoin. Second the replaceId parameter is false in RemapIds in order to allow id references to be fixed up using the map populated in the first call

Parameters
classPtr- the object instance to enumerate
mapper- function object which is invoked to retrieve an id mapped from the originalId
context- The serialize context for enumerating the @classPtr elements

◆ ReplaceIdsAndIdRefs() [2/2]

template<typename IdType , bool AllowDuplicates>
unsigned int AZ::IdUtils::Remapper< IdType, AllowDuplicates >::ReplaceIdsAndIdRefs ( void *  classPtr,
const AZ::Uuid classUuid,
const IdMapper mapper,
AZ::SerializeContext context = nullptr 
)
static

Convenience function for remapping ids with by supplying both true and false to the @RemapIds function. True indicates that an id is the main instance id and should have a new value generated for it. False indicates that an id is a reference to the main instance id and should retrieve a new value from a map of original Id -> new Id*. First the replaceId parameter is true in RemapIds in order to allow population of an old Id -> new Id Map using the IdMapper functoin. Second the replaceId parameter is false in RemapIds in order to allow id references to be fixed up using the map populated in the first call

Parameters
classPtr- the object instance to enumerate
classUuid- the object's type id
mapper- function object which is invoked to retrieve an id mapped from the originalId
context- The serialize context for enumerating the @classPtr elements

The documentation for this struct was generated from the following files: