Binding objects establish connections between properties, message values or arguments. More...
#include <kanzi/core.ui/binding/binding.hpp>
Public Types | |
enum | Mode { ModeOneWay, ModeTwoWay } |
Binding mode enumeration. More... | |
enum | WriteMode { WriteModeProperty, WriteModeModifier, WriteModeValueSource } |
Write mode, what should the binding do with the result value? More... | |
typedef vector< BindingProcessorSharedPtr > | BindingProcessorVector |
typedef BindingProcessorVector::const_iterator | BindingProcessorIterator |
Public Types inherited from kanzi::PropertyObject | |
typedef intrusive_ptr< AbstractPropertyTypeDescriptor::PropertyStorage > | PropertyStoragePtr |
typedef vector< PropertyStoragePtr > | PropertyStorageContainer |
typedef PropertyStorageContainer::iterator | PropertyStorageIterator |
typedef PropertyStorageContainer::const_iterator | PropertyStorageConstIterator |
typedef PropertyStorageContainer::reverse_iterator | PropertyStorageReverseIterator |
Public Member Functions | |
void | setMode (Mode mode) |
Sets binding mode. More... | |
Mode | getMode () const |
Gets binding mode. More... | |
void | setWriteMode (WriteMode mode) |
Sets binding write mode. More... | |
WriteMode | getWriteMode () const |
Gets binding write mode. More... | |
void | setPrecedence (optional< PropertyValuePrecedence > precedence) |
Sets precedence (for value source write mode). More... | |
optional< PropertyValuePrecedence > | getPrecedence () const |
Gets precedence (for value source write mode). More... | |
void | setSourceValue (const Variant &value) |
Set up source rule to specify a value. More... | |
void | setSourceDynamicObjectProperty (string_view objectPath, AbstractPropertyType propertyType, PropertyField field) |
Set up source rule to specify an object property. More... | |
void | addSourceDynamicObjectProperty (string_view objectPath, AbstractPropertyType propertyType, PropertyField field) |
Adds or a source property as the source rule. More... | |
void | setSourceMessageArgument (AbstractPropertyType argumentType, PropertyField field) |
Set up source rule to specify a message argument. More... | |
void | setSourceResource (ResourceID id) |
Set up source as a resource object. More... | |
void | addDataSourceProperty (string_view objectPath) |
Adds a data source property as the source rule. More... | |
void | setZeroSource () |
Set a zero source binding. More... | |
void | setTargetDynamicObjectProperty (string_view objectPath, AbstractPropertyType propertyType, PropertyField field) |
Set up target rule to specify an object property. More... | |
void | setTargetMessageArgument (AbstractPropertyType argumentType, PropertyField field) |
Set up target rule to specify a message argument. More... | |
bool | read (Node *currentObjectNode, const MessageArguments *sourceMessage) |
Read values from sourceMessage and store them in rule's internal cache. More... | |
bool | write (Node *currentObjectNode, MessageArguments *targetMessage) |
Save the cached value from the rule to targetMessage if it has one cached. More... | |
bool | update (Node *currentObjectNode, const MessageArguments *sourceMessage, MessageArguments *targetMessage) |
Read values from sourceMessage and write them to targetMessage if the binding rule type is a message argument to message argument. More... | |
bool | updateSource (Node *currentObjectNode, MessageArguments *sourceMessage, const MessageArguments *targetMessage) |
Update the source value in binding. More... | |
bool | readTargetValue (Variant *value) |
Read the target value. More... | |
const Variant * | getCachedSourceValue () const |
Returns the source value from rule's internal cache. More... | |
void | addValidator (BindingProcessorSharedPtr processor) |
Add a validator object. More... | |
void | removeValidator (const BindingProcessor &processor) |
Remove a validator object. More... | |
BindingProcessorIterator | beginBindingProcessors () const |
BindingProcessorIterator | endBindingProcessors () const |
size_t | getSourceRegisterCount () const |
Gets the number of source registers in binding rule. More... | |
size_t | getConstantRegisterCount () const |
Gets the number of constant registers in binding rule. More... | |
size_t | getTemporaryRegisterCount () const |
Gets the number of temporary registers in binding rule. More... | |
size_t | getDataSourceRegisterCount () const |
Gets the number of data source registers in binding rule. More... | |
void | attach (Node *objectNode) |
Attach binding. More... | |
void | detach () |
Detach binding. More... | |
Node * | getAttachedNode () const |
Get the object node the rule is attached to, if any. More... | |
void | addConstantRegister (const Variant &constant) |
Add a constant value to the binding. More... | |
void | setConstantRegister (size_t index, const Variant &constant) |
Set constant register at given index. More... | |
void | setTemporaryRegisterCount (size_t count) |
Set the number of temporaries for the binding. More... | |
const Variant * | getSourceRegister (size_t index) const |
Get access to source register. More... | |
const Variant * | getConstantRegister (size_t index) const |
Get access to constant register. More... | |
Variant * | getTemporaryRegister (size_t index) |
Get access to temporary register. More... | |
const Variant * | getDataSourceRegister (size_t index) const |
Get access to data source register. More... | |
bool | getTargetPropertyType (AbstractPropertyType &out_targetPropertyType, PropertyField &out_field) const |
Returns target property type and property field of the binding rule if it is writing to property. More... | |
virtual | ~Binding () |
BindingSharedPtr | copy () const |
Copies a binding object. More... | |
bool | isAttached () const |
Tells if this binding is attached. More... | |
void | addOperation (BindingOperationSharedPtr operation) |
Adds operation to the binding. More... | |
void | setTemplateRoot (NodeSharedPtr templateRoot) |
Sets the template root of this binding. More... | |
NodeSharedPtr | getTemplateRoot () const |
Gets the template root of this binding. More... | |
optional< ResourceID > | getIdIfResourceSource () const |
Gets the Resource ID, if the source is a ResourceSource. More... | |
Public Member Functions inherited from kanzi::Object | |
Object (Domain *domain) | |
virtual | ~Object () |
Domain * | getDomain () const |
Returns the domain the object belongs to. More... | |
KzuTaskScheduler * | getTaskScheduler () const |
Returns the task scheduler of the object. More... | |
KzuMessageDispatcher * | getMessageDispatcher () const |
Returns the message dispatcher of the object. More... | |
ResourceManager * | getResourceManager () const |
Returns the resource manager of the object. More... | |
virtual const Metaclass * | getDynamicMetaclass () const KZ_OVERRIDE |
Returns the metaclass of the dynamic type of the object. More... | |
AppliedStyleEntrySharedPtr | applyObjectStyle (kanzi::StyleSharedPtr style) |
Applies a style to an object. More... | |
void | unapplyObjectStyle (AppliedStyleEntrySharedPtr appliedStyleEntry) |
void | applyObjectStyles () |
Apply all styles for an object node. More... | |
void | unapplyObjectStyles () |
Unapplies and removes all applied styles. More... | |
Public Member Functions inherited from kanzi::MetaObject | |
virtual | ~MetaObject () |
bool | isTypeOf (const Metaclass *objectType) const |
Determines if the type of this object is the given type or derived from it. More... | |
Public Member Functions inherited from kanzi::PropertyObject | |
PropertyObject () | |
virtual | ~PropertyObject () |
template<typename DataType > | |
void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
Sets the local value of a property. More... | |
void | removeKzbProperties () |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getProperty (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property. More... | |
template<typename DataType > | |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalProperty (const PropertyType< DataType > &propertyType) const |
Evaluates the property value in the same way as the overload above but does not default to the value in property metadata if there are no inputs to the property value. More... | |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getPropertyBase (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property disregarding modifiers. More... | |
template<typename DataType > | |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::Traits::ParameterType value) |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
PropertyType< DataType >::Traits::ReturnType | getAbstractPropertyBase (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
optional< typename PropertyType< DataType >::Traits::ReturnType > | getOptionalAbstractProperty (AbstractPropertyType abstractPropertyType) const |
void | setPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
bool | isPropertyFlagSet (AbstractPropertyType propertyType, uint32_t flag) const |
void | clearPropertyFlag (AbstractPropertyType propertyType, uint32_t flag) |
bool | hasValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value. More... | |
bool | hasBaseValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value, disregarding modifiers. More... | |
bool | hasLocalValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a local value set for the property. More... | |
bool | hasNonClassValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a value of any precedence higher than class default value set for the property. More... | |
void | removeLocalValue (AbstractPropertyType propertyType) |
Removes the local value associated with the property. More... | |
void | copyLocalValue (const PropertyObject &other, AbstractPropertyType propertyType) |
Copies local value of single property from another object. More... | |
void | copyLocalValues (const PropertyObject &other) |
Copies all local values from another object. More... | |
virtual void | onPropertyChanged (AbstractPropertyType propertyType, PropertyNotificationReason reason) |
Virtual function to handle property change notifications. More... | |
template<typename DataType > | |
void | addPropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, PropertyValuePrecedence precedence, void *owner) |
template<typename DataType > | |
void | removePropertyValueSource (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::TypedValueSource *valueSource, void *owner) |
template<typename DataType > | |
void | addPropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
template<typename DataType > | |
void | removePropertyModifier (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::ModifierCallback callback, void *owner) |
void | validatePropertyModifiers (AbstractPropertyType propertyType) |
template<typename DataType > | |
void | addPropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
template<typename DataType > | |
void | removePropertyNotificationHandler (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::Descriptor::NotificationCallback callback, void *owner) |
template<typename DataType > | |
size_t | getPropertyNotificationHandlerCount (const PropertyType< DataType > &propertyType) |
Gets number of current notification handlers for given property type. More... | |
Static Public Member Functions | |
static BindingSharedPtr | create (Domain *domain) |
Creates a binding object. More... | |
static BindingSharedPtr | create (Domain *domain, string_view objectPath, AbstractPropertyType sourcePropertyType, PropertyField sourceField, AbstractPropertyType targetPropertyType, PropertyField targetField) |
Helper to create a property-to-property binding rule object. More... | |
static BindingSharedPtr | create (Domain *domain, ResourceID resourceName, AbstractPropertyType propertyType) |
static BindingSharedPtr | createFromDataObjectPath (Domain *domain, string_view objectPath, AbstractPropertyType targetPropertyType, PropertyField targetField) |
Helper to create a data object-to-property binding object. More... | |
Static Public Member Functions inherited from kanzi::Object | |
static const Metaclass * | getStaticMetaclass () |
Returns the metaclass of Object class. More... | |
static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
Default implementation that returns empty editor info. More... | |
Static Public Member Functions inherited from kanzi::MetaObject | |
static const Metaclass * | getStaticMetaclass () |
Returns the metaclass of Object class. More... | |
static PropertyTypeEditorInfoSharedPtr | makeEditorInfo () |
Default implementation that returns empty editor info. More... | |
Friends | |
class | DataContextListener |
Binding objects establish connections between properties, message values or arguments.
When the data in the source connection is modified the binding propagates the value to the target connection. While the data is propagated the binding passes it through the optional chain of processors that can modify the value or reject the update.
typedef vector<BindingProcessorSharedPtr> kanzi::Binding::BindingProcessorVector |
typedef BindingProcessorVector::const_iterator kanzi::Binding::BindingProcessorIterator |
enum kanzi::Binding::Mode |
Binding mode enumeration.
Enumerator | |
---|---|
ModeOneWay |
One way binding. |
ModeTwoWay |
Two way binding. |
|
virtual |
|
static |
Creates a binding object.
|
static |
Helper to create a property-to-property binding rule object.
memoryManager | The memory manager to use for allocations. |
domain | The UI domain. |
sourcePath | An object path pointing to the source object that has the source property. This can be relative to the target property owner. |
sourcePropertyType | ::KzuPropertyType of the source property. |
sourceField | Field of the source property to bind or PropertyFieldWhole for the whole property. |
targetPropertyType | ::KzuPropertyType of the target property. |
targetField | Field of the target property to bind or PropertyFieldWhole for the whole property. |
out_rule | A pointer that is set to point to the new KzuBindingRule. |
|
static |
|
static |
Helper to create a data object-to-property binding object.
The object path specified here is passed to addDataSourceProperty(), and is a relative path from the root data source. If the data object path in studio would be {DataContext.path.to.object}, the string passed here should be "path.to.object".
domain | The UI domain. |
objectPath | A relative path pointing from current data context to the source data object. |
targetPropertyType | Type of the property used as binding target. |
targetField | Field of the target property to bind or PropertyFieldWhole for the whole property. |
void kanzi::Binding::setMode | ( | Mode | mode | ) |
Sets binding mode.
Mode kanzi::Binding::getMode | ( | ) | const |
Gets binding mode.
void kanzi::Binding::setWriteMode | ( | WriteMode | mode | ) |
Sets binding write mode.
|
inline |
Gets binding write mode.
void kanzi::Binding::setPrecedence | ( | optional< PropertyValuePrecedence > | precedence | ) |
Sets precedence (for value source write mode).
|
inline |
Gets precedence (for value source write mode).
void kanzi::Binding::setSourceValue | ( | const Variant & | value | ) |
Set up source rule to specify a value.
void kanzi::Binding::setSourceDynamicObjectProperty | ( | string_view | objectPath, |
AbstractPropertyType | propertyType, | ||
PropertyField | field | ||
) |
Set up source rule to specify an object property.
rule | The binding rule which source property is specified. |
objectPath | Object path leading to the source object node, relative to the target object node. |
propertyType | The property type in the source object node. |
field | Field to bind in the property or PropertyFieldWhole for the whole property. |
void kanzi::Binding::addSourceDynamicObjectProperty | ( | string_view | objectPath, |
AbstractPropertyType | propertyType, | ||
PropertyField | field | ||
) |
Adds or a source property as the source rule.
It is possible to add multiple sources with this function.
void kanzi::Binding::setSourceMessageArgument | ( | AbstractPropertyType | argumentType, |
PropertyField | field | ||
) |
Set up source rule to specify a message argument.
void kanzi::Binding::setSourceResource | ( | ResourceID | id | ) |
Set up source as a resource object.
void kanzi::Binding::addDataSourceProperty | ( | string_view | objectPath | ) |
Adds a data source property as the source rule.
It is possible to add multiple sources with this function.
objectPath | Relative path to data source from the root data source. |
void kanzi::Binding::setZeroSource | ( | ) |
Set a zero source binding.
void kanzi::Binding::setTargetDynamicObjectProperty | ( | string_view | objectPath, |
AbstractPropertyType | propertyType, | ||
PropertyField | field | ||
) |
Set up target rule to specify an object property.
rule | The binding rule which target property is specified. |
objectPath | Object path leading to the target object node, relative to the target object node. |
propertyType | The property type in the target object node. |
field | Field to bind in the property or PropertyFieldWhole for the whole property. |
void kanzi::Binding::setTargetMessageArgument | ( | AbstractPropertyType | argumentType, |
PropertyField | field | ||
) |
Set up target rule to specify a message argument.
bool kanzi::Binding::read | ( | Node * | currentObjectNode, |
const MessageArguments * | sourceMessage | ||
) |
Read values from sourceMessage and store them in rule's internal cache.
bool kanzi::Binding::write | ( | Node * | currentObjectNode, |
MessageArguments * | targetMessage | ||
) |
Save the cached value from the rule to targetMessage if it has one cached.
Implicitly installs modifier of value source writers if necessary.
bool kanzi::Binding::update | ( | Node * | currentObjectNode, |
const MessageArguments * | sourceMessage, | ||
MessageArguments * | targetMessage | ||
) |
Read values from sourceMessage and write them to targetMessage if the binding rule type is a message argument to message argument.
Otherwise updates the binding depending on its type (e.g. property to property, variant to property).
rule | The binding rule to update. |
currentObjectNode | The object node for which the binding rule object paths are relative to. |
sourceMessage | The source message or KZ_NULL. |
targetMessage | The target message or KZ_NULL. |
out_updated | A pointer to a Boolean that is set to KZ_TRUE if the rule was updated, otherwise it is set to KZ_FALSE. |
bool kanzi::Binding::updateSource | ( | Node * | currentObjectNode, |
MessageArguments * | sourceMessage, | ||
const MessageArguments * | targetMessage | ||
) |
Update the source value in binding.
bool kanzi::Binding::readTargetValue | ( | Variant * | value | ) |
Read the target value.
const Variant* kanzi::Binding::getCachedSourceValue | ( | ) | const |
Returns the source value from rule's internal cache.
This is an internal Kanzi function.
void kanzi::Binding::addValidator | ( | BindingProcessorSharedPtr | processor | ) |
Add a validator object.
void kanzi::Binding::removeValidator | ( | const BindingProcessor & | processor | ) |
Remove a validator object.
|
inline |
|
inline |
size_t kanzi::Binding::getSourceRegisterCount | ( | ) | const |
Gets the number of source registers in binding rule.
size_t kanzi::Binding::getConstantRegisterCount | ( | ) | const |
Gets the number of constant registers in binding rule.
size_t kanzi::Binding::getTemporaryRegisterCount | ( | ) | const |
Gets the number of temporary registers in binding rule.
size_t kanzi::Binding::getDataSourceRegisterCount | ( | ) | const |
Gets the number of data source registers in binding rule.
void kanzi::Binding::attach | ( | Node * | objectNode | ) |
Attach binding.
This is Kanzi-internal function, use Node::addBinding() instead.
void kanzi::Binding::detach | ( | ) |
Detach binding.
This is Kanzi-internal function, use Node::addBinding() instead.
Node* kanzi::Binding::getAttachedNode | ( | ) | const |
Get the object node the rule is attached to, if any.
void kanzi::Binding::addConstantRegister | ( | const Variant & | constant | ) |
Add a constant value to the binding.
void kanzi::Binding::setConstantRegister | ( | size_t | index, |
const Variant & | constant | ||
) |
Set constant register at given index.
void kanzi::Binding::setTemporaryRegisterCount | ( | size_t | count | ) |
Set the number of temporaries for the binding.
const Variant* kanzi::Binding::getSourceRegister | ( | size_t | index | ) | const |
Get access to source register.
const Variant* kanzi::Binding::getConstantRegister | ( | size_t | index | ) | const |
Get access to constant register.
Variant* kanzi::Binding::getTemporaryRegister | ( | size_t | index | ) |
Get access to temporary register.
const Variant* kanzi::Binding::getDataSourceRegister | ( | size_t | index | ) | const |
Get access to data source register.
bool kanzi::Binding::getTargetPropertyType | ( | AbstractPropertyType & | out_targetPropertyType, |
PropertyField & | out_field | ||
) | const |
Returns target property type and property field of the binding rule if it is writing to property.
BindingSharedPtr kanzi::Binding::copy | ( | ) | const |
Copies a binding object.
|
inline |
Tells if this binding is attached.
void kanzi::Binding::addOperation | ( | BindingOperationSharedPtr | operation | ) |
Adds operation to the binding.
Operations are executed in order in which they are added to the binding when binding is invoked.
operation | Operation. |
|
inline |
Sets the template root of this binding.
Template root is used template root bindings. This is an internal function.
|
inline |
Gets the template root of this binding.
Template root is used template root bindings. This is an internal function.
optional<ResourceID> kanzi::Binding::getIdIfResourceSource | ( | ) | const |
|
friend |