Kanzi  3.9.9
Kanzi Engine C++ API
kanzi::PropertyType< Type, typename > Class Template Reference

An instance of a PropertyType represents a single property type in the Kanzi property system. More...

#include <kanzi/core/property/property_type.hpp>

Public Types

using DataType = Type
 
using Descriptor = PropertyTypeDescriptor< Type >
 
using Traits = typename PropertyTypeDescriptor< Type >::Traits
 

Public Member Functions

Descriptorget () const
 
uint32_t getChangeFlags () const
 Gets the change flags for a property type. More...
 
PropertyDataType getDataType () const
 Gets the data type of a property type. More...
 
Traits::ReturnType getDefaultValue () const
 Gets the default value of a property type. More...
 
PropertyTypeEditorInfoSharedPtr getEditorInfo () const
 Gets the editor information of a property type. More...
 
const char * getName () const
 Gets the fully qualified name of a property type in the form "Class.PropertyType". More...
 
const char * getUnqualifiedName () const
 Gets the unqualified name of a property type in the form "PropertyType". More...
 
bool isInherited () const
 Returns whether a property type is inheritable. More...
 
 operator AbstractPropertyType () const
 Converting operator to get AbstractPropertyType instance referring to this PropertyType instance. More...
 
 PropertyType (FixedString name)
 Constructor. More...
 
 PropertyType (MetadataGeneratedName name)
 Constructor. More...
 
 PropertyType (FixedString name, DataType defaultValue, uint32_t changeFlags, bool inheritable)
 Constructor. More...
 
 PropertyType (MetadataGeneratedName name, DataType defaultValue, uint32_t changeFlags, bool inheritable)
 Constructor. More...
 
 PropertyType (FixedString name, DataType defaultValue, uint32_t changeFlags, bool inheritable, PropertyTypeEditorInfoSharedPtr editorInfo)
 Constructor. More...
 
 PropertyType (MetadataGeneratedName name, DataType defaultValue, uint32_t changeFlags, bool inheritable, PropertyTypeEditorInfoSharedPtr editorInfo)
 Constructor. More...
 
 ~PropertyType ()
 Destructor. More...
 

Protected Member Functions

 PropertyType ()
 Constructor. More...
 

Friends

class AbstractPropertyType
 
class DynamicPropertyType< Type >
 
class Node
 
class Object
 

Detailed Description

template<typename Type, typename = void>
class kanzi::PropertyType< Type, typename >

An instance of a PropertyType represents a single property type in the Kanzi property system.

A property type exists throughout the lifetime of an application, including the property types that you create during the runtime of an application.

To work with the existing property types in the Kanzi property system, use the DynamicPropertyType and AbstractPropertyType classes.

Examples

To declare a new property type:

// Example node which introduces a new static property type to the Kanzi property system.
class ExampleNode2D : public kanzi::Node2D
{
public:
// To introduce a static property type to the Kanzi property system use the
// PropertyType declaration in your class.
// For example, declare a property type whose data type is floating point
// number and is named "ExampleProperty".
static PropertyType<float> ExampleProperty;
// A convenient way to access the value of this property type is to create
// the get and set functions.
float getExampleProperty() const
{
return getProperty(ExampleProperty);
}
void setExampleProperty(float value)
{
setProperty(ExampleProperty, value);
}
// In the Kanzi Engine register the ExampleNode2D derived from the Node2D and the ExampleProperty
// property type.
// For more information about the metadata system in Kanzi, see the Node and Metaclass classes.
KZ_METACLASS_BEGIN(ExampleNode2D, Node2D, "MyNamespace.ExampleNode2D")
KZ_METACLASS_PROPERTY_TYPE(ExampleProperty)
// ...

To define a new property type:

// In the ExampleNode2D node type define a property type whose data type is a floating point number,
// is named "ExampleProperty", and has a fully qualified name "ExampleNode2D.ExampleProperty".
//
// For example, use these PropertyType constructor arguments to define a property type:
// - The first argument sets the fully qualified name. For example, set the fully qualified
// name to "ExampleNode2D.ExampleProperty".
// - The second argument sets the default value. This argument type depends on the data type
// of a property type. When queried, Kanzi returns the default value of the property, if you
// do not specify a property value either directly or indirectly (through styles, inheritance, and so on).
// For example, even though the Node::Visible property is not specified for every node to be true,
// the default value for this property is true.
// - The third argument sets the change flags. Each property type has a set of
// property change flags that indicate how changes to the property type value affect the application.
// For example property type with PropertyTypeChangeFlagFinalTransformation flag affects final
// transformation of a node and all its children.
// See PropertyTypeChangeFlag.
// - The fourth argument sets whether the value of this property type is inheritable.
// Inheritance determines whether nodes can inherit from their ancestor nodes the value of this property type.
// - The fifth argument sets the metadata for this property type that Kanzi Studio uses.
// For the list of all available metadata attributes in Kanzi documentation see
// Reference > Reference for showing Kanzi Engine plugin custom types in Kanzi Studio.
// - displayName sets a user-friendly name that users can see in the Properties window in Kanzi Studio.
// - tooltip sets the text shown when users hover over the name of this property in Kanzi Studio.
// - host sets the node types for which Kanzi Studio suggests the property and whether Kanzi Studio
// adds this property to a node automatically.
// - editor sets the editor type Kanzi Studio users use to set the value for the property.
// If you do not set an editor, Kanzi assigns a default editor.
// For a list of Kanzi Studio property editors, in Kanzi documentation see Reference >
// Kanzi Studio property editors for property types declared in Kanzi Engine plugins.
// - LowerBound sets the lowest value the property can have.
// - UpperBound sets the highest value the property can have.
// - Step sets the amount by which the property value changes when a Kanzi Studio user edits the value in the editor.
// If you do not want users to access a property type in Kanzi Studio, pass an empty
// PropertyTypeEditorInfoSharedPtr shared pointer.
PropertyType<float> ExampleNode2D::ExampleProperty(kzMakeFixedString("ExampleNode2D.ExampleProperty"), 2.2f, PropertyTypeChangeFlagFinalTransformation, true,
metadata.displayName = "Example property";
metadata.tooltip = "Property used as an example.";
metadata.host = "Node:user, Node2D:context";
metadata.editor = "Slider";
metadata.lowerBound = "0";
metadata.upperBound = "10";
metadata.step = "0.1";
));

