Menu
Lumberyard
C++ API Reference (Version 1.10)

AZ::BehaviorContext::ClassReflection< C > Struct Template Reference

This structure is built up while you call ClassReflection functions to reflect a class's information to the behavior context. More...

Inherits AZ::Internal::GenericAttributes< ClassReflection< C > >.

Public Member Functions

ClassReflectionAllocator (BehaviorClass::AllocateType allocate, BehaviorClass::DeallocateType deallocate)
 Sets a custom memory allocator and deallocator for a class. More...
 
template<class... Params>
ClassReflectionConstructor ()
 Attaches additional constructor signatures to a class. More...
 
template<class WrappedType >
ClassReflectionWrapping (BehaviorClassUnwrapperFunction unwrapper, void *userData)
 Use to indicate that a class is a wrapper of another class. More...
 
template<class WrappedType , class MemberFunction >
ClassReflectionWrappingMember (MemberFunction memberFunction)
 Provides a function to unwrap a class. More...
 
ClassReflectionUserData (void *userData)
 Attaches additional data to a class. More...
 
template<class Function >
ClassReflectionMethod (const char *name, Function method, BehaviorValues *defaultValues=nullptr, const char *dbgDesc=nullptr)
 Reflects a class method to the behavior context. More...
 
template<class Function , class = AZStd::enable_if_t<AZStd::function_traits<Function>::num_args != 0>>
ClassReflectionMethod (const char *name, Function method, AZStd::array< AZStd::string, AZStd::function_traits< Function >::num_args > argNames, BehaviorValues *defaultValues=nullptr, const char *dbgDesc=nullptr)
 Reflects a class method with arguments to the behavior context. More...
 
template<class Getter , class Setter >
ClassReflectionProperty (const char *name, Getter getter, Setter setter)
 Reflects class member properties to the behavior context. More...
 
template<int Value>
ClassReflectionEnum (const char *name)
 Reflects class member enum types to the behavior context. More...
 
template<class Getter >
ClassReflectionConstant (const char *name, Getter getter)
 Reflects a class member constant to the behavior context. More...
 
ClassReflectionRequestBus (const char *busName)
 Describes the EBus request buses that this class uses. More...
 
ClassReflectionNotificationBus (const char *busName)
 Describes the EBus notification buses that this class uses. More...
 

Public Attributes

BehaviorClassm_class
 A pointer to all the information that describes a reflected class. More...
 

Detailed Description

template<class C>
struct AZ::BehaviorContext::ClassReflection< C >

This structure is built up while you call ClassReflection functions to reflect a class's information to the behavior context.

The end result of this reflection is a BehaviorClass instance that is stored in the behavior context.

You call the functions in a builder pattern. To add attributes to the entire class or to individual class members, immediately follow a function call with ->Attribute("attributeName", attributeValue);.

The following example shows how to add attributes.

behaviorContext->Class<MyClass>()
->Attribute("attributeName", attributeValue); // Class attribute.
->Property("memberData", &MyClass::GetData(), &MyClass::SetData)
->Attribute("attributeName", attributeValue); // Class member attribute.

Member Function Documentation

◆ Allocator()

template<class C >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Allocator ( BehaviorClass::AllocateType  allocate,
BehaviorClass::DeallocateType  deallocate 
)

Sets a custom memory allocator and deallocator for a class.

This is only for very specific cases where you want to override AZ_CLASS_ALLOCATOR or you are using third-party classes. Otherwise, you should use AZ_CLASS_ALLOCATOR to control which allocator the class uses.

Parameters
allocateAn allocator function.
deallocateA deallocator function.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Constant()

template<class C >
template<class Getter >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Constant ( const char *  name,
Getter  getter 
)

Reflects a class member constant to the behavior context.

You must use a getter function to pass in the constant. If you don't have a getter function, you can use the BehaviorConstant() helper macro.

You can attach one or more attributes to the constant by following Constant() with Attribute() in a builder pattern as shown in the following example.

behaviorContext->Class<MyClass>()
->Constant("memberConst", BehaviorConstant(constValue))
->Attribute("attributeName", attributeValue);

To reflect global constants, use BehaviorContext::Constant().

Parameters
nameThe name of the constant.
getterA method that gets the value of the constant. You can use the BehaviorConstant() helper macro to convert a value to a function to use for this parameter.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Constructor()

template<class C >
template<class... Params>
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Constructor ( )

Attaches additional constructor signatures to a class.

You can have any number of these. You must pass all constructor arguments as template arguments.

You can attach one or more attributes to the constructor by following Constructor() with Attribute() in a builder pattern as shown in the following example.

behaviorContext->Class<MyClass>()
->Constructor<ParamType1, ParamType2>()
->Attribute("attributeName", attributeValue);
Template Parameters
ParamsThe constructor's argument types.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Enum()

template<class C >
template<int Value>
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Enum ( const char *  name)

Reflects class member enum types to the behavior context.

All enums are treated as int.

You can attach one or more attributes to the enum by following Enum() with Attribute() in a builder pattern as shown in the following example.

behaviorContext->Class<MyClass>()
->Enum<MyClass::ENUM_VALUE>("ENUM_VALUE")
->Attribute("attributeName", attributeValue);

