Binding objects establish connections between properties, message values or arguments. More...
#include <kanzi/binding/binding.hpp>
Public Types | |
enum | Mode { ModeOneWay, ModeTwoWay } |
Binding mode enumeration. More... | |
typedef vector < BindingProcessorSharedPtr > | BindingProcessorVector |
typedef BindingProcessorVector::const_iterator | BindingProcessorIterator |
Public Member Functions | |
void | setMode (Mode mode) |
Set binding mode. More... | |
Mode | getMode () const |
Get binding 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) const |
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 | 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 |
![]() | |
Object (Domain *domain) | |
virtual | ~Object () |
Domain * | getDomain () const |
Returns the domain the object belongs to. More... | |
KzuPropertyManager * | getPropertyManager () const |
Returns the property manager of the object. 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 |
Returns the metaclass of the dynamic type of the object. More... | |
bool | isTypeOf (const Metaclass *objectType) const |
Determines if the type of this object is the given type or derived from it. More... | |
template<typename DataType > | |
void | setProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::DataType value) |
Sets the local value of a property. More... | |
void | setProperty (const PropertyType< ResourceID > &propertyType, ResourceSharedPtr value) |
Sets the local value of a resource id property with a resource pointer. More... | |
template<typename DataType > | |
DataType | getProperty (const PropertyType< DataType > &propertyType) const |
Returns the current value of a property. More... | |
template<typename DataType > | |
bool | getProperty (const PropertyType< DataType > &propertyType, typename PropertyType< DataType >::DataType &value) 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 > | |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::DataType value) |
void | setAbstractProperty (AbstractPropertyType abstractPropertyType, ResourceSharedPtr value) |
template<typename DataType > | |
DataType | getAbstractProperty (AbstractPropertyType abstractPropertyType) const |
template<typename DataType > | |
bool | getAbstractProperty (AbstractPropertyType abstractPropertyType, typename PropertyType< DataType >::DataType &value) const |
bool | hasValue (AbstractPropertyType propertyType) const |
Evaluates whether there are any inputs into the property value. More... | |
bool | hasLocalValue (AbstractPropertyType propertyType) const |
Evaluates whether there is a local value set for the property. More... | |
void | removeLocalValue (AbstractPropertyType propertyType) |
Removes the local value associated with the property. More... | |
void | copyLocalValues (const Object &other) |
Copies all local values from another object. More... | |
virtual void | onPropertyChanged (AbstractPropertyType propertyType, KzuPropertyNotificationReason reason) |
Virtual function to handle property change notifications. More... | |
AppliedStyleEntry * | applyObjectStyle (kanzi::StyleSharedPtr style) |
Applies a style to an object. More... | |
void | unapplyObjectStyle (AppliedStyleEntry *appliedStyleEntry) |
void | applyObjectStyles () |
Apply all styles for an object node. More... | |
void | unapplyObjectStyles () |
Unapplies and removes all applied styles. 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 | createFromDataObjectPath (Domain *domain, string_view objectPath, AbstractPropertyType targetPropertyType, PropertyField targetField) |
Helper to create a data object-to-property binding object. More... | |
![]() | |
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 |
Additional Inherited Members | |
![]() | |
typedef vector < AppliedStyleEntry * > | AppliedStyleContainer |
Applied style container. More... | |
![]() | |
void | initialize () |
void | onCopy (const Object &other) |
![]() | |
AppliedStyleContainer | m_appliedStyles |
Listing of applied styles applied to this object. More... | |
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 |
Helper to create a data object-to-property binding 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 | ) |
Set binding mode.
Mode kanzi::Binding::getMode | ( | ) | const |
Get binding 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.
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 | ||
) | const |
Save the cached value from the rule to targetMessage if it has one cached.
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 ::kzuObjectNodeAddBinding() instead.
void kanzi::Binding::detach | ( | ) |
Detach binding.
This is Kanzi-internal function, use ::kzuObjectNodeRemoveBinding() 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::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 |
|
friend |