Open 3D Engine AtomCore 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::Data::InstanceHandler< Type > Struct Template Reference

#include <InstanceDatabase.h>

Public Types

using CreateFunction = AZStd::function< Instance< Type >(AssetData *)>
 
using CreateFunctionWithParam = AZStd::function< Instance< Type >(AssetData *, const AZStd::any *param)>
 
using DeleteFunction = AZStd::function< void(Type *)>
 

Public Attributes

CreateFunction m_createFunction = nullptr
 
CreateFunctionWithParam m_createFunctionWithParam = nullptr
 
DeleteFunction m_deleteFunction = [](Type* t) { delete t; }
 [Optional] The function to use when deleting an instance.
 

Detailed Description

template<typename Type>
struct AZ::Data::InstanceHandler< Type >

Provides create and delete functions for a specific InstanceData type, for use by InstanceDatabase

Member Typedef Documentation

◆ CreateFunction

template<typename Type >
using AZ::Data::InstanceHandler< Type >::CreateFunction = AZStd::function<Instance<Type>(AssetData*)>

Creation takes an asset as input and produces a new instance as output. Ownership must be returned to the caller. Use this method to perform both allocation and initialization using the provided asset. The returned instance is assumed to be valid and usable by the client.

Usage Examples:

  • The user may choose to allocate from a local pool or cache.
  • The concrete instance type may have a non-standard initialization path.
  • The user may wish to encode global context into the functor (an RHI device, for example).

PERFORMANCE NOTE: Creation is currently done under a lock. Initialization should be quick.

◆ DeleteFunction

template<typename Type >
using AZ::Data::InstanceHandler< Type >::DeleteFunction = AZStd::function<void(Type*)>

Deletion takes an asset as input and transfers ownership to the method.

Member Data Documentation

◆ m_createFunction

template<typename Type >
CreateFunction AZ::Data::InstanceHandler< Type >::m_createFunction = nullptr

A function to use when creating an instance. The system will assert if both @m_createFunction and @m_createFunctionWithParam creation functions are invalid.

◆ m_createFunctionWithParam

template<typename Type >
CreateFunctionWithParam AZ::Data::InstanceHandler< Type >::m_createFunctionWithParam = nullptr

A function with an additional custom param to use when creating an instance. The system will assert if both @m_createFunction and @m_createFunctionWithParam creation functions are invalid.


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