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::BehaviorContext Class Reference

#include <BehaviorContext.h>

Inherits AZ::ReflectContext.

Classes

struct  ClassBuilder
 
struct  EBusBuilder
 Internal structure to maintain EBus information while describing it. More...
 
struct  GlobalMethodBuilder
 
struct  GlobalPropertyBuilder
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (BehaviorContext, SystemAllocator)
 
 AZ_TYPE_INFO_WITH_NAME_DECL (BehaviorContext)
 
 AZ_RTTI_NO_TYPE_INFO_DECL ()
 
bool IsTypeReflected (AZ::Uuid typeId) const override
 
 ~BehaviorContext ()
 
template<class Function >
GlobalMethodBuilder Method (const char *name, Function f, BehaviorValues *defaultValues=nullptr, const char *dbgDesc=nullptr)
 
template<class Function >
GlobalMethodBuilder Method (const char *name, Function f, const char *deprecatedName, BehaviorValues *defaultValues=nullptr, const char *dbgDesc=nullptr)
 <
 
template<class Function >
GlobalMethodBuilder Method (const char *name, Function f, const BehaviorParameterOverridesArray< Function > &args, const char *dbgDesc=nullptr)
 <
 
template<class Function >
GlobalMethodBuilder Method (const char *name, Function f, const char *deprecatedName, const BehaviorParameterOverridesArray< Function > &args, const char *dbgDesc=nullptr)
 
template<class Getter , class Setter >
GlobalPropertyBuilder Property (const char *name, Getter getter, Setter setter)
 
template<auto Value>
BehaviorContextEnum (const char *name)
 All enums are treated as the enum type.
 
template<auto Value, typename T = decltype(Value)>
GlobalPropertyBuilder EnumProperty (const char *name)
 
template<class Getter >
BehaviorContextConstant (const char *name, Getter getter)
 
template<class Getter >
GlobalPropertyBuilder ConstantProperty (const char *name, Getter getter)
 
template<class T >
ClassBuilder< T > Class (const char *name=nullptr)
 
template<class T >
EBusBuilder< T > EBus (const char *name, const char *deprecatedName=nullptr, const char *toolTip=nullptr)
 
template<class Value >
BehaviorDefaultValuePtr MakeDefaultValue (Value &&defaultValue)
 
template<class... Values>
BehaviorValuesMakeDefaultValues (Values &&... values)
 
const BehaviorMethodFindMethodByReflectedName (AZStd::string_view reflectedName) const
 
const BehaviorPropertyFindPropertyByReflectedName (AZStd::string_view reflectedName) const
 
const BehaviorMethodFindGetterByReflectedName (AZStd::string_view reflectedName) const
 
const BehaviorMethodFindSetterByReflectedName (AZStd::string_view reflectedName) const
 
const BehaviorClassFindClassByReflectedName (AZStd::string_view reflectedName) const
 
const BehaviorClassFindClassByTypeId (const AZ::TypeId &typeId) const
 
const BehaviorEBusFindEBusByReflectedName (AZStd::string_view reflectedName) const
 
template<class T >
auto Class (const char *name) -> ClassBuilder< T >
 
template<class T >
auto EBus (const char *name, const char *deprecatedName, const char *toolTip) -> EBusBuilder< T >
 
- Public Member Functions inherited from AZ::ReflectContext
 AZ_TYPE_INFO_WITH_NAME_DECL (ReflectContext)
 
 AZ_RTTI_NO_TYPE_INFO_DECL ()
 
void EnableRemoveReflection ()
 
void DisableRemoveReflection ()
 
bool IsRemovingReflection () const
 
bool IsOnDemandTypeReflected (AZ::Uuid typeId)
 Check if an OnDemandReflection type's typeid is already reflected.
 
virtual bool IsTypeReflected (AZ::Uuid) const
 
void ExecuteQueuedOnDemandReflections ()
 Execute all queued OnDemandReflection calls.
 

Static Public Member Functions

static AZ::Uuid GetVoidTypeId ()
 
static const AZStd::pair< AZ::Uuid, AZStd::string > & GetVoidTypeNamePair ()
 
static bool IsVoidType (const AZ::Uuid &uuid)
 

Public Attributes

AZStd::unordered_map< AZStd::string, BehaviorMethod * > m_methods
 
AZStd::unordered_map< AZStd::string, BehaviorProperty * > m_properties
 
AZStd::unordered_map< AZStd::string, BehaviorClass * > m_classes
 
AZStd::unordered_map< AZ::Uuid, BehaviorClass * > m_typeToClassMap
 