To set or get a value of a property type from a node:

// To set a value of a property type in a node, use an existing PropertyType object.
node->setProperty(Node::VisibleProperty, false);
// To get the value of a property type from a node, use an existing PropertyType object.
bool visible = node->getProperty(Node::VisibleProperty);

To create a property type during application runtime:

// To create a new property type during application runtime, use the PropertyTypeDescriptor
// to define your property type.
//
// For example, use these PropertyTypeDescriptor arguments to define a property type:
// - The first argument sets the fully qualified name. For example, set the fully qualified
// name to "MyRuntimeBooleanProperty".
// - The second argument sets the default value. This argument type depends on the data type
// of a property type. When queried, Kanzi returns the default value of the property, if you
// do not specify a property value either directly or indirectly (through styles, inheritance, and so on).
// For example, even though the Node::Visible property is not specified for every node to be true,
// the default value for this property is true.
// - The third argument sets the change flags. Each property type has a set of
// property change flags that indicate how changes to the property type value affect the application.
// For example property type with PropertyTypeChangeFlagRender flag affects rendering and
// causes Kanzi to run updateRender().
// See PropertyTypeChangeFlag.
// - The fourth argument sets whether the value of this property type is inheritable.
// Inheritance determines whether nodes can inherit from their ancestor nodes the value of this property type.
// - For the fifth argument always pass an empty PropertyTypeEditorInfoSharedPtr shared pointer.
// Users cannot access in Kanzi Studio the property types created during the application runtime.
AbstractPropertyTypeDescriptor::ManagedDescriptor propertyType(new PropertyTypeDescriptor<bool>(MetadataGeneratedName("MyRuntimeBooleanProperty"),
true,
true,
// After you create a property type, add the property type to the Kanzi property system
// by registering the descriptor of the property type.
// You can access the new property type with DynamicPropertyType and AbstractPropertyType objects.
DynamicPropertyType<bool> property("MyRuntimeBooleanProperty");
node->setProperty(property, false);

Member Typedef Documentation

template<typename Type, typename = void>
using kanzi::PropertyType< Type, typename >::DataType = Type
template<typename Type, typename = void>
using kanzi::PropertyType< Type, typename >::Descriptor = PropertyTypeDescriptor<Type>
template<typename Type, typename = void>
using kanzi::PropertyType< Type, typename >::Traits = typename PropertyTypeDescriptor<Type>::Traits

Constructor & Destructor Documentation

template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( FixedString  name)
explicit

Constructor.

Parameters
nameFully qualified name for the property type as a FixedString.
template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( MetadataGeneratedName  name)
explicit

Constructor.

Parameters
nameFully qualified name for the property type as a MetadataGeneratedName.
template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( FixedString  name,
DataType  defaultValue,
uint32_t  changeFlags,
bool  inheritable 
)
explicit

Constructor.

Parameters
nameFully qualified name for the property type as a FixedString.
defaultValueThe default value for the property type.
changeFlagsThe flags that indicate how changes to the property type value affect the application.
See also
PropertyTypeChangeFlag for all available change flags.
Parameters
inheritableSets whether this property type is inheritable. Inheritance determines whether nodes can inherit from their ancestor nodes the value of this property type.
template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( MetadataGeneratedName  name,
DataType  defaultValue,
uint32_t  changeFlags,
bool  inheritable 
)
explicit

Constructor.

Parameters
nameFully qualified name for the property type as a MetadataGeneratedName.
defaultValueThe default value for the property type.
changeFlagsThe flags that indicate how changes to the property type value affect the application.
See also
PropertyTypeChangeFlag for all available change flags.
Parameters
inheritableSets whether this property type is inheritable. Inheritance determines whether nodes can inherit from their ancestor nodes the value of this property type.
template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( FixedString  name,
DataType  defaultValue,
uint32_t  changeFlags,
bool  inheritable,
PropertyTypeEditorInfoSharedPtr  editorInfo 
)
explicit

Constructor.

Parameters
nameFully qualified name for the property type as a FixedString.
defaultValueThe default value for the property type.
changeFlagsThe flags that indicate how changes to the property type value affect the application.
See also
PropertyTypeChangeFlag for all available change flags.
Parameters
inheritableSets whether this property type is inheritable. Inheritance determines whether nodes can inherit from their ancestor nodes the value of this property type.
editorInfoSets the editor information for this property type that Kanzi Studio uses.
template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( MetadataGeneratedName  name,
DataType  defaultValue,
uint32_t  changeFlags,
bool  inheritable,
PropertyTypeEditorInfoSharedPtr  editorInfo 
)
explicit

Constructor.

Parameters
nameFully qualified name for the property type as a MetadataGeneratedName.
defaultValueThe default value for the property type.
changeFlagsThe flags that indicate how changes to the property type value affect the application.
See also
PropertyTypeChangeFlag for all available change flags.
Parameters
inheritableSets whether this property type is inheritable. Inheritance determines whether nodes can inherit from their ancestor nodes the value of this property type.
editorInfoSets the editor information for this property type that Kanzi Studio uses.
template<typename Type , typename A >
kanzi::PropertyType< Type, A >::~PropertyType ( )

Destructor.

template<typename Type , typename A >
kanzi::PropertyType< Type, A >::PropertyType ( )
explicitprotected

Constructor.

Member Function Documentation

template<typename Type , typename A >
kanzi::PropertyType< Type, A >::operator AbstractPropertyType ( ) const

Converting operator to get AbstractPropertyType instance referring to this PropertyType instance.

Returns
AbstractPropertyType object referring to this PropertyType instance.
template<typename Type , typename A >
PropertyType< Type, A >::Traits::ReturnType kanzi::PropertyType< Type, A >::getDefaultValue ( ) const

Gets the default value of a property type.

When no other value is available, getProperty functions return the default value.

Returns
The default value of a property type.
template<typename Type , typename A >
const char * kanzi::PropertyType< Type, A >::getName ( ) const

Gets the fully qualified name of a property type in the form "Class.PropertyType".

Returns
The fully qualified name of a property type.
See also
getUnqualifiedName()
template<typename Type , typename A >
const char * kanzi::PropertyType< Type, A >::getUnqualifiedName ( ) const

Gets the unqualified name of a property type in the form "PropertyType".

Returns
The unqualified name of a property type.
See also
getName()
template<typename Type , typename A >
PropertyDataType kanzi::PropertyType< Type, A >::getDataType ( ) const

Gets the data type of a property type.

The data type of a property type defines the data representation type of each property value. For example, float.

Returns
The data type of a property type.
template<typename Type , typename A >
bool kanzi::PropertyType< Type, A >::isInherited ( ) const

Returns whether a property type is inheritable.

Inheritable property types provide values to all descendant nodes.

Returns
If the property type is inheritable, true, otherwise false.
template<typename Type , typename A >
uint32_t kanzi::PropertyType< Type, A >::getChangeFlags ( ) const

Gets the change flags for a property type.

Change flags indicate whether a modification of property value invalidates a particular aspect of a node. For example, when you change the Node::HeightProperty or Node::WidthProperty in a node Kanzi recalculates the layout.

Returns
The change flags for a property type.
template<typename Type , typename A >
PropertyTypeEditorInfoSharedPtr kanzi::PropertyType< Type, A >::getEditorInfo ( ) const

Gets the editor information of a property type.

Returns
The editor information of a property type.
template<typename Type , typename A >
PropertyType< Type, A >::Descriptor * kanzi::PropertyType< Type, A >::get ( ) const

Friends And Related Function Documentation

template<typename Type, typename = void>
friend class Object
friend
template<typename Type, typename = void>
friend class Node
friend
template<typename Type, typename = void>
friend class AbstractPropertyType
friend
template<typename Type, typename = void>
friend class DynamicPropertyType< Type >
friend

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