To reflect global enums, use BehaviorContext::Enum().

Parameters
nameThe name of the enum.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Method() [1/2]

template<class C >
template<class Function >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Method ( const char *  name,
Function  method,
BehaviorValues *  defaultValues = nullptr,
const char *  dbgDesc = nullptr 
)

Reflects a class method to the behavior context.

Each method must have a name unique to the class.

You can attach one or more attributes to the method by following Method() with Attribute() in a builder pattern as shown in the following example.

behaviorContext->Class<MyClass>()
->Method("MemberMethod",&Method, nullptr, "Debug description.")
->Attribute("attributeName", attributeValue);

To reflect global methods, use BehaviorContext::Method().

Parameters
nameThe name of the method.
methodA reference to the method.
defaultValues(Optional) Default values, which help you call the reflected method with fewer arguments. Default values are used right to left.
dbgDesc(Optional) A description that is used for debugging.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Method() [2/2]

template<class C >
template<class Function , class = AZStd::enable_if_t<AZStd::function_traits<Function>::num_args != 0>>
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Method ( const char *  name,
Function  method,
AZStd::array< AZStd::string, AZStd::function_traits< Function >::num_args >  argNames,
BehaviorValues *  defaultValues = nullptr,
const char *  dbgDesc = nullptr 
)

Reflects a class method with arguments to the behavior context.

Each method must have a name unique to the class.

You can attach one or more attributes to the method by following Method() with Attribute() in a builder pattern as shown in the following example.

behaviorContext->Class<MyClass>()
->Method("MemberMethod",&Method, {"MyArg1","MyArg2"}, nullptr, "Debug description.")
->Attribute("attributeName", attributeValue);

To reflect global methods, use BehaviorContext::Method().

Parameters
nameThe name of the method.
methodA reference to the method.
argNamesAn array of argument names for the method.
defaultValues(Optional) Default values, which help you call the reflected method with fewer arguments. Default values are used right to left.
dbgDesc(Optional) A description that is used for debugging.
Returns
The this pointer so that you can keep using the builder pattern.

◆ NotificationBus()

template<class C >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::NotificationBus ( const char *  busName)

Describes the EBus notification buses that this class uses.

This information is used by tools and gives developers information about which notification buses this class interacts with. You don't need to reflect all notification buses that your class uses, just the ones related to class behavior.

Parameters
busNameThe name of the notification bus.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Property()

template<class C >
template<class Getter , class Setter >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Property ( const char *  name,
Getter  getter,
Setter  setter 
)

Reflects class member properties to the behavior context.

A property is data that is represented by a getter and setter function. If you don't have a getter or setter function, you can use the BehaviorValueGetter() and BehaviorValueSetter() helper macros.

You can attach one or more attributes to a property by following Property() with Attribute() in a builder pattern as shown in the following example.

behaviorContext->Class<MyClass>()
->Property("memberData", &MyClass::GetData(), &MyClass::SetData)
->Attribute("attributeName", attributeValue);

For more examples, see the detailed description of BehaviorContext. To reflect global properties, use BehaviorContext::Property().

Parameters
nameA name for the property.
getter(Optional) A method that gets the value of the property. If you pass null for this parameter, the property is write only. (This is rare.)
setter(Optional) A function that sets the property. If you pass null for this parameter, the property is read only.
Returns
The this pointer so that you can keep using the builder pattern.

◆ RequestBus()

template<class C >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::RequestBus ( const char *  busName)

Describes the EBus request buses that this class uses.

This information is used by tools and gives developers information about which request buses this class interacts with. You don't need to reflect all request buses that your class uses, just the ones related to class behavior.

Parameters
busNameThe name of the request bus.
Returns
The this pointer so that you can keep using the builder pattern.

◆ UserData()

template<class C >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::UserData ( void *  userData)

Attaches additional data to a class.

Parameters
userDataA pointer to additional data.
Returns
The this pointer so that you can keep using the builder pattern.

◆ Wrapping()

template<class C >
template<class WrappedType >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::Wrapping ( BehaviorClassUnwrapperFunction  unwrapper,
void *  userData 
)

Use to indicate that a class is a wrapper of another class.

You can use this when your class is a wrapper, such as a smart pointer.

Template Parameters
WrappedTypeThe type that is wrapped.
Parameters
unwrapperA reference to a function to unwrap the class.
userDataA pointer to additional data for the wrapper.
Returns
The this pointer so that you can keep using the builder pattern.

◆ WrappingMember()

template<class C >
template<class WrappedType , class MemberFunction >
ClassReflection* AZ::BehaviorContext::ClassReflection< C >::WrappingMember ( MemberFunction  memberFunction)

Provides a function to unwrap a class.

Uses an underlying class.

Template Parameters
WrappedTypeThe type that is wrapped.
MemberFunctionThe function type that unwraps the class.
Parameters
memberFunctionA reference to a function to unwrap the class.
Returns
The this pointer so that you can keep using the builder pattern.

Member Data Documentation

◆ m_class

template<class C >
BehaviorClass* AZ::BehaviorContext::ClassReflection< C >::m_class

A pointer to all the information that describes a reflected class.


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