Kanzi 3.9.10
kanzi::ToSourceBinding Class Reference

To Source bindings are one-way bindings that have an extra source to which to write the result value. More...

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

Inheritance diagram for kanzi::ToSourceBinding:
[legend]

Static Public Member Functions

static ToSourceBindingSharedPtr create (BindingSourcePtr readSource, BindingSourcePtr pushSource)
 Creates a To Source binding.
 

Protected Member Functions

AbstractBindingRuntimeSharedPtr createRuntimeOverride (AbstractBindingSharedPtr binding, BindingLookupContextPtr sourceLookupContext, BindingTargetRuntimePtr bindingTarget) override
 AbstractBinding::createRuntime() implementation.
 
 ToSourceBinding (BindingSourcePtr readSource, BindingSourcePtr pushSource)
 Constructor.
 
- Protected Member Functions inherited from kanzi::AbstractBinding
 AbstractBinding (BindingSourcePtr source)
 Constructor.
 
virtual void addReverseProcessorOverride (BindingProcessorSharedPtr processor)
 Implementation-dependent binding processor add (reverse direction).
 
virtual BindingProcessorConstIterator beginReverseProcessorsOverride () const
 Implementation-dependent access to reverse direction binding processors.
 
virtual BindingProcessorConstIterator endReverseProcessorsOverride () const
 Implementation-dependent access to reverse direction binding processors.
 
virtual void removeReverseProcessorOverride (BindingProcessor &processor)
 Implementation-dependent binding processor remove (reverse direction).
 

Protected Attributes

BindingSourcePtr m_pushSource
 Push source.
 
- 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.
 
BindingProcessorContainer m_processors
 Binding processor (forward direction).
 
BindingSourcePtr m_source
 Binding source.
 

Additional Inherited Members

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

Detailed Description

To Source bindings are one-way bindings that have an extra source to which to write the result value.

To Source binding is the opposite of a regular one-way binding. To Source binding updates the source property whenever the target property changes.

The extra binding source, called push source, is used only for writing. To Source bindings have a binding target just like regular one-way bindings, but are usually set to Node or RenderPass objects with a DummyBindingTargetRuntime, so that they only write values to the push source.

The push source is usually a regular ObjectPropertyBindingSource. It does not install a value source or a property modifier, but instead writes the property value using setProperty().

Creating a ToSourceBinding

To create a ToSourceBinding, create an extra binding source first:

// Create a binding source for the regular source to read from.
BindingSourcePtr source = ObjectPropertyBindingSource::create("emptyNode", Node2D::OpacityProperty);
// Create another binding source to serve as the push target.
BindingSourcePtr pushSource = ObjectPropertyBindingSource::create("siblingNode", Node2D::OpacityProperty);

Then create a ToSourceBinding using the push source created:

// Create a To Source binding using both the read source and the push source.
ToSourceBindingSharedPtr binding = ToSourceBinding::create(kanzi::move(source), kanzi::move(pushSource));

To add a ToSourceBinding to a Node or RenderPass, use a DummyBindingTargetRuntime:

// Set the binding to the root node.
// It reads values from its first child and writes them to the other child.
root->setBinding(binding);
// Because target property is not provided, a dummy binding target is created.

You can specify a target property when calling setBinding for the ToSourceBinding. In this case, both values are written when the binding is executed.

Unlike with regular one-way bindings, which require the binding source and target to be connected to be considered connected, ToSourceBinding also requires the push source to be connected. Trying to update the binding manually when both sources or the target are not connected does nothing. However, DummyBindingTargetRuntime is considered always connected.

See also
AbstractBinding
Since
Kanzi 3.7.0

Constructor & Destructor Documentation

◆ ToSourceBinding()

kanzi::ToSourceBinding::ToSourceBinding ( BindingSourcePtr readSource,
BindingSourcePtr pushSource )
inlineexplicitprotected

Constructor.

Parameters
readSourceRegular, readable source.
pushSourcePush source

Member Function Documentation

◆ create()

static ToSourceBindingSharedPtr kanzi::ToSourceBinding::create ( BindingSourcePtr readSource,
BindingSourcePtr pushSource )
static

Creates a To Source binding.

Parameters
readSourceRegular, readable source.
pushSourcePush source
Returns
The created To Source binding.

◆ createRuntimeOverride()

AbstractBindingRuntimeSharedPtr kanzi::ToSourceBinding::createRuntimeOverride ( AbstractBindingSharedPtr binding,
BindingLookupContextPtr sourceLookupContext,
BindingTargetRuntimePtr bindingTarget )
overrideprotectedvirtual

Member Data Documentation

◆ m_pushSource

BindingSourcePtr kanzi::ToSourceBinding::m_pushSource
protected

Push source.

Used to create another binding source runtime to use as push source and write the binding result to. Regular binding target runtime is still also used.


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