Blender V5.3
blender::fn::GField Class Reference

#include <FN_field.hh>

Classes

struct  Input
struct  MultiFn
struct  FieldRef
struct  ConstantRef
struct  TrivialInlineConstant
struct  OwnedConstant

Public Types

using Variant

Public Member Functions

 GField ()=delete
 GField (const GField &other)
 GField (GField &&other) noexcept
GField & operator= (const GField &other)
GField & operator= (GField &&other) noexcept
 ~GField ()
const FieldInputsPtr & field_inputs () const
uint64_t hash () const
FieldOperationPtr try_extract_operation ()

Static Public Member Functions

static GField from_constant (const CPPType &type, const void *value)

Static Public Attributes

template<typename T>
static constexpr bool is_constant_value_v

Friends

bool operator== (const GField &a, const GField &b)

Inline Methods

 GField (const CPPType &type) noexcept
 GField (FieldInputPtr node) noexcept
 GField (FieldOperationPtr node, int output_i=0) noexcept
 GField (Variant variant) noexcept
const CPPType & cpp_type () const
const GField & deref_field_ref () const
const Variant & variant () const
bool depends_on_input () const
template<typename InputT>
const InputT * get_input_if () const
const void * get_if_constant () const
template<typename T>
const Field< T > & typed () const
template<typename T>
Field< T > & typed ()
static GField from_non_owning_ref (const GField &field)
static GField from_non_owning_constant (const CPPType &type, const void *value)
template<typename InputT, typename... Args>
static GField from_input (Args &&...args)

Detailed Description

A field with a type that is only known at runtime which can be accessed through the cpp_type method. If the type is known at compile time, it is recommended to use Field<T> instead.

It is designed to support various internal storage representations to avoid unnecessary allocations or reference counting in many common cases.

Definition at line 55 of file FN_field.hh.

Member Typedef Documentation

◆ Variant

Initial value:
std::variant<Input, MultiFn, FieldRef, ConstantRef, TrivialInlineConstant, OwnedConstant>

Definition at line 110 of file FN_field.hh.

Constructor & Destructor Documentation

◆ GField() [1/7]

◆ GField() [2/7]

blender::fn::GField::GField ( const CPPType & type)
inlineexplicitnoexcept

Construct a field that just outputs the default value of the given type.

Definition at line 450 of file FN_field.hh.

◆ GField() [3/7]

blender::fn::GField::GField ( FieldInputPtr node)
inlineexplicitnoexcept

Construct a field owning a field input.

Definition at line 454 of file FN_field.hh.

References node.

◆ GField() [4/7]

blender::fn::GField::GField ( FieldOperationPtr node,
int output_i = 0 )
inlineexplicitnoexcept

Construct a field that owns a field operation and outputs one of its outputs.

Definition at line 456 of file FN_field.hh.

References node.

◆ GField() [5/7]

blender::fn::GField::GField ( Variant variant)
inlineexplicitnoexcept

Construct directly from a Variant, mostly for internal use.

Definition at line 455 of file FN_field.hh.

References variant().

◆ GField() [6/7]

blender::fn::GField::GField ( const GField & other)

GField requires manual memory management due to inlined values and to support move semantics without making GField nullable.

Definition at line 321 of file field.cc.

References GField(), blender::MEM_new_uninitialized_aligned(), T, and blender::v.

◆ GField() [7/7]

blender::fn::GField::GField ( GField && other)
noexcept

Definition at line 335 of file field.cc.

References cpp_type(), blender::CPPType::default_value(), and GField().

◆ ~GField()

blender::fn::GField::~GField ( )

Definition at line 361 of file field.cc.

References blender::MEM_delete_void(), T, and blender::v.

Member Function Documentation

◆ cpp_type()

◆ depends_on_input()

bool blender::fn::GField::depends_on_input ( ) const
inline

◆ deref_field_ref()

const GField & blender::fn::GField::deref_field_ref ( ) const
inline

