|
Blender V5.3
|
#include <BKE_node_socket_value.hh>
Public Member Functions | |
| SocketValueVariant ()=default | |
| template<typename T> requires (std::is_trivial_v<std::decay_t<T>> || is_same_any_v<std::decay_t<T>, std::string>) | |
| SocketValueVariant (T &&value) | |
| template<typename T, typename... Args> | |
| T & | emplace (Args &&...args) |
| template<typename T> | |
| T * | try_convert () |
| void * | try_convert (const CPPType &type) |
| template<typename T> | |
| T & | ensure_type () |
| void * | ensure_type (const CPPType &type) |
| template<typename T> | |
| T | copy_as () const |
| template<typename T> | |
| T | extract () |
| template<typename T> | |
| const T * | get_if () const |
| template<typename T> | |
| T * | get_if () |
| const void * | get_if (const CPPType &type) const |
| void * | get_if (const CPPType &type) |
| GPointer | get () const |
| GMutablePointer | get () |
| bool | is_context_dependent_field () const |
| bool | is_field () const |
| bool | is_volume_grid () const |
| bool | is_single () const |
| bool | is_list () const |
| void | ensure_owns_direct_data () |
| bool | owns_direct_data () const |
| void * | allocate_single (const CPPType &type) |
| void | count_memory (MemoryCounter &memory) const |
Static Public Member Functions | |
| template<typename T> | |
| static SocketValueVariant & | construct_in (void *ptr, T &&value) |
| template<typename T> | |
| static SocketValueVariant | from (T &&value) |
| template<typename T> | |
| static T & | init_default (detail::SocketValueVariantAny &value) |
| static void * | init_default (const CPPType &type, detail::SocketValueVariantAny &value) |
| static void * | allocate (const CPPType &type, detail::SocketValueVariantAny &value) |
SocketValueVariant is used to pass data between nodes, e.g. by geometry nodes in the lazy function evaluator. Specifically, it is the container type for the following socket types: bool, float, integer, vector, rotation, color and string.
The data passed through e.g. an integer socket can be a single value, a field or a grid (and in the lists and images). Each of those is stored differently, but this container can store them all.
A key requirement for this container is that it is type-erased, i.e. not all code that uses it has to include all the headers required to process the other storage types. This is achieved by using the Any type and by providing templated accessors that are implemented outside of a header.
This container is also able to do implicit conversions between the different types, with the ensure_type() methods.
Definition at line 83 of file BKE_node_socket_value.hh.
Create an empty variant. This is not valid for any socket type yet.
Referenced by blender::make_socket_type_bool(), blender::make_socket_type_float(), blender::make_socket_type_int(), blender::make_socket_type_matrix(), blender::make_socket_type_rgba(), blender::make_socket_type_rotation(), blender::make_socket_type_string(), and blender::make_socket_type_vector().
|
inlineexplicit |
Create a variant based on the given value. This works for primitive types. For more complex types, one can use the from or construct_in utilities.
Definition at line 206 of file BKE_node_socket_value.hh.
|
static |
Definition at line 476 of file node_socket_value.cc.
| void * blender::bke::SocketValueVariant::allocate_single | ( | const CPPType & | type | ) |
Replaces the stored value with a new uninitialized single value for the given socket type. The caller is responsible to construct the value in the returned memory before it is used.
Definition at line 500 of file node_socket_value.cc.
|
inlinestatic |
Construct a SocketValueVariant at the given pointer from the given value.
Definition at line 213 of file BKE_node_socket_value.hh.
| T blender::bke::SocketValueVariant::copy_as | ( | ) | const |
Equivalent to calling extract<T>() on a copy of this value.
Definition at line 287 of file BKE_node_socket_value.hh.
| void blender::bke::SocketValueVariant::count_memory | ( | MemoryCounter & | memory | ) | const |
Definition at line 591 of file node_socket_value.cc.
|
inline |
Replace the stored value by constructing the given type in the storage.
Definition at line 227 of file BKE_node_socket_value.hh.
Also see GeomtrySet::ensure_owns_direct_data.
Definition at line 547 of file node_socket_value.cc.
|
inline |
Try to convert the stored value to the given type, creating the type's default value if the conversion does not exist.
Definition at line 271 of file BKE_node_socket_value.hh.
|
inline |
Definition at line 279 of file BKE_node_socket_value.hh.
|
inline |
Get the stored value as a specific type. For convenience this allows accessing the stored type as a different type, using implicit conversions as possible.
This method may leave the variant empty, in a moved from state or unchanged. Therefore, this should only be called once.
Definition at line 368 of file BKE_node_socket_value.hh.
|
inlinestatic |
Create a new SocketValueVariant from the given value.
Definition at line 220 of file BKE_node_socket_value.hh.
Referenced by blender::make_socket_type_bundle(), blender::make_socket_type_closure(), blender::make_socket_type_collection(), blender::make_socket_type_font(), blender::make_socket_type_geometry(), blender::make_socket_type_image(), blender::make_socket_type_mask(), blender::make_socket_type_material(), blender::make_socket_type_menu(), blender::make_socket_type_object(), blender::make_socket_type_scene(), blender::make_socket_type_sound(), blender::make_socket_type_text(), and blender::make_socket_type_texture().
Definition at line 349 of file BKE_node_socket_value.hh.
|
inline |
Get the stored value as a GPointer.
Definition at line 340 of file BKE_node_socket_value.hh.
|
inline |
Definition at line 315 of file BKE_node_socket_value.hh.
|
inline |
Return a pointer to the stored value if it is of the given type. Otherwise return null.
Definition at line 293 of file BKE_node_socket_value.hh.
|
inline |
Definition at line 335 of file BKE_node_socket_value.hh.
|
inline |
Definition at line 320 of file BKE_node_socket_value.hh.
|
static |
Definition at line 431 of file node_socket_value.cc.
|
inlinestatic |
Definition at line 373 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_context_dependent_field | ( | ) | const |
If true, the stored value cannot be converted to a single value without loss of information.
Definition at line 538 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_field | ( | ) | const |
If true, the value is stored as a GField.
Definition at line 520 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_list | ( | ) | const |
The stored value is a list.
Definition at line 525 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_single | ( | ) | const |
The stored value is a single value.
Definition at line 505 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::is_volume_grid | ( | ) | const |
The stored value is a volume grid.
Definition at line 529 of file node_socket_value.cc.
| bool blender::bke::SocketValueVariant::owns_direct_data | ( | ) | const |
Definition at line 572 of file node_socket_value.cc.
| T * blender::bke::SocketValueVariant::try_convert | ( | ) |
Try to convert the stored value to the given type, returning null if the implicit conversion does not exist.
Definition at line 235 of file BKE_node_socket_value.hh.
|
inline |
Definition at line 256 of file BKE_node_socket_value.hh.