Blender V5.0
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
5#pragma once
6
8
12
13#include "BLI_resource_scope.hh"
14
15#include "FN_lazy_function.hh"
16
17namespace blender::nodes {
18
42
52 private:
53 std::shared_ptr<ClosureSignature> signature_;
54 std::optional<ClosureSourceLocation> source_location_;
55 std::shared_ptr<ClosureEvalLog> eval_log_;
62 std::unique_ptr<ResourceScope> scope_;
63 const fn::lazy_function::LazyFunction &function_;
65 Vector<bke::SocketValueVariant> default_input_values_;
66
67 public:
68 Closure(std::shared_ptr<ClosureSignature> signature,
69 std::unique_ptr<ResourceScope> scope,
72 Vector<bke::SocketValueVariant> default_input_values,
73 std::optional<ClosureSourceLocation> source_location,
74 std::shared_ptr<ClosureEvalLog> eval_log)
75 : signature_(signature),
76 source_location_(source_location),
77 eval_log_(eval_log),
78 scope_(std::move(scope)),
79 function_(function),
80 indices_(indices),
81 default_input_values_(std::move(default_input_values))
82 {
83 }
84
86 {
87 return *signature_;
88 }
89
91 {
92 return indices_;
93 }
94
96 {
97 return function_;
98 }
99
100 const std::optional<ClosureSourceLocation> &source_location() const
101 {
102 return source_location_;
103 }
104
105 const std::shared_ptr<ClosureEvalLog> &eval_log_ptr() const
106 {
107 return eval_log_;
108 }
109
110 const bke::SocketValueVariant &default_input_value(const int index) const
111 {
112 return default_input_values_[index];
113 }
114
115 void delete_self() override
116 {
117 MEM_delete(this);
118 }
119
120 void log_evaluation(const ClosureEvalLocation &location) const
121 {
122 if (!eval_log_) {
123 return;
124 }
125 std::lock_guard lock{eval_log_->mutex};
126 eval_log_->evaluations.append(location);
127 }
128};
129
130} // namespace blender::nodes
volatile int lock
const std::optional< ClosureSourceLocation > & source_location() 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
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)
const bke::SocketValueVariant & default_input_value(const int index) const
const ClosureFunctionIndices & indices() const
#define main()
static blender::bke::bNodeSocketTemplate outputs[]
static blender::bke::bNodeSocketTemplate inputs[]