This "normalizes" the field. Specifically, if this field is just a non-owning reference to some other field, the referenced field is returned.

Definition at line 541 of file FN_field.hh.

References GField().

Referenced by get_input_if(), GField(), hash(), and operator==.

◆ field_inputs()

◆ from_constant()

◆ from_input()

◆ from_non_owning_constant()

GField blender::fn::GField::from_non_owning_constant ( const CPPType & type,
const void * value )
inlinestatic

Construct a field that just outputs the given constant value without owning it.

Definition at line 472 of file FN_field.hh.

References GField().

Referenced by blender::nodes::node_geo_tool_selection_cc::get_selection_field(), and GField().

◆ from_non_owning_ref()

GField blender::fn::GField::from_non_owning_ref ( const GField & field)
inlinestatic

Wraps the given field in a new field. This is used to avoid reference counting for some field fields which have static lifetime.

Definition at line 461 of file FN_field.hh.

References GField().

Referenced by blender::fn::Field< T >::from_non_owning_ref(), and GField().

◆ get_if_constant()

const void * blender::fn::GField::get_if_constant ( ) const
inline

◆ get_input_if()

template<typename InputT>
const InputT * blender::fn::GField::get_input_if ( ) const
inline

Utility to access a specific input type if this field is just an input.

Definition at line 623 of file FN_field.hh.

References deref_field_ref(), GField(), and variant().

Referenced by GField(), blender::bke::bake::serialize_field(), and blender::bke::try_get_field_direct_attribute_id().

◆ hash()

uint64_t blender::fn::GField::hash ( ) const

◆ operator=() [1/2]

GField & blender::fn::GField::operator= ( const GField & other)

Definition at line 341 of file field.cc.

References GField().

◆ operator=() [2/2]

GField & blender::fn::GField::operator= ( GField && other)
noexcept

Definition at line 351 of file field.cc.

References GField().

◆ try_extract_operation()

FieldOperationPtr blender::fn::GField::try_extract_operation ( )

Attempts to take ownership of a FieldOperation stored in this field, leaving the field input. It's expected to be deleted shortly after. This is necessary to avoid deep recursion when destructing a field tree.

Definition at line 202 of file field.cc.

References blender::fn::GField::MultiFn::node.

Referenced by GField().

◆ typed() [1/2]

template<typename T>
Field< T > & blender::fn::GField::typed ( )
inline

Definition at line 591 of file FN_field.hh.

References blender::BLI_assert(), cpp_type(), and GField().

◆ typed() [2/2]

template<typename T>
const Field< T > & blender::fn::GField::typed ( ) const
inline

Get a typed reference to this field. Note that Field<T> happens to be identical to GField on a bit-level. So this is just a cast.

Definition at line 584 of file FN_field.hh.

References blender::BLI_assert(), cpp_type(), and GField().

Referenced by blender::bke::AttributeExistsFieldInput::from(), blender::fn::Field< int >::from_input(), blender::fn::Field< T >::from_non_owning_ref(), and GField().

◆ variant()

const GField::Variant & blender::fn::GField::variant ( ) const
inline

Get the underlying Variant.

Definition at line 598 of file FN_field.hh.

Referenced by get_input_if(), GField(), and GField().

◆ operator==

bool operator== ( const GField & a,
const GField & b )
friend

This only implements shallow comparison. A more deep comparison could reveal that two fields are semantically the same even if this comparison is false. Deep comparison is much more expensive though.

Definition at line 37 of file field.cc.

References b, BLI_assert_unreachable, BLI_assert_unreachable_static_t, deref_field_ref(), GField(), is_constant_value_v, blender::CPPType::is_equal_or_false(), operator==, T, and blender::U.

Referenced by operator==.

Member Data Documentation

◆ is_constant_value_v

template<typename T>
bool blender::fn::GField::is_constant_value_v
staticconstexpr
Initial value:

Definition at line 107 of file FN_field.hh.

Referenced by hash(), and operator==.


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