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::EditContext::ClassBuilder Class Reference

#include <EditContext.h>

Public Member Functions

ClassBuilderoperator-> ()
 
ClassBuilderClassElement (Crc32 elementIdCrc, const char *description)
 
ClassBuilderEndGroup ()
 
template<class T >
ClassBuilderGroupElementToggle (const char *description, bool(T::*memberVariable))
 
ClassBuilderUIElement (const char *uiId, const char *description)
 
ClassBuilderUIElement (Crc32 uiIdCrc, const char *description)
 
ClassBuilderUIElement (Crc32 uiIdCrc, const char *name, const char *description)
 
template<class T >
ClassBuilderDataElement (const char *uiId, T memberVariable, const char *name, const char *description)
 
template<class T >
ClassBuilderDataElement (Crc32 uiIdCrc, T memberVariable, const char *name, const char *description)
 
template<class T >
ClassBuilderDataElement (Crc32 uiIdCrc, T memberVariable, const char *name, const char *description, const char *deprecatedName)
 
template<class T >
ClassBuilderDataElement (const char *uiId, T memberVariable)
 
template<class T >
ClassBuilderDataElement (Crc32 uiIdCrc, T memberVariable)
 
template<class T >
ClassBuilderAttribute (const char *id, T value)
 
template<class T >
ClassBuilderAttribute (Crc32 idCrc, T value)
 
template<class T >
ClassBuilderEnumAttribute (T value, const char *descriptor)
 
template<class T >
ClassBuilderElementAttribute (const char *id, T value)
 
template<class T >
ClassBuilderElementAttribute (Crc32 idCrc, T value)
 
ClassBuilderSetDynamicEditDataProvider (Edit::DynamicEditDataProvider *pHandler)
 
template<class T >
EditContext::ClassBuilderGroupElementToggle (const char *name, bool(T::*memberVariable))
 
template<class T >
EditContext::ClassBuilderDataElement (const char *uiId, T memberVariable, const char *name, const char *description)
 
template<class T >
EditContext::ClassBuilderDataElement (Crc32 uiIdCrc, T memberVariable, const char *name, const char *description)
 
template<class T >
EditContext::ClassBuilderDataElement (Crc32 uiIdCrc, T memberVariable, const char *name, const char *description, const char *deprecatedName)
 
template<class T >
EditContext::ClassBuilderDataElement (const char *uiId, T memberVariable)
 
template<class T >
EditContext::ClassBuilderDataElement (Crc32 uiIdCrc, T memberVariable)
 
template<class T >
EditContext::ClassBuilderAttribute (const char *id, T value)
 
template<class T >
EditContext::ClassBuilderAttribute (Crc32 idCrc, T value)
 
template<class T >
EditContext::ClassBuilderEnumAttribute (T value, const char *description)
 
template<class T >
EditContext::ClassBuilderElementAttribute (const char *id, T value)
 
template<class T >
EditContext::ClassBuilderElementAttribute (Crc32 idCrc, T value)
 

Detailed Description

Internal structure to maintain class information while we are describing a class. User should call variety of functions to describe class features and data. example: struct MyStruct { int m_data };

expose for edit editContext->Class<MyStruct>("My structure","This structure was made to apply structure action!")-> ClassElement(AZ::Edit::ClassElements::Group,"MyGroup")-> Attribute("Callback",&MyStruct::IsMyGroup)-> DataElement(AZ::Edit::UIHandlers::Slider,&MyStruct::m_data,"Structure data","My structure data")-> Attribute(AZ::Edit::Attributes::Min,0)-> Attribute(AZ::Edit::Attributes::Max,100)-> Attribute(AZ::Edit::Attributes::Step,5);

