Blender V5.3
blender::bke::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 is expected to always have a valid CPPType. Therefore, it can't be default constructed.

Referenced by blender::bke::detail::SocketValueVariantTypeInfo::try_convert_fn().

◆ 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.

◆ 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.

◆ 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.

◆ 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.

◆ GField() [7/7]

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

Definition at line 335 of file field.cc.

◆ ~GField()

Definition at line 361 of file field.cc.

Member Function Documentation

◆ cpp_type()

const CPPType & blender::fn::GField::cpp_type ( ) const
inline

The value type the field outputs for each element, e.g. float.

Definition at line 518 of file FN_field.hh.

◆ depends_on_input()

Returns true when the field depends on some input.

Definition at line 614 of file FN_field.hh.

◆ 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.

◆ field_inputs()

Root FieldInput nodes that this field depends on.

Definition at line 504 of file field.cc.

◆ from_constant()

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

Construct a field that just outputs the given constant value.

Definition at line 24 of file field.cc.

Referenced by blender::bke::detail::SocketValueVariantTypeInfo::try_convert_fn().

◆ from_input()

template<typename InputT, typename... Args>
GField blender::fn::GField::from_input ( Args &&... args)
inlinestatic

Build a new FieldInput with the given arguments.

Definition at line 482 of file FN_field.hh.

◆ 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.

◆ from_non_owning_ref()

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.

◆ get_if_constant()

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

Definition at line 632 of file FN_field.hh.

◆ 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.

◆ hash()

Definition at line 87 of file field.cc.

◆ operator=() [1/2]

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

Definition at line 341 of file field.cc.

◆ operator=() [2/2]

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

Definition at line 351 of file field.cc.

◆ 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.

◆ typed() [1/2]

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

Definition at line 591 of file FN_field.hh.

◆ 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.

◆ variant()

Get the underlying Variant.

Definition at line 598 of file FN_field.hh.

◆ 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.

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.


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