Libprimis
Imprimis' 3D destroyable world engine
|
A property. More...
#include <prop.h>
Public Member Functions | |
const PropertyValue & | get_value () const |
int | get_int () const |
Get the integer value of the property. | |
float | get_float () const |
Get the float value of the property. | |
const bvec & | get_color () const |
Get the color value of the property. | |
const ivec & | get_ivec () const |
Get the integer vector value of the property. | |
const vec & | get_fvec () const |
Get the float vector value of the property. | |
const std::string & | get_string () const |
Get the string value of the property. | |
size_t | get_size () const |
Get the size of the property. | |
std::string | get_name () const |
Get the name of the property. | |
PropertyType | get_type () const |
Get the type of the property. | |
std::string | to_string () const |
void | copy (const Property &prop) |
Copy the value of another property, will not invoke callback. | |
void | set (PropertyValue value, std::any on_change_argument=std::any()) |
Set the value of the property. | |
void | set_no_cb (PropertyValue value) |
Set the value of the property without invoking callback. | |
void | reset () |
Reset the value of the property to the default value. | |
void | cmd_result () const |
Results the value of the property. | |
void | cmd_result_min () const |
Results the minimum value of the property. | |
void | cmd_result_def () const |
Results the default value of the property. | |
void | cmd_result_max () const |
Results the maximum value of the property. | |
virtual void | pack (std::vector< uint8_t > &buf) const |
Packs the property into a buffer. | |
virtual size_t | unpack (const uint8_t *buf, size_t len) |
Unpacks the property from a buffer. | |
Property (const PropertyMetaT &_meta) | |
Creates a new property with the given meta class. | |
A property.
PropertyMetaT | - The type of the meta class, defaults to PropertyMeta |
This class is an instance of a property. It stores a value and a reference to its meta class.
prop::Property< PropertyMetaT >::Property | ( | const PropertyMetaT & | _meta | ) |
Creates a new property with the given meta class.
PropertyMetaT | - The type of the meta class. |
_meta | - The meta class. |
void prop::Property< PropertyMetaT >::cmd_result | ( | ) | const |
Results the value of the property.
PropertyMetaT | - The type of the meta class. |
void prop::Property< PropertyMetaT >::cmd_result_def | ( | ) | const |
Results the default value of the property.
PropertyMetaT | - The type of the meta class. |
void prop::Property< PropertyMetaT >::cmd_result_max | ( | ) | const |
Results the maximum value of the property.
PropertyMetaT | - The type of the meta class. |
void prop::Property< PropertyMetaT >::cmd_result_min | ( | ) | const |
Results the minimum value of the property.
PropertyMetaT | - The type of the meta class. |
void prop::Property< PropertyMetaT >::copy | ( | const Property< PropertyMetaT > & | prop | ) |
Copy the value of another property, will not invoke callback.
PropertyMetaT | - The type of the meta class. |
prop | - The property to copy the value from. |
on_change_arg | - Optional argument for on_change callback. |
Note: type check is performed automatically, value of an incompatible type is ignored and reported. Value is clamped to the range defined in the meta class, if applicable.
const bvec & prop::Property< PropertyMetaT >::get_color | ( | ) | const |
Get the color value of the property.
PropertyMetaT | - The type of the meta class. |
Caution: This function does not check the type of the property. A former check is assumed.
float prop::Property< PropertyMetaT >::get_float | ( | ) | const |
Get the float value of the property.
PropertyMetaT | - The type of the meta class. |
Caution: This function does not check the type of the property. A former check is assumed.
const vec & prop::Property< PropertyMetaT >::get_fvec | ( | ) | const |
Get the float vector value of the property.
PropertyMetaT | - The type of the meta class. |
Caution: This function does not check the type of the property. A former check is assumed.
int prop::Property< PropertyMetaT >::get_int | ( | ) | const |
Get the integer value of the property.
PropertyMetaT | - The type of the meta class. |
Caution: This function does not check the type of the property. A former check is assumed.
const ivec & prop::Property< PropertyMetaT >::get_ivec | ( | ) | const |
Get the integer vector value of the property.
PropertyMetaT | - The type of the meta class. |
Caution: This function does not check the type of the property. A former check is assumed.
std::string prop::Property< PropertyMetaT >::get_name | ( | ) | const |
Get the name of the property.
PropertyMetaT | - The type of the meta class. |
Returns the name of the property, as per the definition in the meta class.
size_t prop::Property< PropertyMetaT >::get_size | ( | ) | const |
Get the size of the property.
PropertyMetaT | - The type of the meta class. |
Returns the size of the stored value in bytes.
const std::string & prop::Property< PropertyMetaT >::get_string | ( | ) | const |
Get the string value of the property.
PropertyMetaT | - The type of the meta class. |
Caution: This function does not check the type of the property. A former check is assumed.
PropertyType prop::Property< PropertyMetaT >::get_type | ( | ) | const |
Get the type of the property.
PropertyMetaT | - The type of the meta class. |
Returns the type of the property, as per the definition in the meta class.
|
virtual |
Packs the property into a buffer.
PropertyMetaT | - The type of the meta class. |
buf | - The buffer to pack the property into. |
void prop::Property< PropertyMetaT >::reset | ( | ) |
Reset the value of the property to the default value.
PropertyMetaT | - The type of the meta class. |
void prop::Property< PropertyMetaT >::set | ( | PropertyValue | value, |
std::any | on_change_arg = std::any() ) |
Set the value of the property.
PropertyMetaT | - The type of the meta class. |
value | - The new value of the property. |
on_change_arg | - Optional argument for on_change callback. |
Note: type check is performed automatically, value of an incompatible type is ignored and reported. Value is clamped to the range defined in the meta class, if applicable.
void prop::Property< PropertyMetaT >::set_no_cb | ( | PropertyValue | value | ) |
Set the value of the property without invoking callback.
PropertyMetaT | - The type of the meta class. |
value | - The new value of the property. |
Note: type check is performed automatically, value of an incompatible type is ignored and reported. Value is clamped to the range defined in the meta class, if applicable.
|
virtual |
Unpacks the property from a buffer.
PropertyMetaT | - The type of the meta class. |
buf | - The buffer to unpack the property from. |
buf_size | - The size of the buffer. |