diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-24 17:24:33 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2017-11-24 17:24:33 +0300 |
commit | 93e8a045df4cecdd0572dfd583e697552d8a9b10 (patch) | |
tree | 0856b0c6f6f1c52b7275497b7fbea1f9840e1fe1 | |
parent | 68654c0be54cc11e3ce10e664f19121dfb02335a (diff) |
Depsgraph: Introduce explicit method which finds operation or returns NULL
-rw-r--r-- | source/blender/depsgraph/intern/nodes/deg_node_component.cc | 23 | ||||
-rw-r--r-- | source/blender/depsgraph/intern/nodes/deg_node_component.h | 8 |
2 files changed, 26 insertions, 5 deletions
diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.cc b/source/blender/depsgraph/intern/nodes/deg_node_component.cc index f520fc7ef52..bbf4a46fa78 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.cc +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.cc @@ -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, diff --git a/source/blender/depsgraph/intern/nodes/deg_node_component.h b/source/blender/depsgraph/intern/nodes/deg_node_component.h index 39365ad31af..a9a5904b4ec 100644 --- a/source/blender/depsgraph/intern/nodes/deg_node_component.h +++ b/source/blender/depsgraph/intern/nodes/deg_node_component.h @@ -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, |