AZStd::unordered_map< AZStd::string, BehaviorEBus * > m_ebuses
 
AZStd::unordered_set< ExplicitOverloadInfom_explicitOverloads
 
AZStd::unordered_map< const BehaviorMethod *, AZStd::pair< const BehaviorMethod *, const BehaviorClass * > > m_checksByOperations
 

Additional Inherited Members

- Protected Attributes inherited from AZ::ReflectContext
bool m_isRemoveReflection
 True if all calls in the context should be considered to remove not to add reflection.
 
AZStd::unordered_map< AZ::Uuid, AZStd::weak_ptr< Internal::ReflectionFunctionRef > > m_onDemandReflection
 Store the on demand reflect functions so we can avoid double-reflecting something.
 
AZStd::vector< AZStd::pair< AZ::Uuid, StaticReflectionFunctionPtr > > m_toProcessOnDemandReflection
 OnDemandReflection functions that need to be called.
 
AZStd::deque< AZ::Uuidm_currentlyProcessingTypeIds
 The type ids of the currently reflecting type. Used to prevent circular references. Is a set to prevent recursive circular references.
 
friend OnDemandReflectionOwner
 

Detailed Description

BehaviorContext is used to reflect classes, methods and EBuses for runtime interaction. A typical consumer of this context and different scripting systems (i.e. Lua, Visual Script, etc.). Even though (as designed) there are overlaps between some context they have very different purpose and set of rules. For example SerializeContext, doesn't reflect any methods, it just reflects data fields that will be stored for initial object setup, it handles version conversion and so thing, this related to storing the object to a persistent storage. Behavior context, doesn't need to deal with versions as no data is stored, just methods for manipulating the object state.

Constructor & Destructor Documentation

◆ ~BehaviorContext()

AZ::BehaviorContext::~BehaviorContext ( )
Deprecated:
Use "Method(const char*, Function, const BehaviorParameterOverridesArray<Function>&, const char*)" instead This method does not support passing in argument names and tooltips nor does it support overriding specific parameter Behavior traits

Member Function Documentation

◆ IsTypeReflected()

bool AZ::BehaviorContext::IsTypeReflected ( AZ::Uuid  typeId) const
overridevirtual

Reimplemented from AZ::ReflectContext.

◆ MakeDefaultValue()

template<class Value >
BehaviorDefaultValuePtr AZ::BehaviorContext::MakeDefaultValue ( Value &&  defaultValue)

Create a default value to be stored with the parameter metadata. Default value are stored by value in a temp storage, so currently there is limit the BehaviorArgument temp storage, we can easily change that if it became a problem.

◆ MakeDefaultValues()

template<class... Values>
BehaviorValues * AZ::BehaviorContext::MakeDefaultValues ( Values &&...  values)

Create a container of default values to be used with methods. Default values are stored by value in a temp storage, so currently there is limit the BehaviorArgument temp storage, we can easily change that if it became a problem.

◆ Method() [1/3]

template<class Function >
BehaviorContext::GlobalMethodBuilder AZ::BehaviorContext::Method ( const char *  name,
Function  f,
BehaviorValues defaultValues = nullptr,
const char *  dbgDesc = nullptr 
)
Deprecated:
Use "Method(const char*, Function, const char*, const BehaviorParameterOverridesArray<Function>&, const char*)" instead This method does not support passing in argument names and tooltips nor does it support overriding specific parameter Behavior traits

◆ Method() [2/3]

template<class Function >
BehaviorContext::GlobalMethodBuilder AZ::BehaviorContext::Method ( const char *  name,
Function  f,
const BehaviorParameterOverridesArray< Function > &  args,
const char *  dbgDesc = nullptr 
)

<

Deprecated:
Use "Method(const char*, Function, const BehaviorParameterOverridesArray<Function>&, const char*)" instead

◆ Method() [3/3]

template<class Function >
BehaviorContext::GlobalMethodBuilder AZ::BehaviorContext::Method ( const char *  name,
Function  f,
const char *  deprecatedName,
BehaviorValues defaultValues = nullptr,
const char *  dbgDesc = nullptr 
)

<

Deprecated:
Use "Method(const char*, Function, const char*, const BehaviorParameterOverridesArray<Function>&, const char*)" instead

Member Data Documentation

◆ m_methods

AZStd::unordered_map<AZStd::string, BehaviorMethod*> AZ::BehaviorContext::m_methods

Prefer to access BehaviorContext methods, properties, classes and EBuses through the Find* functions instead of direct member access


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