Properties#
#include "navground/core/property.h"
A function that gets a value of type
T
from an object of typeC
.
A function that sets a value of type
T
of an object of typeC
.
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 Field, which is one of
bool
,int
,float
,string
, navground::core::Vector2 or a collection (a vector in C++, a list in Python) thereof. Properties are used to configure sub-classes of navground::core::HasProperties when using bindings like YAML or Python. Properties values are accessed using the methods exposed by navground::core::HasProperties.Public Types
The type of the scalar values held by the property.
The type of the value held by the property.
The type of the property value getter, i.e., a function that gets the property value from the owner.
The type of the property value setter, i.e., a function that sets the property value of the owner.
A custom YAML schema modifier
Public Members
The property value getter.
The property value setter.
The property default value, i.e., the value of the property when the object is initialized.
The name of the property value type, used for auto documentation.
A textual description of the property, used for auto documentation.
The name of the property-owner type.
Alternative deprecated names for the property
Whether the property is readonly
A custom YAML schema for the property to add validity constrains
Public Static Functions
Makes a property from a pair of typed setters and getters. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getters and setters. The property type is effectively preserved inside the getter and setter.- Parameters:
getter – [in] A typed getter
setter – [in] A typed setter
default_value – [in] The property default value
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
- Returns:
A property
Makes a readonly property with a getter. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getter. The property type is effectively preserved inside the getter. The property default is set toT{}
.- Parameters:
getter – [in] A typed getter
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
- Returns:
A property
Makes a readonly property from a class getter. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getter. The property type is effectively preserved inside the getter. The property default is set toT{}
.- Parameters:
getter – [in] The getter
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
- Returns:
A property
Makes a property from a pair of class setters and getters. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getters and setters. The property type is effectively preserved inside the getter and setter.- Parameters:
getter – [in] A getter
setter – [in] A setter
default_value – [in] The property default value
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
U – The type manipulated by the getter and setter.
- Returns:
A property
Makes a property from a pair of class setters and getters. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getters and setters. The property type is effectively preserved inside the getter and setter.- Parameters:
getter – [in] A getter
setter – [in] A setter
default_value – [in] The property default value
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
U – The type manipulated by the getter and setter.
- Returns:
A property
Makes a property that gets and sets a class member. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getters and setters. The property type is effectively preserved inside the getter and setter.- Parameters:
param – [in] A class member
default_value – [in] The property default value
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
U – The type of param
- Returns:
A property
Makes a readonly property that gets a class member. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getter. The property type is effectively preserved inside the getter. The property default is set toT{}
.- Parameters:
param – [in] A class member
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
T – The type of the property
C – The type of the property owner
U – The type of param
- Returns:
A property
Makes a readonly property that gets a class member. It erases the type of the property (
T
) and of the property owner (C
) from the interface, replacing typed by generic getter. The property type is effectively preserved inside the getter. The property default is set toT{}
.- Parameters:
param – [in] A class member
description – [in] The property description
deprecated_names – [in] A list of deprecated alias names for this property.
schema – [in] An optional schema
- Template Parameters:
C – The type of the property owner
U – The type of param and property
- Returns:
A property
A type the holds a dictionary of named properties
name -> property
This class defines set and get methods to access named properties.
Subclassed by navground::core::HasRegister< Behavior >, navground::core::HasRegister< BehaviorModulation >, navground::core::HasRegister< Kinematics >, navground::core::HasRegister< Scenario >, navground::core::HasRegister< StateEstimation >, navground::core::HasRegister< Task >, navground::core::HasRegister< T >
Public Functions
Gets all properties associated with an owner.
All the properties associated with a owner type.
- Returns:
The properties.
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 – [in] The name of the property
value – [in] The desired value for the property
Set the value of a named property, similar to set but casting the value to V.
- Parameters:
name – [in] The name of the property
value – [in] The desired value for the property
- Template Parameters:
V – The type of the desired value
Gets the value of the specified property.
- Parameters:
name – [in] The name of the property
- Throws:
std::runtime_error – A runtime error if no property is found.
- Returns:
The value of the property