Blender V5.3
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
8
9#pragma once
10
12#include "BLI_hash.hh"
13
14#include "BKE_node_runtime.hh"
15
16namespace blender {
17
18struct bNode;
19struct bNodeSocket;
20
21namespace nodes {
22
23struct NodeInContext;
24struct SocketInContext;
25
31 const ComputeContext *context = nullptr;
32 const bNode *node = nullptr;
33
34 uint64_t hash() const;
36 const bNode *operator->() const;
37 const bNode &operator*() const;
38 operator bool() const;
39
42
47 friend bool operator==(const NodeInContext &a, const NodeInContext &b)
48 {
49 return a.context_hash() == b.context_hash() && a.node == b.node;
50 }
51};
52
58 const ComputeContext *context = nullptr;
59 const bNodeSocket *socket = nullptr;
60
61 uint64_t hash() const;
63 const bNodeSocket *operator->() const;
64 const bNodeSocket &operator*() const;
65 operator bool() const;
66
68
73 friend bool operator==(const SocketInContext &a, const SocketInContext &b)
74 {
75 return a.context_hash() == b.context_hash() && a.socket == b.socket;
76 }
77};
78
83 const ComputeContext *context = nullptr;
84 const bNodeTree *tree = nullptr;
85
86 uint64_t hash() const;
88 const bNodeTree *operator->() const;
89 const bNodeTree &operator*() const;
90 operator bool() const;
91};
92
93/* -------------------------------------------------------------------- */
96
98{
99 return get_default_hash(this->context_hash(), this->node);
100}
101
106
107inline const bNode *NodeInContext::operator->() const
108{
109 return this->node;
110}
111
112inline const bNode &NodeInContext::operator*() const
113{
114 return *this->node;
115}
116
117inline NodeInContext::operator bool() const
118{
119 return this->node != nullptr;
120}
121
123{
124 return {this->context, &this->node->input_socket(index)};
125}
126
128{
129 return {this->context, &this->node->output_socket(index)};
130}
131
133
134/* -------------------------------------------------------------------- */
137
139{
140 return get_default_hash(this->context_hash(), this->socket);
141}
142
147
149{
150 return this->socket;
151}
152
154{
155 return *this->socket;
156}
157
158inline SocketInContext::operator bool() const
159{
160 return this->socket != nullptr;
161}
162
164{
165 return {this->context, &this->socket->owner_node()};
166}
167
169
170/* -------------------------------------------------------------------- */
173
175{
176 return get_default_hash(this->context_hash(), this->tree);
177}
178
183
185{
186 return this->tree;
187}
188
190{
191 return *this->tree;
192}
193
194inline TreeInContext::operator bool() const
195{
196 return this->tree != nullptr;
197}
198
200
201} // namespace nodes
202} // namespace blender
const ComputeContextHash & hash() const
BMesh Iterators.
unsigned __int64 uint64_t
Definition BKE_text.h:91
constexpr uint64_t get_default_hash(const T &v, const Args &...args)
Definition BLI_hash.hh:252
friend bool operator==(const NodeInContext &a, const NodeInContext &b)
SocketInContext input_socket(int index) const
SocketInContext output_socket(int index) const
friend bool operator==(const SocketInContext &a, const SocketInContext &b)