All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
kanzi::Binding Class Reference

Binding objects establish connections between properties, message values or arguments. More...

#include <kanzi/binding/binding.hpp>

Inheritance diagram for kanzi::Binding:
kanzi::Object

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 VariantgetCachedSourceValue () 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...
 
NodegetAttachedNode () 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 VariantgetSourceRegister (size_t index) const
 Get access to source register. More...
 
const VariantgetConstantRegister (size_t index) const
 Get access to constant register. More...
 
VariantgetTemporaryRegister (size_t index)
 Get access to temporary register. More...
 
const VariantgetDataSourceRegister (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
 
- Public Member Functions inherited from kanzi::Object
 Object (Domain *domain)
 
virtual ~Object ()
 
DomaingetDomain () const
 Returns the domain the object belongs to. More...
 
KzuPropertyManager * getPropertyManager () const
 Returns the property manager of the object. More...
 
KzuTaskSchedulergetTaskScheduler () const
 Returns the task scheduler of the object. More...
 
KzuMessageDispatchergetMessageDispatcher () const
 Returns the message dispatcher of the object. More...
 
ResourceManagergetResourceManager () const
 Returns the resource manager of the object. More...
 
virtual const MetaclassgetDynamicMetaclass () 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...
 
AppliedStyleEntryapplyObjectStyle (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 Public Member Functions inherited from kanzi::Object
static const MetaclassgetStaticMetaclass ()
 Returns the metaclass of Object class. More...
 
static
PropertyTypeEditorInfoSharedPtr 
makeEditorInfo ()
 Default implementation that returns empty editor info. More...
 

Friends

class DataContextListener
 

Additional Inherited Members

- Protected Types inherited from kanzi::Object
typedef vector
< AppliedStyleEntry * > 
AppliedStyleContainer
 Applied style container. More...
 
- Protected Member Functions inherited from kanzi::Object
void initialize ()
 
void onCopy (const Object &other)
 
- Protected Attributes inherited from kanzi::Object
AppliedStyleContainer m_appliedStyles
 Listing of applied styles applied to this object. More...
 

Detailed Description

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.

Member Typedef Documentation

typedef BindingProcessorVector::const_iterator kanzi::Binding::BindingProcessorIterator

Member Enumeration Documentation

Binding mode enumeration.

Enumerator
ModeOneWay 

One way binding.

ModeTwoWay 

Two way binding.

Constructor & Destructor Documentation

virtual kanzi::Binding::~Binding ( )
virtual

Member Function Documentation

static BindingSharedPtr kanzi::Binding::create ( Domain domain)
static

Creates a binding object.

static BindingSharedPtr kanzi::Binding::create ( Domain domain,
string_view  objectPath,
AbstractPropertyType  sourcePropertyType,
PropertyField  sourceField,
AbstractPropertyType  targetPropertyType,
PropertyField  targetField 
)
static

Helper to create a property-to-property binding rule object.

Parameters
memoryManagerThe memory manager to use for allocations.
domainThe UI domain.
sourcePathAn object path pointing to the source object that has the source property. This can be relative to the target property owner.
sourcePropertyTypeKzuPropertyType of the source property.
sourceFieldField of the source property to bind or PropertyFieldWhole for the whole property.
targetPropertyTypeKzuPropertyType of the target property.
targetFieldField of the target property to bind or PropertyFieldWhole for the whole property.
out_ruleA pointer that is set to point to the new KzuBindingRule.
Returns
KZS_SUCCESS on success.
static BindingSharedPtr kanzi::Binding::createFromDataObjectPath ( Domain domain,
string_view  objectPath,
AbstractPropertyType  targetPropertyType,
PropertyField  targetField 
)
static

Helper to create a data object-to-property binding object.

Parameters
domainThe UI domain.
objectPathA relative path pointing from current data context to the source data object.
targetPropertyTypeType of the property used as binding target.
targetFieldField of the target property to bind or PropertyFieldWhole for the whole property.
Returns
Resulting binding object.
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.

Parameters
ruleThe binding rule which source property is specified.
objectPathObject path leading to the source object node, relative to the target object node.
propertyTypeThe property type in the source object node.
fieldField to bind in the property or PropertyFieldWhole for the whole property.
Returns
KZS_SUCCESS on success.
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.

Parameters
ruleThe binding rule which target property is specified.
objectPathObject path leading to the target object node, relative to the target object node.
propertyTypeThe property type in the target object node.
fieldField to bind in the property or PropertyFieldWhole for the whole property.
Returns
KZS_SUCCESS on success.
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).

Parameters
ruleThe binding rule to update.
currentObjectNodeThe object node for which the binding rule object paths are relative to.
sourceMessageThe source message or KZ_NULL.
targetMessageThe target message or KZ_NULL.
out_updatedA pointer to a Boolean that is set to KZ_TRUE if the rule was updated, otherwise it is set to KZ_FALSE.
Returns
KZS_SUCCESS on success. KZS_ERROR_ENUM_OUT_OF_RANGE if the binding source type is invalid.
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.

BindingProcessorIterator kanzi::Binding::beginBindingProcessors ( ) const
inline
BindingProcessorIterator kanzi::Binding::endBindingProcessors ( ) const
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.

bool kanzi::Binding::isAttached ( ) const
inline

Friends And Related Function Documentation

friend class DataContextListener
friend

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