Blender V5.0
NOD_node_in_compute_context.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
8#include "BLI_hash.hh"
10
11#include "BKE_node_runtime.hh"
12
13struct bNode;
14struct bNodeSocket;
15
16namespace blender::nodes {
17
18struct NodeInContext;
19struct SocketInContext;
20
26 const ComputeContext *context = nullptr;
27 const bNode *node = nullptr;
28
29 uint64_t hash() const;
31 const bNode *operator->() const;
32 const bNode &operator*() const;
33 operator bool() const;
34
35 SocketInContext input_socket(int index) const;
36 SocketInContext output_socket(int index) const;
37
43};
44
50 const ComputeContext *context = nullptr;
51 const bNodeSocket *socket = nullptr;
52
53 uint64_t hash() const;
55 const bNodeSocket *operator->() const;
56 const bNodeSocket &operator*() const;
57 operator bool() const;
58
60
66};
67
72 const ComputeContext *context = nullptr;
73 const bNodeTree *tree = nullptr;
74
75 uint64_t hash() const;
77 const bNodeTree *operator->() const;
78 const bNodeTree &operator*() const;
79 operator bool() const;
80};
81
82/* -------------------------------------------------------------------- */
85
87{
88 return get_default_hash(this->context_hash(), this->node);
89}
90
95
96inline const bNode *NodeInContext::operator->() const
97{
98 return this->node;
99}
100
101inline const bNode &NodeInContext::operator*() const
102{
103 return *this->node;
104}
105
106inline NodeInContext::operator bool() const
107{
108 return this->node != nullptr;
109}
110
111inline SocketInContext NodeInContext::input_socket(const int index) const
112{
113 return {this->context, &this->node->input_socket(index)};
114}
115
117{
118 return {this->context, &this->node->output_socket(index)};
119}
120
122
123/* -------------------------------------------------------------------- */
126
128{
129 return get_default_hash(this->context_hash(), this->socket);
130}
131
133{
134 return context ? context->hash() : ComputeContextHash{};
135}
136
138{
139 return this->socket;
140}
141
143{
144 return *this->socket;
145}
146
147inline SocketInContext::operator bool() const
148{
149 return this->socket != nullptr;
150}
151
153{
154 return {this->context, &this->socket->owner_node()};
155}
156
158
159/* -------------------------------------------------------------------- */
162
164{
165 return get_default_hash(this->context_hash(), this->tree);
166}
167
169{
170 return context ? context->hash() : ComputeContextHash{};
171}
172
174{
175 return this->tree;
176}
177
179{
180 return *this->tree;
181}
182
183inline TreeInContext::operator bool() const
184{
185 return this->tree != nullptr;
186}
187
189
190} // namespace blender::nodes
#define BLI_STRUCT_EQUALITY_OPERATORS_2(Type, m1, m2)
unsigned long long int uint64_t
uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:233
SocketInContext input_socket(int index) const
SocketInContext output_socket(int index) const