[Bf-blender-cvs] [e420a30] depsgraph_refactor: Code Cleanup: Disambiguate the "ComponentKey" name

Joshua Leung noreply at git.blender.org
Thu Jan 1 14:42:43 CET 2015


Commit: e420a303c7c17d6b8f9bcf5fb31c16bd59c0ba1a
Author: Joshua Leung
Date:   Fri Jan 2 01:56:37 2015 +1300
Branches: depsgraph_refactor
https://developer.blender.org/rBe420a303c7c17d6b8f9bcf5fb31c16bd59c0ba1a

Code Cleanup: Disambiguate the "ComponentKey" name

ComponentKey was mostly used to refer to the lookup keys used when specifying
a relevant node for use when creating a relationship, while the secondary
usage of this was in IDDepsNodes as the keys for the component dict. While there
is technically no problem with having this, in practice it was too confusing.

So, now "ComponentKey" is only for looking up nodes, while "ComponentIDKey" is
used internally to identify keys.

===================================================================

M	source/blender/depsgraph/intern/depsnode.cpp
M	source/blender/depsgraph/intern/depsnode.h

===================================================================

diff --git a/source/blender/depsgraph/intern/depsnode.cpp b/source/blender/depsgraph/intern/depsnode.cpp
index 73640c5..43ee5eb 100644
--- a/source/blender/depsgraph/intern/depsnode.cpp
+++ b/source/blender/depsgraph/intern/depsnode.cpp
@@ -148,7 +148,7 @@ void IDDepsNode::copy(DepsgraphCopyContext *dcc, const IDDepsNode *src)
 	     ++it)
 	{
 		/* Get current <type : component> mapping. */
-		ComponentKey c_key      = it->first;
+		ComponentIDKey c_key    = it->first;
 		DepsNode *old_component = it->second;
 
 		/* Make a copy of component. */
@@ -164,7 +164,7 @@ void IDDepsNode::copy(DepsgraphCopyContext *dcc, const IDDepsNode *src)
 ComponentDepsNode *IDDepsNode::find_component(eDepsNode_Type type,
                                               const string &name) const
 {
-	ComponentKey key(type, name);
+	ComponentIDKey key(type, name);
 	ComponentMap::const_iterator it = components.find(key);
 	return it != components.end() ? it->second : NULL;
 }
@@ -172,7 +172,7 @@ ComponentDepsNode *IDDepsNode::find_component(eDepsNode_Type type,
 ComponentDepsNode *IDDepsNode::add_component(eDepsNode_Type type,
                                              const string &name)
 {
-	ComponentKey key(type, name);
+	ComponentIDKey key(type, name);
 	ComponentDepsNode *comp_node = find_component(type, name);
 	if (!comp_node) {
 		DepsNodeFactory *factory = DEG_get_node_factory(type);
@@ -187,7 +187,7 @@ ComponentDepsNode *IDDepsNode::add_component(eDepsNode_Type type,
 
 void IDDepsNode::remove_component(eDepsNode_Type type, const string &name)
 {
-	ComponentKey key(type, name);
+	ComponentIDKey key(type, name);
 	ComponentDepsNode *comp_node = find_component(type, name);
 	if (comp_node) {
 		/* Unregister. */
diff --git a/source/blender/depsgraph/intern/depsnode.h b/source/blender/depsgraph/intern/depsnode.h
index 36fb3a3..83137ce 100644
--- a/source/blender/depsgraph/intern/depsnode.h
+++ b/source/blender/depsgraph/intern/depsnode.h
@@ -139,11 +139,11 @@ struct RootDepsNode : public DepsNode {
 
 /* ID-Block Reference */
 struct IDDepsNode : public DepsNode {
-	struct ComponentKey {
-		ComponentKey(eDepsNode_Type type, const string &name = "")
+	struct ComponentIDKey {
+		ComponentIDKey(eDepsNode_Type type, const string &name = "")
 		    : type(type), name(name) {}
 
-		bool operator== (const ComponentKey &other) const
+		bool operator== (const ComponentIDKey &other) const
 		{
 			return type == other.type && name == other.name;
 		}
@@ -152,19 +152,19 @@ struct IDDepsNode : public DepsNode {
 		string name;
 	};
 
-	/* XXX can't specialize std::hash for this purpose, because ComponentKey is
+	/* XXX can't specialize std::hash for this purpose, because ComponentIDKey is
 	 * a nested type ...
 	 *
 	 *   http://stackoverflow.com/a/951245
 	 */
 	struct component_key_hash {
-		bool operator() (const ComponentKey &key) const
+		bool operator() (const ComponentIDKey &key) const
 		{
 			return hash_combine(hash<int>()(key.type), hash<string>()(key.name));
 		}
 	};
 
-	typedef unordered_map<ComponentKey,
+	typedef unordered_map<ComponentIDKey,
 	                      ComponentDepsNode*,
 	                      component_key_hash> ComponentMap;




More information about the Bf-blender-cvs mailing list