Kanzi  3.9.6
Kanzi Engine API
kanzi::DataSourceBindingSource Class Reference

Data source binding source. More...

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

Inheritance diagram for kanzi::DataSourceBindingSource:
[legend]

Public Member Functions

string getPath () const
 Gets the source data object path. More...
 
- Public Member Functions inherited from kanzi::BindingSource
BindingSourceRuntimePtr createRuntime (BindingLookupContextPtr lookupContext)
 Creates binding source runtime. More...
 
virtual ~BindingSource ()
 Destructor. More...
 

Static Public Member Functions

static BindingSourcePtr create (string_view path)
 Creates a new data source binding source. More...
 

Protected Member Functions

BindingSourceRuntimePtr createRuntimeOverride (BindingLookupContextPtr lookupContext) override
 BindingSource::createRuntime implementation. More...
 
 DataSourceBindingSource (string_view path)
 Constructor. More...
 
- Protected Member Functions inherited from kanzi::BindingSource
 BindingSource ()
 Constructor. More...
 

Protected Attributes

string m_path
 Path to object to listen to. More...
 

Detailed Description

Data source binding source.

DataSourceBindingSource specifies a path to a data source in the local effective data source context. When the value specified by the path changes, it is used as the source value for the binding. If the data object specified by the path is not available, DataSourceBindingSource waits for the object to be available and connects when it exists for the local data source context.

Creating a data source binding source

To create a data source binding source:

// Create a data source binding source.
BindingSourcePtr source = DataSourceBindingSource::create("cluster.speed.kmh");

Writing to data sources with bindings

To write to a data source, you can create a two-way binding to a data source.

BindingSourcePtr source = DataSourceBindingSource::create("cluster.speed.needle.rotationAngle");
TwoWayBindingSharedPtr binding = TwoWayBinding::create(kanzi::move(source));
// Value in data source now controls the rotation of a 2D node.

Considerations

Data source binding sources can connect and read values only if a data source is available for the location in which they are used. For nodes this means that the DataContext::DataContextProperty is set in the node or in an ascendant of the node.

You can create a data source binding by binding to the DataContext::DataContextProperty of a Node. In this case, a DataObject within the DataContext can serve as the data source for the Node and its descendants. To create a data context binding:

BindingSharedPtr binding = Binding::create(kanzi::move(source));
// Local data context for node is now the DataContext identified by the path "cluster.speed" from the parent data context.
Since
Kanzi 3.7.0

Constructor & Destructor Documentation

◆ DataSourceBindingSource()

kanzi::DataSourceBindingSource::DataSourceBindingSource ( string_view  path)
inlineprotected

Constructor.

Parameters
pathData object path.

Member Function Documentation

◆ create()

static BindingSourcePtr kanzi::DataSourceBindingSource::create ( string_view  path)
static

Creates a new data source binding source.

Parameters
pathData object path.
Returns
The created data source binding source.

◆ getPath()

string kanzi::DataSourceBindingSource::getPath ( ) const
inline

Gets the source data object path.

Returns
Data object path.

◆ createRuntimeOverride()

BindingSourceRuntimePtr kanzi::DataSourceBindingSource::createRuntimeOverride ( BindingLookupContextPtr  lookupContext)
overrideprotectedvirtual

Member Data Documentation

◆ m_path

string kanzi::DataSourceBindingSource::m_path
protected

Path to object to listen to.


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