Properties#
This class defines a property (similar to Python built-in properties), i.e., a pair of getter and setter. In addition, it holds (for auto- documentation) a default value, a description, and the name of the involved types. A property has a value of type
PropertyField
, which is one ofbool
,int
,float
,string
,Vector2
or a collection (a vector in C++, a list in Python) thereof. Properties are used to configure sub-classes ofHasProperties
when using bindings like YAML or Python. Properties values are accessed using the methods exposed byHasProperties
.Constructs a navground property from a Python property.
- Parameters:
property (
property
) – The Python propertydefault (
navground.core.PropertyField
) – The default value (should be convertible to the property type)type_name (str) – The property type name
description (str) – Optional description
schema (
typing.Callable[[dict[str, typing.Any]], None]
) – Optional schema modifierdeprecated_names (list[str]) – A list of deprecated names for this property
Create a value of the desired type.
- Parameters:
type_name – The type name
- Returns:
A value or null is the type name is not valid.
- Type:
Union[bool, int, float, str, Vector2, list[bool], list[int], list[float], list[str], list[Vector2]]
The property default value, i.e., the value of the property when the object is initialized.
- Type:
A textual description of the property, used for auto documentation.
- Type:
The name of the property-owner type.
- Type:
Whether the property is readonly
- Type:
The name of the property value type, used for auto documentation.
This class defines set and get methods to access named
Property
“properties”.Gets the value of the specified property.
- Parameters:
name – The name of the property
- Raise:
std::runtime_error A runtime error if no property is found.
- Returns:
The value of the property
Gets the type of a property.
- Parameters:
name – The name of the property
- Returns:
The property type name or an empty string if the property is not defined.
Checks whether a property exists.
- Parameters:
name – The name of the property
- Returns:
True if the property exists
Set the value of a named property. Fails silently if no property can be found or if the value has a non-compatible type.
- Parameters:
name – The name of the property
value – The desired value for the property