Libprimis
Imprimis' 3D destroyable world engine
Loading...
Searching...
No Matches
prop::Property< PropertyMetaT > Class Template Reference

A property. More...

#include <prop.h>

Public Member Functions

const PropertyValueget_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 bvecget_color () const
 Get the color value of the property.
 
const ivecget_ivec () const
 Get the integer vector value of the property.
 
const vecget_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.
 

Detailed Description

template<typename PropertyMetaT = PropertyMeta>
class prop::Property< PropertyMetaT >

A property.

Template Parameters
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.

Constructor & Destructor Documentation

◆ Property()

template<typename PropertyMetaT >
prop::Property< PropertyMetaT >::Property ( const PropertyMetaT & _meta)

Creates a new property with the given meta class.

Template Parameters
PropertyMetaT- The type of the meta class.
Parameters
_meta- The meta class.

Member Function Documentation

◆ cmd_result()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::cmd_result ( ) const

Results the value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.

◆ cmd_result_def()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::cmd_result_def ( ) const

Results the default value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.

◆ cmd_result_max()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::cmd_result_max ( ) const

Results the maximum value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.

◆ cmd_result_min()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::cmd_result_min ( ) const

Results the minimum value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.

◆ copy()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::copy ( const Property< PropertyMetaT > & prop)

Copy the value of another property, will not invoke callback.

Template Parameters
PropertyMetaT- The type of the meta class.
Parameters
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.

◆ get_color()

template<typename PropertyMetaT >
const bvec & prop::Property< PropertyMetaT >::get_color ( ) const

Get the color value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
bvec

Caution: This function does not check the type of the property. A former check is assumed.

◆ get_float()

template<typename PropertyMetaT >
float prop::Property< PropertyMetaT >::get_float ( ) const

Get the float value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
float

Caution: This function does not check the type of the property. A former check is assumed.

◆ get_fvec()

template<typename PropertyMetaT >
const vec & prop::Property< PropertyMetaT >::get_fvec ( ) const

Get the float vector value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
vec

Caution: This function does not check the type of the property. A former check is assumed.

◆ get_int()

template<typename PropertyMetaT >
int prop::Property< PropertyMetaT >::get_int ( ) const

Get the integer value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
int

Caution: This function does not check the type of the property. A former check is assumed.

◆ get_ivec()

template<typename PropertyMetaT >
const ivec & prop::Property< PropertyMetaT >::get_ivec ( ) const

Get the integer vector value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
ivec

Caution: This function does not check the type of the property. A former check is assumed.

◆ get_name()

template<typename PropertyMetaT >
std::string prop::Property< PropertyMetaT >::get_name ( ) const

Get the name of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
std::string

Returns the name of the property, as per the definition in the meta class.

◆ get_size()

template<typename PropertyMetaT >
size_t prop::Property< PropertyMetaT >::get_size ( ) const

Get the size of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
size_t

Returns the size of the stored value in bytes.

◆ get_string()

template<typename PropertyMetaT >
const std::string & prop::Property< PropertyMetaT >::get_string ( ) const

Get the string value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
std::string

Caution: This function does not check the type of the property. A former check is assumed.

◆ get_type()

template<typename PropertyMetaT >
PropertyType prop::Property< PropertyMetaT >::get_type ( ) const

Get the type of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Returns
std::string

Returns the type of the property, as per the definition in the meta class.

◆ pack()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::pack ( std::vector< uint8_t > & buf) const
virtual

Packs the property into a buffer.

Template Parameters
PropertyMetaT- The type of the meta class.
Parameters
buf- The buffer to pack the property into.

◆ reset()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::reset ( )

Reset the value of the property to the default value.

Template Parameters
PropertyMetaT- The type of the meta class.

◆ set()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::set ( PropertyValue value,
std::any on_change_arg = std::any() )

Set the value of the property.

Template Parameters
PropertyMetaT- The type of the meta class.
Parameters
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.

◆ set_no_cb()

template<typename PropertyMetaT >
void prop::Property< PropertyMetaT >::set_no_cb ( PropertyValue value)

Set the value of the property without invoking callback.

Template Parameters
PropertyMetaT- The type of the meta class.
Parameters
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.

◆ unpack()

template<typename PropertyMetaT >
size_t prop::Property< PropertyMetaT >::unpack ( const uint8_t * buf,
size_t buf_size )
virtual

Unpacks the property from a buffer.

Template Parameters
PropertyMetaT- The type of the meta class.
Parameters
buf- The buffer to unpack the property from.
buf_size- The size of the buffer.
Returns
The number of bytes read from the buffer.

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