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::BehaviorInterfaceProxy< T > Class Template Reference

#include <BehaviorInterfaceProxy.h>

Classes

struct  MethodWrapper
 

Public Member Functions

 AZ_CLASS_ALLOCATOR (BehaviorInterfaceProxy, AZ::SystemAllocator)
 
 AZ_RTTI (BehaviorInterfaceProxy< T >, "{E7CC8D27-4499-454E-A7DF-3F72FBECD30D}")
 
 BehaviorInterfaceProxy (AZStd::shared_ptr< T > sharedInstance)
 Stores the instance which will use the provided shared_ptr deleter when the reference count hits zero.
 
 BehaviorInterfaceProxy (T *rawIntance)
 Stores the instance which will perform a no-op deleter when the reference count hits zero.
 
bool IsValid () const
 Returns if the m_instance shared pointer is non-nullptr.
 

Static Protected Member Functions

static T * GetInstance ()
 Internal access for use in the derived GetProxy function.
 

Protected Attributes

AZStd::shared_ptr< T > m_instance
 

Detailed Description

template<typename T>
class AZ::BehaviorInterfaceProxy< T >

Utility class for reflecting an AZ::Interface through the BehaviorContext

Example:

class MyInterface { public: AZ_RTTI(MyInterface, "{BADDF000D-CDCD-CDCD-CDCD-BAAAADF0000D}"); virtual ~MyInterface() = default;

virtual AZStd::string Foo() = 0; virtual void Bar(float x, float y) = 0; };

class MySystemProxy : public BehaviorInterfaceProxy<MyInterface> { public: AZ_RTTI(MySystemProxy, "{CDCDCDCD-BAAD-BADD-F00D-CDCDCDCDCDCD}", BehaviorInterfaceProxy<MyInterface>); AZ_BEHAVIOR_INTERFACE(MySystemProxy, MyInterface); };

void Reflect(AZ::ReflectContext* context) { if (AZ::BehaviorContext* behaviorContext = azrtti_cast<AZ::BehaviorContext*>(context)) { behaviorContext->ConstantProperty("g_MySystem", MySystemProxy::GetProxy) ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "MyModule");

behaviorContext->Class<MySystemProxy>("MySystemInterface") ->Attribute(AZ::Script::Attributes::Scope, AZ::Script::Attributes::ScopeFlags::Common) ->Attribute(AZ::Script::Attributes::Module, "MyModule")

->Method("Foo", MySystemProxy::WrapMethod<&MyInterface::Foo>()) ->Method("Bar", MySystemProxy::WrapMethod<&MyInterface::Bar>()); } }


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