Kanzi Framework  3.9.0
Kanzi Engine API
kanzi::TwoWayBinding Class Reference

Two-way binding causes changes to either the source value or the target value to automatically update the other. More...

#include <kanzi/core.ui/binding/two_way_binding.hpp>

Inheritance diagram for kanzi::TwoWayBinding:
[legend]

Static Public Member Functions

static TwoWayBindingSharedPtr create (BindingSourcePtr source)
 Creates a two-way binding. More...
 
static TwoWayBindingSharedPtr create (string_view sourcePath, AbstractPropertyType sourcePropertyType, PropertyField sourceField)
 Creates a two-way binding. More...
 
static TwoWayBindingSharedPtr create (string_view sourcePath, AbstractPropertyType sourcePropertyType)
 Creates a two-way binding. More...
 

Protected Member Functions

void addReverseProcessorOverride (BindingProcessorSharedPtr processor) override
 AbstractBinding::addReverseBindingProcessorOverride implementation. More...
 
BindingProcessorConstIterator beginReverseProcessorsOverride () const override
 Gets an iterator to the beginning of reverse binding processors. More...
 
AbstractBindingRuntimeSharedPtr createRuntimeOverride (AbstractBindingSharedPtr binding, BindingLookupContextPtr sourceLookupContext, BindingTargetRuntimePtr targetRuntime) override
 AbstractBinding::createRuntime() implementation. More...
 
BindingProcessorConstIterator endReverseProcessorsOverride () const override
 Gets an iterator to the end of reverse binding processors. More...
 
void removeReverseProcessorOverride (BindingProcessor &processor) override
 AbstractBinding::removeReverseBindingProcessorOverride implementation. More...
 
 TwoWayBinding (BindingSourcePtr source)
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::AbstractBinding
 AbstractBinding (BindingSourcePtr source)
 Constructor. More...
 

Protected Attributes

BindingProcessorContainer m_reverseProcessors
 Binding processors (reverse direction). More...
 
- Protected Attributes inherited from kanzi::AbstractBinding
bool m_createdFromKZB
 Is the binding sourced from a KZB? This field is used to determine if the binding should be removed during patching. More...
 
BindingProcessorContainer m_processors
 Binding processor (forward direction). More...
 
BindingSourcePtr m_source
 Binding source. More...
 

Additional Inherited Members

- Public Types inherited from kanzi::AbstractBinding
typedef BindingProcessorContainer::const_iterator BindingProcessorConstIterator
 Binding processor iterator type. More...
 
typedef vector< BindingProcessorSharedPtrBindingProcessorContainer
 Binding processor container type. More...
 
- Public Member Functions inherited from kanzi::AbstractBinding
void addProcessor (BindingProcessorSharedPtr processor)
 Add a binding processor. More...
 
void addReverseProcessor (BindingProcessorSharedPtr processor)
 Add a binding processor (reverse direction). More...
 
BindingProcessorConstIterator beginProcessors () const
 Gets an iterator to the beginning of binding processors. More...
 
BindingProcessorConstIterator beginReverseProcessors () const
 Gets an iterator to the beginning of reverse direction binding processors. More...
 
AbstractBindingRuntimeSharedPtr createRuntime (AbstractBindingSharedPtr binding, BindingLookupContextPtr sourceLookupContext, BindingTargetRuntimePtr targetRuntime)
 Creates a binding runtime for this binding. More...
 
BindingProcessorConstIterator endProcessors () const
 Gets an iterator to the end of binding processors. More...
 
BindingProcessorConstIterator endReverseProcessors () const
 Gets an iterator to the end of reverse direction binding processors. More...
 
BindingSourcegetSource ()
 Gets the binding source for this binding. More...
 
bool isCreatedFromKZB () const
 Indicates whether the binding is sourced from a KZB? Used to check whether or not to remove the binding during patching. More...
 
void removeProcessor (BindingProcessor &processor)
 Remove a binding processor. More...
 