or if you have some structure to group information or offer default values, etc. (that you know if the code and it's safe to include) you can do something like:

serializeContext->Class<MyStruct>("My structure","This structure was made to apply structure action!")-> ClassElement(AZ::Edit::ClassElements::Group,"MyGroup")-> Attribute("Callback",&MyStruct::IsMyGroup)-> DataElement(AZ::Edit::UIHandlers::Slider,&MyStruct::m_data,"Structure data","My structure data")-> Attribute("Params",SliderParams(0,100,5));

Attributes can be any value (must be copy constructed) or a function type. We do supported member functions and member data. look at the unit tests and example to see use cases.

Member Function Documentation

◆ Attribute() [1/2]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::Attribute ( const char *  id,
value 
)

All T (attribute value) MUST be copy constructible as they are stored in internal AttributeContainer<T>, which can be accessed by azrtti and AttributeData. Attributes can be assigned to either classes or DataElements.

◆ Attribute() [2/2]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::Attribute ( Crc32  idCrc,
value 
)

All T (attribute value) MUST be copy constructible as they are stored in internal AttributeContainer<T>, which can be accessed by azrtti and AttributeData. Attributes can be assigned to either classes or DataElements.

◆ ClassElement()

EditContext::ClassBuilder * AZ::EditContext::ClassBuilder::ClassElement ( Crc32  elementIdCrc,
const char *  description 
)
inline

Declare element with attributes that belong to the class SerializeContext::Class, this is a logical structure, you can have one or more ClassElements. \uiId is the logical element ID (for instance "Group" when you want to group certain elements in this class. then in each DataElement you can attach the appropriate group attribute.

◆ DataElement() [1/5]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::DataElement ( const char *  uiId,
memberVariable 
)

Same as above, except we will get the name and description from the edit context of the 'T' type. If 'T' doesn't have edit context both name and the description will be set AzTypeInfo<T>::Name().

Note
this function will search the context for 'T' type, it must be registered at the time of reflection, otherwise it will use the fallback (AzTypeInfo<T>::Name()).

◆ DataElement() [2/5]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::DataElement ( const char *  uiId,
memberVariable,
const char *  name,
const char *  description 
)

Declare element that will handle a specific class member variable (SerializeContext::ClassBuilder::Field).

Parameters
uiId- us element ID ("Int" or "Real", etc. how to edit the memberVariable)
memberVariable- reference to the member variable to we can bind to serializations data.
name- descriptive name of the field. Use this when using types in context. For example T is 'int' and name describes what it does. Sometime 'T' will have edit context with enough information for name and description. In such cases use the DataElement function below.
description- detailed description that will usually appear in a tool tip.

◆ DataElement() [3/5]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::DataElement ( Crc32  uiIdCrc,
memberVariable 
)

Same as above, except we will get the name and description from the edit context of the 'T' type. If 'T' doesn't have edit context both name and the description will be set AzTypeInfo<T>::Name().

Note
this function will search the context for 'T' type, it must be registered at the time of reflection, otherwise it will use the fallback (AzTypeInfo<T>::Name()).

◆ DataElement() [4/5]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::DataElement ( Crc32  uiIdCrc,
memberVariable,
const char *  name,
const char *  description 
)

Declare element that will handle a specific class member variable (SerializeContext::ClassBuilder::Field).

Parameters
uiId- Crc32 of us element ID ("Int" or "Real", etc. how to edit the memberVariable)
memberVariable- reference to the member variable to we can bind to serializations data.
name- descriptive name of the field. Use this when using types in context. For example T is 'int' and name describes what it does. Sometime 'T' will have edit context with enough information for name and description. In such cases use the DataElement function below.
description- detailed description that will usually appear in a tool tip.

◆ DataElement() [5/5]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::DataElement ( Crc32  uiIdCrc,
memberVariable,
const char *  name,
const char *  description,
const char *  deprecatedName 
)

Declare element that will handle a specific class member variable (SerializeContext::ClassBuilder::Field).

Parameters
uiId- Crc32 of us element ID ("Int" or "Real", etc. how to edit the memberVariable)
memberVariable- reference to the member variable to we can bind to serializations data.
name- descriptive name of the field. Use this when using types in context. For example T is 'int' and name describes what it does.
deprecatedName- supports name deprecation when an element name needs to be changed. Sometime 'T' will have edit context with enough information for name and description. In such cases use the DataElement function below.
description- detailed description that will usually appear in a tool tip.

◆ ElementAttribute() [1/2]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::ElementAttribute ( const char *  id,
value 
)

Specialized attribute for setting properties on elements inside a container. This could be used to specify a spinbox handler for all elements inside a container while only having to specify it once (on the parent container).

◆ ElementAttribute() [2/2]

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::ElementAttribute ( Crc32  idCrc,
value 
)

Specialized attribute for setting properties on elements inside a container. This could be used to specify a spinbox handler for all elements inside a container while only having to specify it once (on the parent container).

◆ EndGroup()

EditContext::ClassBuilder * AZ::EditContext::ClassBuilder::EndGroup ( )
inline

Helper method to end the current group (if any). This is shorthand for: ->ClassElement(AZ::Edit::ClassElements::Group, "")

◆ EnumAttribute()

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::EnumAttribute ( value,
const char *  descriptor 
)

Specialized attribute for defining enum values with an associated description. Given the prevalence of the enum case, this prevents users from having to manually create a pair<value, description> for every reflected enum value.

Note
Do not add a bunch of these kinds of specializations. This one is generic enough and common enough that it's warranted for programmer ease.

◆ GroupElementToggle()

template<class T >
ClassBuilder * AZ::EditContext::ClassBuilder::GroupElementToggle ( const char *  description,
boolT::*  memberVariable 
)

Declare element with attributes that belong to the class SerializeContext::Class, this is a logical structure, you can have one or more GroupElementToggles. T must be a boolean variable that will enable and disable each DataElement attached to this structure.

Parameters
description- Descriptive name of the field that will typically appear in a tooltip.
memberVariable- reference to the member variable so we can bind to serialization data.

◆ UIElement() [1/3]

EditContext::ClassBuilder * AZ::EditContext::ClassBuilder::UIElement ( const char *  uiId,
const char *  description 
)
inline

Declare element with an associated UI handler that does not represent a specific class member variable.

Parameters
uiId- name of a UI handler used to display the element
description- description that will appear as the ID's label by default

◆ UIElement() [2/3]

EditContext::ClassBuilder * AZ::EditContext::ClassBuilder::UIElement ( Crc32  uiIdCrc,
const char *  description 
)
inline

Declare element with an associated UI handler that does not represent a specific class member variable.

Parameters
uiId- crc32 of a UI handler used to display the element
description- description that will appear as the ID's label by default

◆ UIElement() [3/3]

EditContext::ClassBuilder * AZ::EditContext::ClassBuilder::UIElement ( Crc32  uiIdCrc,
const char *  name,
const char *  description 
)
inline

Declare element with an associated UI handler that does not represent a specific class member variable.

Parameters
uiId- crc32 of a UI handler used to display the element
name- descriptive name of the field.
description- description that will appear as the ID's label by default

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