Open 3D Engine AzFramework 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::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature > Class Template Reference

#include <DocumentSchema.h>

Inherits AZ::DocumentPropertyEditor::AttributeDefinition< AZStd::function< CallbackSignature > >.

Classes

struct  Traits
 
struct  Traits< Result(Args...)>
 
struct  Traits< void(Args...)>
 

Public Types

using ErrorType = AZStd::fixed_string< 128 >
 
using FunctionType = AZStd::function< CallbackSignature >
 
using CallbackTraits = Traits< CallbackSignature >
 
using MessageCallbackType = AZStd::function< CallbackSignature >
 

Public Member Functions

constexpr CallbackAttributeDefinition (AZStd::string_view name)
 
template<typename... Args>
CallbackTraits::ResultType InvokeOnDomValue (const AZ::Dom::Value &value, Args... args) const
 
template<typename... Args>
CallbackTraits::ResultType InvokeOnDomNode (const AZ::Dom::Value &value, Args... args) const
 
bool MatchMessage (const AdapterMessage &message, Dom::Value &result, const MessageCallbackType &callback) const
 
AZStd::shared_ptr< AZ::Attribute > DomValueToLegacyAttribute (const AZ::Dom::Value &value, bool) const override
 
AZ::Dom::Value LegacyAttributeToDomValue (void *instance, AZ::Attribute *attribute) const override
 
- Public Member Functions inherited from AZ::DocumentPropertyEditor::AttributeDefinition< AZStd::function< CallbackSignature > >
constexpr AttributeDefinition (AZStd::string_view name)
 
Name GetName () const override
 Retrieves the name of this attribute, as used as a key in the DOM.
 
virtual Dom::Value ValueToDom (const AZStd::function< CallbackSignature > &attribute) const
 Converts a value of this attribute's type to a DOM value.
 
virtual AZStd::optional< AZStd::function< CallbackSignature > > DomToValue (const Dom::Value &value) const
 Converts a DOM value to an instance of AttributeType.
 
AZStd::optional< AZStd::function< CallbackSignature > > ExtractFromDomNode (const Dom::Value &node) const
 Extracts this value from a given Node, if this attribute is set there.
 
AZ::TypeId GetTypeId () const override
 Gets this attribute's type ID.
 
AZStd::shared_ptr< AZ::Attribute > DomValueToLegacyAttribute (const AZ::Dom::Value &value, bool fallback) const override
 
AZ::Dom::Value LegacyAttributeToDomValue (void *instance, AZ::Attribute *attribute) const override
 
virtual Name GetName () const =0
 Retrieves the name of this attribute, as used as a key in the DOM.
 
virtual AZ::TypeId GetTypeId () const =0
 Gets this attribute's type ID.
 
virtual AZStd::shared_ptr< AZ::Attribute > DomValueToLegacyAttribute (const AZ::Dom::Value &value, bool fallback=true) const =0
 
virtual AZ::Dom::Value LegacyAttributeToDomValue (void *instance, AZ::Attribute *attribute) const =0
 

Additional Inherited Members

- Protected Attributes inherited from AZ::DocumentPropertyEditor::AttributeDefinition< AZStd::function< CallbackSignature > >
AZStd::fixed_string< 128 > m_name
 

Detailed Description

template<typename CallbackSignature>
class AZ::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature >

Defines a callback applicable to a Node. Callbacks are stored as attributes and accept an AZStd::function<CallbackSignature> stored as an opaque value. Callbacks can be validated and invokved from DOM values using InvokeOnDomValue and InvokeOnDomNode.

Member Function Documentation

◆ DomValueToLegacyAttribute()

template<typename CallbackSignature >
AZStd::shared_ptr< AZ::Attribute > AZ::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature >::DomValueToLegacyAttribute ( const AZ::Dom::Value &  value,
bool  fallback 
) const
inlineoverridevirtual

Converts this attribute to an AZ::Attribute usable by the ReflectedPropertyEditor

Parameters
fallbackif false, the Attribute type must match AZ::Dom::Value; if true, it will attempt a fallback on failure

Implements AZ::DocumentPropertyEditor::AttributeDefinitionInterface.

◆ InvokeOnDomNode()

template<typename CallbackSignature >
template<typename... Args>
CallbackTraits::ResultType AZ::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature >::InvokeOnDomNode ( const AZ::Dom::Value &  value,
Args...  args 
) const
inline

Attemps to read this attribute from the specified DOM value, which must be a Node. Invokes the method with the specified args if this attribute is specified, otherwise returns an error message.

◆ InvokeOnDomValue()

template<typename CallbackSignature >
template<typename... Args>
CallbackTraits::ResultType AZ::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature >::InvokeOnDomValue ( const AZ::Dom::Value &  value,
Args...  args 
) const
inline

Attempts to call a function with this attribute's callback signature stored in a DOM value as an opaque type. Invokes the method with the specified args if our callback signature is found in the value, otherwise returns an error message.

◆ LegacyAttributeToDomValue()

template<typename CallbackSignature >
AZ::Dom::Value AZ::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature >::LegacyAttributeToDomValue ( void *  instance,
AZ::Attribute *  attribute 
) const
inlineoverridevirtual

Converts this attribute from an AZ::Attribute to a Dom::Value usable in the DocumentPropertyEditor.

Parameters
fallbackif false, a Read<AttributeType> failure will return a null Value; if true, it will attempt a fallback on failure

Implements AZ::DocumentPropertyEditor::AttributeDefinitionInterface.

◆ MatchMessage()

template<typename CallbackSignature >
bool AZ::DocumentPropertyEditor::CallbackAttributeDefinition< CallbackSignature >::MatchMessage ( const AdapterMessage message,
Dom::Value &  result,
const MessageCallbackType &  callback 
) const
inline

Checks if a given AdapterMessage matches this attribute and invokes a provided callback if so. Returns true if the callback was invoked.


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