void removeReverseProcessor (BindingProcessor &processor)
 Remove a binding processor (reverse direction). More...
 
void setCreatedFromKZB (bool flag)
 Sets the created from KZB flag. More...
 
virtual ~AbstractBinding ()=default
 Destructor. More...
 

Detailed Description

Two-way binding causes changes to either the source value or the target value to automatically update the other.

In a two-way binding the binding from the source to target works the same way as in a Binding. When the source value is modified, the value is written to the BindingTargetRuntime of the TwoWayBinding.

When anything other than the binding itself modifies the target value, the value is copied to the source. The value is copied to the source using setProperty() to write the property value.

Removing the binding does not erase the value that is written to the source.

See also
AbstractBinding
Since
Kanzi 3.7.0

Constructor & Destructor Documentation

◆ TwoWayBinding()

kanzi::TwoWayBinding::TwoWayBinding ( BindingSourcePtr  source)
inlineexplicitprotected

Constructor.

Parameters
sourceBinding source owned by this binding.

Member Function Documentation

◆ create() [1/3]

static TwoWayBindingSharedPtr kanzi::TwoWayBinding::create ( BindingSourcePtr  source)
static

Creates a two-way binding.

Parameters
sourceBinding source.
Returns
The created two-way binding.

◆ create() [2/3]

static TwoWayBindingSharedPtr kanzi::TwoWayBinding::create ( string_view  sourcePath,
AbstractPropertyType  sourcePropertyType,
PropertyField  sourceField 
)
static

Creates a two-way binding.

Parameters
sourcePathPath to source object.
sourcePropertyTypeSource property type from which to bind.
sourceFieldField of the source property type from which to bind. Use PropertyFieldWhole to bind to the whole property.
Returns
The created two-way binding.

◆ create() [3/3]

static TwoWayBindingSharedPtr kanzi::TwoWayBinding::create ( string_view  sourcePath,
AbstractPropertyType  sourcePropertyType 
)
inlinestatic

Creates a two-way binding.

Whole property field is used.

Parameters
sourcePathPath to source object.
sourcePropertyTypeSource property type from which to bind.
Returns
The created two-way binding.

◆ createRuntimeOverride()

AbstractBindingRuntimeSharedPtr kanzi::TwoWayBinding::createRuntimeOverride ( AbstractBindingSharedPtr  binding,
BindingLookupContextPtr  sourceLookupContext,
BindingTargetRuntimePtr  targetRuntime 
)
overrideprotectedvirtual

◆ addReverseProcessorOverride()

void kanzi::TwoWayBinding::addReverseProcessorOverride ( BindingProcessorSharedPtr  processor)
inlineoverrideprotectedvirtual

AbstractBinding::addReverseBindingProcessorOverride implementation.

Reimplemented from kanzi::AbstractBinding.

◆ removeReverseProcessorOverride()

void kanzi::TwoWayBinding::removeReverseProcessorOverride ( BindingProcessor processor)
inlineoverrideprotectedvirtual

AbstractBinding::removeReverseBindingProcessorOverride implementation.

Reimplemented from kanzi::AbstractBinding.

◆ beginReverseProcessorsOverride()

BindingProcessorConstIterator kanzi::TwoWayBinding::beginReverseProcessorsOverride ( ) const
inlineoverrideprotectedvirtual

Gets an iterator to the beginning of reverse binding processors.

Returns
Iterator to beginning of processor array.

Reimplemented from kanzi::AbstractBinding.

◆ endReverseProcessorsOverride()

BindingProcessorConstIterator kanzi::TwoWayBinding::endReverseProcessorsOverride ( ) const
inlineoverrideprotectedvirtual

Gets an iterator to the end of reverse binding processors.

Returns
Iterator to end of processor array.

Reimplemented from kanzi::AbstractBinding.

Member Data Documentation

◆ m_reverseProcessors

BindingProcessorContainer kanzi::TwoWayBinding::m_reverseProcessors
protected

Binding processors (reverse direction).


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