Blender V5.0
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
20struct ID;
21struct PropertyRNA;
22
23namespace blender::deg {
24
26 TimeSourceKey() = default;
27
28 std::string identifier() const;
29};
30
32 ComponentKey() = default;
33
34 ComponentKey(const ID *id, NodeType type, const char *name = "") : id(id), type(type), name(name)
35 {
36 }
37
38 std::string identifier() const;
39
40 const ID *id = nullptr;
42 const char *name = "";
43};
44
46 OperationKey() = default;
47
48 OperationKey(const ID *id, NodeType component_type, const char *name, int name_tag = -1)
50 {
51 }
52
53 OperationKey(const ID *id,
55 const char *component_name,
56 const char *name,
57 int name_tag)
58 : id(id),
61 name(name),
63 {
64 }
65
70
78
87 OperationKey(const ID *id,
89 const char *component_name,
91 const char *name,
92 int name_tag = -1)
93 : id(id),
97 name(name),
99 {
100 }
101
102 OperationKey(OperationKey &&other) noexcept = default;
104
105 OperationKey(const OperationKey &other) = default;
106 OperationKey &operator=(const OperationKey &other) = default;
107
108 std::string identifier() const;
109
110 const ID *id = nullptr;
112 const char *component_name = "";
114 const char *name = "";
115 int name_tag = -1;
116};
117
118/* Similar to the #OperationKey but does not contain external references, which makes it
119 * suitable to identify operations even after the original database or graph was destroyed.
120 * The downside of this key over the #OperationKey is that it performs string allocation upon
121 * the key construction. */
123 /* Create the key which identifies the given operation node. */
125 {
126 const ComponentNode *component_node = operation_node->owner;
127 const IDNode *id_node = component_node->owner;
128
129 /* Copy names over to our object, so that the key stays valid even after the `operation_node`
130 * is destroyed. */
131 component_name_storage_ = component_node->name;
132 name_storage_ = operation_node->name;
133
134 /* Assign fields used by the #OperationKey API. */
135 id = id_node->id_orig;
136 component_type = component_node->type;
137 component_name = component_name_storage_.c_str();
138 opcode = operation_node->opcode;
139 name = name_storage_.c_str();
140 name_tag = operation_node->name_tag;
141 }
142
144 {
145 component_name_storage_ = std::move(other.component_name_storage_);
146 name_storage_ = std::move(other.name_storage_);
147
148 /* Re-assign pointers to the strings.
149 * This is needed because string content can actually change address if the string uses the
150 * small string optimization. */
151 component_name = component_name_storage_.c_str();
152 name = name_storage_.c_str();
153 }
154
156
159
160 private:
161 std::string component_name_storage_;
162 std::string name_storage_;
163};
164
166 RNAPathKey(ID *id, const char *path, RNAPointerSource source);
167 RNAPathKey(const PointerRNA &target_prop,
168 const char *rna_path_from_target_prop,
171
172 std::string identifier() const;
173
178};
179
180} // namespace blender::deg
ID and Library types, which are fundamental for SDNA.
Definition DNA_ID.h:414
std::string identifier() const
ComponentKey(const ID *id, NodeType type, const char *name="")
std::string name
Definition deg_node.hh:180
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