Kanzi 3.9.10
kanzi::NodeReference< NodeType > Class Template Reference

Provides functionality for a reference to any attached node that you can access using a relative path. More...

#include <kanzi/core.ui/node/node_reference.hpp>

Inheritance diagram for kanzi::NodeReference< NodeType >:
[legend]

Public Types

typedef shared_ptr< NodeTypeNodeTypeSharedPtr
 
typedef weak_ptr< NodeTypeNodeTypeWeakPtr
 

Public Member Functions

void attach () override
 Attaches a node reference.
 
void detach () override
 Detaches a node reference.
 
NodeTypeSharedPtr get () const
 Returns the referenced node.
 
 NodeReference (Node &baseNode, const PropertyType< string > &propertyType)
 Constructor.
 
void setUserReference (NodeTypeSharedPtr node)
 Sets the node reference to refer to a node.
 
void update () override
 Refreshes a node reference.
 
virtual ~NodeReference ()
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from kanzi::AbstractNodeReference
 ~AbstractNodeReference ()
 

Detailed Description

template<typename NodeType>
class kanzi::NodeReference< NodeType >

Provides functionality for a reference to any attached node that you can access using a relative path.

Kanzi installs the node reference on a base node. Kanzi then starts the look-up from the path that it retrieves from a property in the base node that you set in the NodeReference function. This path is relative to the base node.

You can override the look-up by assigning user reference node, in which case, Kanzi always returns the assigned node, and does not perform a look-up.

Member Typedef Documentation

◆ NodeTypeSharedPtr

template<typename NodeType >
typedef shared_ptr<NodeType> kanzi::NodeReference< NodeType >::NodeTypeSharedPtr

◆ NodeTypeWeakPtr

template<typename NodeType >
typedef weak_ptr<NodeType> kanzi::NodeReference< NodeType >::NodeTypeWeakPtr

Constructor & Destructor Documentation

◆ NodeReference()

template<typename NodeType >
kanzi::NodeReference< NodeType >::NodeReference ( Node & baseNode,
const PropertyType< string > & propertyType )
inlineexplicit

Constructor.

Parameters
baseNodeThe node where Kanzi installs the constructed node reference.
propertyTypeThe property of a baseNode the value of which Kanzi is using to resolve the referenced node.

◆ ~NodeReference()

Destructor.

Member Function Documentation

◆ attach()

template<typename NodeType >
void kanzi::NodeReference< NodeType >::attach ( )
inlineoverridevirtual

Attaches a node reference.

Kanzi uses this reference to keep track of the node to which the relative path in the base node points.

Implements kanzi::AbstractNodeReference.

◆ detach()

template<typename NodeType >
void kanzi::NodeReference< NodeType >::detach ( )
inlineoverridevirtual

Detaches a node reference.

When you detach a node reference, Kanzi stops tracking the node to which the relative path in the base node points.

Implements kanzi::AbstractNodeReference.

◆ update()

template<typename NodeType >
void kanzi::NodeReference< NodeType >::update ( )
inlineoverridevirtual

Refreshes a node reference.

Call this function when in the base node the value of the property that sets the relative path changes.

Implements kanzi::AbstractNodeReference.

◆ setUserReference()

template<typename NodeType >
void kanzi::NodeReference< NodeType >::setUserReference ( NodeTypeSharedPtr node)
inline

Sets the node reference to refer to a node.

This function overrides the resolving referenced node by path. The node reference does not take ownership nor keeps alive the passed node.

Parameters
nodeA node to which the reference refers. To reset the reference and use the relative path set in the property of the base node, pass nullptr.
See also
get()

◆ get()

template<typename NodeType >
NodeTypeSharedPtr kanzi::NodeReference< NodeType >::get ( ) const
inline

Returns the referenced node.

Returns
Returns the referenced node referenced by relative path or with the setUserReference function.

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