Kanzi  3.9.9
Kanzi Engine C++ API
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. More...
 

Protected Member Functions

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

Protected Attributes

BindingSourcePtr m_pushSource
 Push source. 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
using BindingProcessorConstIterator = BindingProcessorContainer::const_iterator
 Binding processor iterator type. More...
 
using BindingProcessorContainer = vector< BindingProcessorSharedPtr >
 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

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.
// Create another binding source to serve as the push target.

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

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

Constructor.

Parameters
readSourceRegular, readable source.
pushSourcePush source

Member Function Documentation

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.
AbstractBindingRuntimeSharedPtr kanzi::ToSourceBinding::createRuntimeOverride ( AbstractBindingSharedPtr  binding,
BindingLookupContextPtr  sourceLookupContext,
BindingTargetRuntimePtr  bindingTarget 
)
overrideprotectedvirtual

Member Data Documentation

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: