Blender V5.3
NOD_geometry_nodes_closure.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2025 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
8
9#pragma once
10
12
16
17#include "BLI_resource_scope.hh"
18
19#include "FN_lazy_function.hh"
20
21namespace blender::nodes {
22
46
56 private:
57 std::shared_ptr<ClosureSignature> signature_;
58 std::optional<ClosureSourceLocation> source_location_;
59 std::shared_ptr<ClosureEvalLog> eval_log_;
66 std::unique_ptr<ResourceScope> scope_;
67 const fn::lazy_function::LazyFunction &function_;
69 Vector<bke::SocketValueVariant> default_input_values_;
71
72 public:
73 Closure(std::shared_ptr<ClosureSignature> signature,
74 std::unique_ptr<ResourceScope> scope,
78 std::optional<ClosureSourceLocation> source_location,
79 std::shared_ptr<ClosureEvalLog> eval_log,
81 : signature_(signature),
82 source_location_(source_location),
83 eval_log_(eval_log),
84 scope_(std::move(scope)),
85 function_(function),
86 indices_(indices),
87 default_input_values_(std::move(default_input_values)),
88 captured_values_(std::move(captured_values))
89 {
90 }
91
93 {
94 return *signature_;
95 }
96
98 {
99 return indices_;
100 }
101
103 {
104 return function_;
105 }
106
107 const std::optional<ClosureSourceLocation> &source_location() const
108 {
109 return source_location_;
110 }
111
112 const std::shared_ptr<ClosureEvalLog> &eval_log_ptr() const
113 {
114 return eval_log_;
115 }
116
118 {
119 return default_input_values_[index];
120 }
121
123 {
124 return default_input_values_;
125 }
126
128 {
129 return captured_values_;
130 }
131
132 void delete_self() override
133 {
134 MEM_delete(this);
135 }
136
137 void log_evaluation(const ClosureEvalLocation &location) const
138 {
139 if (!eval_log_) {
140 return;
141 }
142 std::lock_guard lock{eval_log_->mutex};
143 eval_log_->evaluations.append(location);
144 }
145};
146
147} // namespace blender::nodes
volatile int lock
Span< bke::SocketValueVariant > default_input_values() const
Closure(std::shared_ptr< ClosureSignature > signature, std::unique_ptr< ResourceScope > scope, const fn::lazy_function::LazyFunction &function, ClosureFunctionIndices indices, Vector< bke::SocketValueVariant > default_input_values, std::optional< ClosureSourceLocation > source_location, std::shared_ptr< ClosureEvalLog > eval_log, Vector< const bke::SocketValueVariant * > captured_values)
const std::optional< ClosureSourceLocation > & source_location() const
Span< const bke::SocketValueVariant * > captured_values() const
const std::shared_ptr< ClosureEvalLog > & eval_log_ptr() const
const ClosureSignature & signature() const
void log_evaluation(const ClosureEvalLocation &location) const
const fn::lazy_function::LazyFunction & function() const
const bke::SocketValueVariant & default_input_value(const int index) const
const ClosureFunctionIndices & indices() const
struct blender::nodes::ClosureFunctionIndices::@160307352137314066326363125174013160024306142302 outputs
struct blender::nodes::ClosureFunctionIndices::@322073305126251315255160374026131265320171306337 inputs