Blender V5.3
blender::fn::lazy_function::LazyFunction Class Referenceabstract

#include <FN_lazy_function.hh>

Inherited by blender::fn::lazy_function::GraphExecutor, blender::fn::lazy_function::tests::AddLazyFunction, blender::fn::lazy_function::tests::PartialEvaluationTestFunction, blender::fn::lazy_function::tests::StoreValueFunction, blender::nodes::LazyFunctionForEnableOutputSocketUsage, blender::nodes::LazyFunctionForExtractingReferenceSet, blender::nodes::LazyFunctionForIndexSwitchSocketUsage, blender::nodes::LazyFunctionForJoinReferenceSets, blender::nodes::LazyFunctionForLogicalOr, blender::nodes::LazyFunctionForSwitchSocketUsage, and blender::nodes::node_geo_menu_switch_cc::LazyFunctionForMenuSwitchSocketUsage.

Public Member Functions

virtual ~LazyFunction ()=default
virtual std::string name () const
virtual std::string input_name (int index) const
virtual std::string output_name (int index) const
virtual void * init_storage (LinearAllocator<> &allocator) const
virtual void destruct_storage (void *storage) const
virtual void possible_output_dependencies (int output_index, FunctionRef< void(Span< int >)> fn) const
bool always_used_inputs_available (const Params &params) const
bool allow_missing_requested_inputs () const
#LazyFunction Inline Methods
Span< Input > inputs () const
Span< Output > outputs () const
void execute (Params &params, const Context &context) const

Protected Attributes

const char * debug_name_ = "unknown"
Vector< Input > inputs_
Vector< Output > outputs_
bool allow_missing_requested_inputs_ = false

Detailed Description

A function that can compute outputs and request inputs lazily. For more details see the comment at the top of the file.

Definition at line 247 of file FN_lazy_function.hh.

Constructor & Destructor Documentation

◆ ~LazyFunction()

virtual blender::fn::lazy_function::LazyFunction::~LazyFunction ( )
virtualdefault

Member Function Documentation

◆ allow_missing_requested_inputs()

bool blender::fn::lazy_function::LazyFunction::allow_missing_requested_inputs ( ) const
inline

If true, the function can be executed even when some requested inputs are not available yet. This allows the function to make some progress and maybe to compute some outputs that are passed into this function again (lazy-function graphs may contain cycles as long as there aren't actually data dependencies).

Definition at line 314 of file FN_lazy_function.hh.

References allow_missing_requested_inputs_.

◆ always_used_inputs_available()

bool LazyFunction::always_used_inputs_available ( const Params & params) const

Utility to check that the guarantee by #Input::usage is followed.

Definition at line 50 of file lazy_function.cc.

References allow_missing_requested_inputs_, inputs_, blender::fn::lazy_function::Params::try_get_input_data_ptr(), blender::fn::lazy_function::Input::usage, and blender::fn::lazy_function::Used.

Referenced by execute(), and ~LazyFunction().

◆ destruct_storage()

void LazyFunction::destruct_storage ( void * storage) const
virtual

Destruct the storage created in init_storage.

Reimplemented in blender::fn::lazy_function::GraphExecutor.

Definition at line 33 of file lazy_function.cc.

References blender::BLI_assert(), storage, and UNUSED_VARS_NDEBUG.

Referenced by ~LazyFunction().

◆ execute()

void LazyFunction::execute ( Params & params,
const Context & context ) const
inline

During execution the function retrieves inputs and sets outputs in #params. For some functions, this method is called more than once. After execution, the function either has computed all required outputs or is waiting for more inputs.

Definition at line 341 of file FN_lazy_function.hh.

References always_used_inputs_available(), blender::BLI_assert(), debug_name_, blender::Default, PRF_scope_set_dynamic_name, and PRF_scope_with_name.

Referenced by ~LazyFunction().

◆ init_storage()

void * LazyFunction::init_storage ( LinearAllocator<> & allocator) const
virtual

Allocates storage for this function. The storage will be passed to every call to execute. If the function does not keep track of any state, this does not have to be implemented.

Reimplemented in blender::fn::lazy_function::GraphExecutor.

Definition at line 28 of file lazy_function.cc.

Referenced by ~LazyFunction().

◆ input_name()

std::string LazyFunction::input_name ( int index) const
virtual

Reimplemented in blender::fn::lazy_function::GraphExecutor.

Definition at line 18 of file lazy_function.cc.

References inputs_.

Referenced by ~LazyFunction().

◆ inputs()

◆ name()

std::string LazyFunction::name ( ) const
virtual

Get a name of the function or an input or output. This is mainly used for debugging. These are virtual functions because the names are often not used outside of debugging workflows. This way the names are only generated when they are actually needed.

Definition at line 13 of file lazy_function.cc.

References debug_name_.

Referenced by blender::nodes::LazyFunctionForJoinReferenceSets::execute_impl(), blender::nodes::LazyFunctionForExtractingReferenceSet::gather_references_from_field(), blender::fn::lazy_function::Node::name(), and ~LazyFunction().

◆ output_name()

std::string LazyFunction::output_name ( int index) const
virtual

Reimplemented in blender::fn::lazy_function::GraphExecutor.

Definition at line 23 of file lazy_function.cc.

References outputs_.

Referenced by ~LazyFunction().

◆ outputs()

◆ possible_output_dependencies()

void LazyFunction::possible_output_dependencies ( int output_index,
FunctionRef< void(Span< int >)> fn ) const
virtual

Calls fn with the input indices that the given output_index may depend on. By default every output depends on every input.

Reimplemented in blender::fn::lazy_function::tests::PartialEvaluationTestFunction.

Definition at line 39 of file lazy_function.cc.

References inputs_.

Referenced by ~LazyFunction().

Member Data Documentation

◆ allow_missing_requested_inputs_

bool blender::fn::lazy_function::LazyFunction::allow_missing_requested_inputs_ = false
protected

◆ debug_name_

◆ inputs_

◆ outputs_


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