Blender V4.3
deg_builder_key.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2013 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
9#pragma once
10
16
17#include "DNA_ID.h"
18
19#include "RNA_access.hh"
20#include "RNA_types.hh"
21
22struct ID;
23struct PropertyRNA;
24
25namespace blender::deg {
26
28 TimeSourceKey() = default;
29
30 string identifier() const;
31};
32
34 ComponentKey() = default;
35
36 inline ComponentKey(const ID *id, NodeType type, const char *name = "")
37 : id(id), type(type), name(name)
38 {
39 }
40
41 string identifier() const;
42
43 const ID *id = nullptr;
45 const char *name = "";
46};
47
49 OperationKey() = default;
50
51 inline OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1)
52 : id(id),
56 name(name),
58 {
59 }
60
61 OperationKey(const ID *id,
63 const char *component_name,
64 const char *name,
65 int name_tag)
66 : id(id),
70 name(name),
72 {
73 }
74
76 : id(id),
80 name(""),
81 name_tag(-1)
82 {
83 }
84
85 OperationKey(const ID *id,
87 const char *component_name,
89 : id(id),
93 name(""),
94 name_tag(-1)
95 {
96 }
97
98 OperationKey(const ID *id,
101 const char *name,
102 int name_tag = -1)
103 : id(id),
105 component_name(""),
106 opcode(opcode),
107 name(name),
109 {
110 }
111
112 OperationKey(const ID *id,
114 const char *component_name,
116 const char *name,
117 int name_tag = -1)
118 : id(id),
121 opcode(opcode),
122 name(name),
124 {
125 }
126
127 OperationKey(OperationKey &&other) noexcept = default;
129
130 OperationKey(const OperationKey &other) = default;
131 OperationKey &operator=(const OperationKey &other) = default;
132
133 string identifier() const;
134
135 const ID *id = nullptr;
137 const char *component_name = "";
139 const char *name = "";
140 int name_tag = -1;
141};
142
143/* Similar to the #OperationKey but does not contain external references, which makes it
144 * suitable to identify operations even after the original database or graph was destroyed.
145 * The downside of this key over the #OperationKey is that it performs string allocation upon
146 * the key construction. */
148 /* Create the key which identifies the given operation node. */
150 {
151 const ComponentNode *component_node = operation_node->owner;
152 const IDNode *id_node = component_node->owner;
153
154 /* Copy names over to our object, so that the key stays valid even after the `operation_node`
155 * is destroyed. */
156 component_name_storage_ = component_node->name;
157 name_storage_ = operation_node->name;
158
159 /* Assign fields used by the #OperationKey API. */
160 id = id_node->id_orig;
161 component_type = component_node->type;
162 component_name = component_name_storage_.c_str();
163 opcode = operation_node->opcode;
164 name = name_storage_.c_str();
165 name_tag = operation_node->name_tag;
166 }
167
169 {
170 component_name_storage_ = std::move(other.component_name_storage_);
171 name_storage_ = std::move(other.name_storage_);
172
173 /* Re-assign pointers to the strings.
174 * This is needed because string content can actually change address if the string uses the
175 * small string optimization. */
176 component_name = component_name_storage_.c_str();
177 name = name_storage_.c_str();
178 }
179
181
184
185 private:
186 string component_name_storage_;
187 string name_storage_;
188};
189
191 RNAPathKey(ID *id, const char *path, RNAPointerSource source);
192 RNAPathKey(const PointerRNA &target_prop,
193 const char *rna_path_from_target_prop,
196
197 string identifier() const;
198
203};
204
205} // namespace blender::deg
ID and Library types, which are fundamental for SDNA.
const IDNode * id_node
Definition DNA_ID.h:413
ComponentKey(const ID *id, NodeType type, const char *name="")
OperationKey(const ID *id, NodeType component_type, OperationCode opcode)
OperationKey(const ID *id, NodeType component_type, const char *component_name, OperationCode opcode)
OperationKey(OperationKey &&other) noexcept=default
OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag=-1)
OperationKey(const ID *id, NodeType component_type, const char *component_name, const char *name, int name_tag)
OperationKey(const OperationKey &other)=default
OperationKey(const ID *id, NodeType component_type, OperationCode opcode, const char *name, int name_tag=-1)
OperationKey & operator=(OperationKey &&other)=default
OperationKey(const ID *id, NodeType component_type, const char *component_name, OperationCode opcode, const char *name, int name_tag=-1)
OperationKey & operator=(const OperationKey &other)=default
PersistentOperationKey(const OperationNode *operation_node)
PersistentOperationKey(const PersistentOperationKey &other)=delete
PersistentOperationKey & operator=(const PersistentOperationKey &other)=delete
PersistentOperationKey & operator=(PersistentOperationKey &&other)=delete
PersistentOperationKey(PersistentOperationKey &&other) noexcept
RNAPathKey(ID *id, const char *path, RNAPointerSource source)