Blender V5.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
8
9#pragma once
10
15
16#include "DNA_ID.h"
17
18#include "RNA_types.hh"
19
20namespace blender {
21
22struct ID;
23struct PropertyRNA;
24
25namespace deg {
26
28 TimeSourceKey() = default;
29
30 std::string identifier() const;
31};
32
34 ComponentKey() = default;
35
36 ComponentKey(const ID *id, NodeType type, const char *name = "") : id(id), type(type), name(name)
37 {
38 }
39
40 std::string identifier() const;
41
42 const ID *id = nullptr;
44 const char *name = "";
45};
46
48 OperationKey() = default;
49
50 OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1)
52 {
53 }
54
55 OperationKey(const ID *id,
57 const char *component_name,
58 const char *name,
59 int name_tag)
60 : id(id),
63 name(name),
65 {
66 }
67
72
80
89 OperationKey(const ID *id,
91 const char *component_name,
93 const char *name,
94 int name_tag = -1)
95 : id(id),
99 name(name),
101 {
102 }
103
104 OperationKey(OperationKey &&other) noexcept = default;
106
107 OperationKey(const OperationKey &other) = default;
108 OperationKey &operator=(const OperationKey &other) = default;
109
110 std::string identifier() const;
111
112 const ID *id = nullptr;
114 const char *component_name = "";
116 const char *name = "";
117 int name_tag = -1;
118};
119
120/* Similar to the #OperationKey but does not contain external references, which makes it
121 * suitable to identify operations even after the original database or graph was destroyed.
122 * The downside of this key over the #OperationKey is that it performs string allocation upon
123 * the key construction. */
125 /* Create the key which identifies the given operation node. */
127 {
128 const ComponentNode *component_node = operation_node->owner;
129 const IDNode *id_node = component_node->owner;
130
131 /* Copy names over to our object, so that the key stays valid even after the `operation_node`
132 * is destroyed. */
133 component_name_storage_ = component_node->name;
134 name_storage_ = operation_node->name;
135
136 /* Assign fields used by the #OperationKey API. */
137 id = id_node->id_orig;
138 component_type = component_node->type;
139 component_name = component_name_storage_.c_str();
140 opcode = operation_node->opcode;
141 name = name_storage_.c_str();
142 name_tag = operation_node->name_tag;
143 }
144
146 {
147 component_name_storage_ = std::move(other.component_name_storage_);
148 name_storage_ = std::move(other.name_storage_);
149
150 /* Re-assign pointers to the strings.
151 * This is needed because string content can actually change address if the string uses the
152 * small string optimization. */
153 component_name = component_name_storage_.c_str();
154 name = name_storage_.c_str();
155 }
156
158
161
162 private:
163 std::string component_name_storage_;
164 std::string name_storage_;
165};
166
168 RNAPathKey(ID *id, const char *path, RNAPointerSource source);
169 RNAPathKey(const PointerRNA &target_prop,
170 const char *rna_path_from_target_prop,
173
174 std::string identifier() const;
175
180};
181
182} // namespace deg
183} // namespace blender
ID and Library types, which are fundamental for SDNA.
BMesh Iterators.
std::string identifier() const
ComponentKey(const ID *id, NodeType type, const char *name="")
std::string name
Definition deg_node.hh:186
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)
std::string identifier() const
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)
std::string identifier() const
std::string identifier() const