Depsgraph: Introduce explicit method which finds operation or returns NULL

This commit is contained in:
2017-11-24 15:24:33 +01:00
parent 68654c0be5
commit 93e8a045df
2 changed files with 26 additions and 5 deletions

View File

@@ -163,18 +163,31 @@ string ComponentDepsNode::identifier() const
return string(typebuf) + name + " : " + idname + " (Layers: " + layers + ")";
}
OperationDepsNode *ComponentDepsNode::find_operation(OperationIDKey key) const
{
OperationDepsNode *node =
(OperationDepsNode *)BLI_ghash_lookup(operations_map, &key);
return node;
}
OperationDepsNode *ComponentDepsNode::find_operation(eDepsOperation_Code opcode,
const char *name,
int name_tag) const
{
OperationIDKey key(opcode, name, name_tag);
return find_operation(key);
}
OperationDepsNode *ComponentDepsNode::get_operation(OperationIDKey key) const
{
OperationDepsNode *node = reinterpret_cast<OperationDepsNode *>(BLI_ghash_lookup(operations_map, &key));
if (node != NULL) {
return node;
}
else {
OperationDepsNode *node = find_operation(key);
if (node == NULL) {
fprintf(stderr, "%s: find_operation(%s) failed\n",
this->identifier().c_str(), key.identifier().c_str());
BLI_assert(!"Request for non-existing operation, should not happen");
return NULL;
}
return node;
}
OperationDepsNode *ComponentDepsNode::get_operation(eDepsOperation_Code opcode,

View File

@@ -74,6 +74,14 @@ struct ComponentDepsNode : public DepsNode {
string identifier() const;
/* Find an existing operation, if requested operation does not exist
* NULL will be returned.
*/
OperationDepsNode *find_operation(OperationIDKey key) const;
OperationDepsNode *find_operation(eDepsOperation_Code opcode,
const char *name,
int name_tag) const;
/* Find an existing operation, will throw an assert() if it does not exist. */
OperationDepsNode *get_operation(OperationIDKey key) const;
OperationDepsNode *get_operation(eDepsOperation_Code opcode,