|
Libprimis
Imprimis' 3D destroyable world engine
|
Type-agnotic property system. More...
Go to the source code of this file.
Classes | |
| class | prop::PropertyMeta |
| Meta information about a property. More... | |
| class | prop::Property< PropertyMetaT > |
| A property. More... | |
Typedefs | |
| typedef std::variant< int, float, bvec, ivec, vec, std::string > | prop::PropertyValue |
| Storage for a property value. | |
| typedef std::function< void(std::any argument)> | prop::OnChangeCallback |
| Callback type for property changes. | |
Enumerations | |
| enum class | prop::PropertyType { NoType = -1 , Int , Float , Color , IntVec , FloatVec , String , Count } |
| Type of a property. More... | |
Functions | |
| template<typename PropertyT, std::size_t N> | |
| PropertyT * | prop::find_prop (std::string name, std::array< PropertyT, N > &props) |
| Finds a property with the given name in the given array. | |
| template<typename PropertyT, std::size_t N> | |
| const PropertyT * | prop::find_prop (std::string name, const std::array< PropertyT, N > &props) |
| Finds a property with the given name in the given array. | |
| template<typename PropertyT, std::size_t N> | |
| bool | prop::set_prop (std::string name, PropertyValue value, std::array< PropertyT, N > &props, std::any on_change_arg=std::any()) |
| Sets the value of a property with the given name in the given array. | |
| template<typename PropertyMetaT, std::size_t N> | |
| const PropertyMetaT * | prop::find_prop_meta (std::string name, const std::array< PropertyMetaT, N > &prop_metas) |
| Finds a property definition with the given name in the given array. | |
| template<typename PropertyT, std::size_t N> | |
| void | prop::pack_props (const std::array< PropertyT, N > &props, std::vector< uint8_t > &buf) |
| Packs the given properties into the given buffer. | |
| template<typename PropertyT, std::size_t N> | |
| size_t | prop::unpack_props (const std::vector< uint8_t > &buf, std::array< PropertyT, N > &props) |
| Unpacks the given buffer into the given properties. | |
| template<std::size_t N, typename PropertyT, std::size_t... Is, typename PropertyMetaT> | |
| std::array< PropertyT, N > | prop::_make_props_array_impl (std::index_sequence< Is... >, const PropertyMetaT(&prop_meta)[N]) |
| template<std::size_t N, typename PropertyT, std::size_t... Is, typename PropertyMetaT> | |
| std::array< PropertyT, N > | prop::make_props_array (const PropertyMetaT(&prop_meta)[N]) |
| Creates an array of properties from the given property definitions. | |
Type-agnotic property system.
This file provides a type-agnostic property system. It is used to provide a generic interface for convenient property access for objects, entities and entire systems.
| typedef std::function<void(std::any argument)> prop::OnChangeCallback |
Callback type for property changes.
| argument | - The argument passed to the callback. |
| typedef std::variant<int, float, bvec, ivec, vec, std::string> prop::PropertyValue |
Storage for a property value.
This type is used to store a property value. Supported types are: int, float, bvec, ivec, vec, std::string
|
strong |
Type of a property.
This enum is used to determine the type of a property. Mandates what sort of type is stored inside the PropertyValue.
| const PropertyT * prop::find_prop | ( | std::string | name, |
| const std::array< PropertyT, N > & | props ) |
Finds a property with the given name in the given array.
| PropertyT | - Property class type |
| N | - Size of the array |
| name | - The name of the property to find. |
| props | - The array of properties to search. |
| PropertyT * prop::find_prop | ( | std::string | name, |
| std::array< PropertyT, N > & | props ) |
Finds a property with the given name in the given array.
| PropertyT | - Property class type |
| N | - Size of the array |
| name | - The name of the property to find. |
| props | - The array of properties to search. |
| const PropertyMetaT * prop::find_prop_meta | ( | std::string | name, |
| const std::array< PropertyMetaT, N > & | prop_metas ) |
Finds a property definition with the given name in the given array.
| PropertyMetaT | - PropertyMeta class type |
| N | - Size of the array |
| name | - The name of the property definition to find. |
| prop_metas | - The array of property definitions to search. |
| std::array< PropertyT, N > prop::make_props_array | ( | const PropertyMetaT(&) | prop_meta[N] | ) |
Creates an array of properties from the given property definitions.
| N | - Size of the array |
| PropertyT | - Property class type |
| Is | - Index sequence |
| PropertyMetaT | - PropertyMeta class type |
| prop_meta | - The array of property definitions to create properties from. |
| void prop::pack_props | ( | const std::array< PropertyT, N > & | props, |
| std::vector< uint8_t > & | buf ) |
Packs the given properties into the given buffer.
| PropertyT | - Property class type |
| N | - Size of the array |
| props | - The array of properties to pack. |
| buf | - The buffer to pack the properties into. |
| bool prop::set_prop | ( | std::string | name, |
| PropertyValue | value, | ||
| std::array< PropertyT, N > & | props, | ||
| std::any | on_change_arg = std::any() ) |
Sets the value of a property with the given name in the given array.
| PropertyT | - Property class type |
| N | - Size of the array |
| name | - The name of the property to set. |
| value | - The value to set the property to. Value is clamped to the property's min/max values, if applicable. |
| props | - The array of properties to search. |
| on_change_arg | - Optional argument to pass to the property's on_change callback. |
| size_t prop::unpack_props | ( | const std::vector< uint8_t > & | buf, |
| std::array< PropertyT, N > & | props ) |
Unpacks the given buffer into the given properties.
| PropertyT | - Property class type |
| N | - Size of the array |
| buf | - The buffer to unpack. |
| props | - The array of properties to unpack into. |