Blender V4.5
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
7#include "BKE_node.hh"
8
12
13#include "BLI_resource_scope.hh"
14
15#include "FN_lazy_function.hh"
16
17namespace blender::nodes {
18
21 public:
22 struct Item {
24 const bke::bNodeSocketType *type = nullptr;
25 };
26
29
30 std::optional<int> find_input_index(const SocketInterfaceKey &key) const;
31 std::optional<int> find_output_index(const SocketInterfaceKey &key) const;
32};
33
57
67 private:
68 std::shared_ptr<ClosureSignature> signature_;
69 std::optional<ClosureSourceLocation> source_location_;
70 std::shared_ptr<ClosureEvalLog> eval_log_;
77 std::unique_ptr<ResourceScope> scope_;
78 const fn::lazy_function::LazyFunction &function_;
80 Vector<const void *> default_input_values_;
81
82 public:
83 Closure(std::shared_ptr<ClosureSignature> signature,
84 std::unique_ptr<ResourceScope> scope,
87 Vector<const void *> default_input_values,
88 std::optional<ClosureSourceLocation> source_location,
89 std::shared_ptr<ClosureEvalLog> eval_log)
90 : signature_(signature),
91 source_location_(source_location),
92 eval_log_(eval_log),
93 scope_(std::move(scope)),
94 function_(function),
95 indices_(indices),
96 default_input_values_(std::move(default_input_values))
97 {
98 }
99
101 {
102 return *signature_;
103 }
104
106 {
107 return indices_;
108 }
109
111 {
112 return function_;
113 }
114
115 const std::optional<ClosureSourceLocation> &source_location() const
116 {
117 return source_location_;
118 }
119
120 const std::shared_ptr<ClosureEvalLog> &eval_log_ptr() const
121 {
122 return eval_log_;
123 }
124
125 const void *default_input_value(const int index) const
126 {
127 return default_input_values_[index];
128 }
129
130 void delete_self() override
131 {
132 MEM_delete(this);
133 }
134
135 void log_evaluation(const ClosureEvalLocation &location) const
136 {
137 if (!eval_log_) {
138 return;
139 }
140 std::lock_guard lock{eval_log_->mutex};
141 eval_log_->evaluations.append(location);
142 }
143};
144
145} // namespace blender::nodes
volatile int lock
std::optional< int > find_input_index(const SocketInterfaceKey &key) const
std::optional< int > find_output_index(const SocketInterfaceKey &key) const
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< const void * > default_input_values, std::optional< ClosureSourceLocation > source_location, std::shared_ptr< ClosureEvalLog > eval_log)
const ClosureFunctionIndices & indices() const
const void * default_input_value(const int index) const
#define main()
static blender::bke::bNodeSocketTemplate outputs[]
static blender::bke::bNodeSocketTemplate inputs[]
Defines a socket type.
Definition BKE_node.hh:152