Blender  V3.3
node_declaration.cc
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
4 
5 #include "BKE_node.h"
6 
7 namespace blender::nodes {
8 
10 {
11  auto check_sockets = [&](ListBase sockets, Span<SocketDeclarationPtr> socket_decls) {
12  const int tot_sockets = BLI_listbase_count(&sockets);
13  if (tot_sockets != socket_decls.size()) {
14  return false;
15  }
16  int i;
17  LISTBASE_FOREACH_INDEX (const bNodeSocket *, socket, &sockets, i) {
18  const SocketDeclaration &socket_decl = *socket_decls[i];
19  if (!socket_decl.matches(*socket)) {
20  return false;
21  }
22  }
23  return true;
24  };
25 
26  if (!check_sockets(node.inputs, inputs_)) {
27  return false;
28  }
29  if (!check_sockets(node.outputs, outputs_)) {
30  return false;
31  }
32  return true;
33 }
34 
36  bNode &node,
37  bNodeSocket &socket) const
38 {
39  /* By default just rebuild. */
40  BLI_assert(socket.in_out == in_out_);
41  UNUSED_VARS_NDEBUG(socket);
42  return this->build(ntree, node);
43 }
44 
46 {
53 }
54 
56 {
57  if (socket.name != name_) {
58  return false;
59  }
60  if (socket.identifier != identifier_) {
61  return false;
62  }
63  if (((socket.flag & SOCK_COMPACT) != 0) != compact_) {
64  return false;
65  }
66  if (((socket.flag & SOCK_HIDE_VALUE) != 0) != hide_value_) {
67  return false;
68  }
69  if (((socket.flag & SOCK_HIDE_LABEL) != 0) != hide_label_) {
70  return false;
71  }
72  if (((socket.flag & SOCK_MULTI_INPUT) != 0) != is_multi_input_) {
73  return false;
74  }
75  if (((socket.flag & SOCK_NO_INTERNAL_LINK) != 0) != no_mute_links_) {
76  return false;
77  }
78  if (((socket.flag & SOCK_UNAVAIL) != 0) != is_unavailable_) {
79  return false;
80  }
81  return true;
82 }
83 
84 } // namespace blender::nodes
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define LISTBASE_FOREACH_INDEX(type, var, list, index_var)
Definition: BLI_listbase.h:344
int BLI_listbase_count(const struct ListBase *listbase) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
#define UNUSED_VARS_NDEBUG(...)
#define SET_FLAG_FROM_TEST(value, test, flag)
@ SOCK_HIDE_LABEL
@ SOCK_HIDE_VALUE
@ SOCK_MULTI_INPUT
@ SOCK_COMPACT
@ SOCK_UNAVAIL
@ SOCK_NO_INTERNAL_LINK
bool matches(const bNode &node) const
Span< SocketDeclarationPtr > sockets(eNodeSocketInOut in_out) const
virtual bool matches(const bNodeSocket &socket) const =0
bool matches_common_data(const bNodeSocket &socket) const
virtual bNodeSocket & build(bNodeTree &ntree, bNode &node) const =0
virtual bNodeSocket & update_or_build(bNodeTree &ntree, bNode &node, bNodeSocket &socket) const
void set_common_flags(bNodeSocket &socket) const
OperationNode * node
bNodeTree * ntree
char name[64]
char identifier[64]