Blender V4.5
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
68/* -------------------------------------------------------------------- */
71
73{
74 return get_default_hash(this->context_hash(), this->node);
75}
76
81
82inline const bNode *NodeInContext::operator->() const
83{
84 return this->node;
85}
86
87inline const bNode &NodeInContext::operator*() const
88{
89 return *this->node;
90}
91
92inline NodeInContext::operator bool() const
93{
94 return this->node != nullptr;
95}
96
97inline SocketInContext NodeInContext::input_socket(const int index) const
98{
99 return {this->context, &this->node->input_socket(index)};
100}
101
103{
104 return {this->context, &this->node->output_socket(index)};
105}
106
108
109/* -------------------------------------------------------------------- */
112
114{
115 return get_default_hash(this->context_hash(), this->socket);
116}
117
119{
120 return context ? context->hash() : ComputeContextHash{};
121}
122
124{
125 return this->socket;
126}
127
129{
130 return *this->socket;
131}
132
133inline SocketInContext::operator bool() const
134{
135 return this->socket != nullptr;
136}
137
139{
140 return {this->context, &this->socket->owner_node()};
141}
142
144
145} // 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