Depsgraph: Move key implementation from header to dedicated file
authorSergey Sharybin <sergey.vfx@gmail.com>
Thu, 3 Nov 2016 15:25:26 +0000 (16:25 +0100)
committerSergey Sharybin <sergey.vfx@gmail.com>
Mon, 7 Nov 2016 10:04:49 +0000 (11:04 +0100)
source/blender/depsgraph/CMakeLists.txt
source/blender/depsgraph/intern/builder/deg_builder_relations.h
source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc [new file with mode: 0644]

index fd2a521bec56911d08b6b0603cc4524704103531..ab12a8d5b3ef98c17e0c596664ac9ae4f469704b 100644 (file)
@@ -45,6 +45,7 @@ set(SRC
        intern/builder/deg_builder_nodes.cc
        intern/builder/deg_builder_pchanmap.cc
        intern/builder/deg_builder_relations.cc
+       intern/builder/deg_builder_relations_keys.cc
        intern/builder/deg_builder_transitive.cc
        intern/debug/deg_debug_graphviz.cc
        intern/eval/deg_eval.cc
index 056d4fdfe3dae6409a7f9629560cfa01238aa4de..8d8ad6772b81838de87e3beb79a5a3e778d3b1e2 100644 (file)
@@ -81,42 +81,26 @@ struct ComponentDepsNode;
 struct OperationDepsNode;
 struct RootPChanMap;
 
-struct RootKey
-{
-       RootKey() {}
+struct RootKey {
+       RootKey();
 };
 
 struct TimeSourceKey
 {
-       TimeSourceKey() : id(NULL) {}
-       TimeSourceKey(ID *id) : id(id) {}
+       TimeSourceKey();
+       TimeSourceKey(ID *id);
 
-       string identifier() const
-       {
-               return string("TimeSourceKey");
-       }
+       string identifier() const;
 
        ID *id;
 };
 
 struct ComponentKey
 {
-       ComponentKey() :
-           id(NULL), type(DEPSNODE_TYPE_UNDEFINED), name("")
-       {}
-       ComponentKey(ID *id, eDepsNode_Type type, const char *name = "") :
-           id(id), type(type), name(name)
-       {}
-
-       string identifier() const
-       {
-               const char *idname = (id) ? id->name : "<None>";
+       ComponentKey();
+       ComponentKey(ID *id, eDepsNode_Type type, const char *name = "");
 
-               char typebuf[5];
-               BLI_snprintf(typebuf, sizeof(typebuf), "%d", type);
-
-               return string("ComponentKey(") + idname + ", " + typebuf + ", '" + name + "')";
-       }
+       string identifier() const;
 
        ID *id;
        eDepsNode_Type type;
@@ -125,95 +109,38 @@ struct ComponentKey
 
 struct OperationKey
 {
-       OperationKey()
-               : id(NULL),
-                 component_type(DEPSNODE_TYPE_UNDEFINED),
-                 component_name(""),
-                 opcode(DEG_OPCODE_OPERATION),
-                 name(""),
-                 name_tag(-1)
-       {}
-
+       OperationKey();
        OperationKey(ID *id,
                     eDepsNode_Type component_type,
                     const char *name,
-                    int name_tag = -1)
-               : id(id),
-                 component_type(component_type),
-                 component_name(""),
-                 opcode(DEG_OPCODE_OPERATION),
-                 name(name),
-                 name_tag(name_tag)
-       {}
+                    int name_tag = -1);
        OperationKey(ID *id,
                     eDepsNode_Type component_type,
                     const char *component_name,
                     const char *name,
-                    int name_tag)
-               : id(id),
-                 component_type(component_type),
-                 component_name(component_name),
-                 opcode(DEG_OPCODE_OPERATION),
-                 name(name),
-                 name_tag(name_tag)
-       {}
+                    int name_tag);
 
        OperationKey(ID *id,
                     eDepsNode_Type component_type,
-                    eDepsOperation_Code opcode)
-               : id(id),
-                 component_type(component_type),
-                 component_name(""),
-                 opcode(opcode),
-                 name(""),
-                 name_tag(-1)
-       {}
+                    eDepsOperation_Code opcode);
        OperationKey(ID *id,
                     eDepsNode_Type component_type,
                     const char *component_name,
-                    eDepsOperation_Code opcode)
-               : id(id),
-                 component_type(component_type),
-                 component_name(component_name),
-                 opcode(opcode),
-                 name(""),
-                 name_tag(-1)
-       {}
+                    eDepsOperation_Code opcode);
 
        OperationKey(ID *id,
-                   eDepsNode_Type component_type,
-                   eDepsOperation_Code opcode,
-                   const char *name,
-                   int name_tag = -1)
-               : id(id),
-                 component_type(component_type),
-                 component_name(""),
-                 opcode(opcode),
-                 name(name),
-                 name_tag(name_tag)
-       {}
+                    eDepsNode_Type component_type,
+                    eDepsOperation_Code opcode,
+                    const char *name,
+                    int name_tag = -1);
        OperationKey(ID *id,
                     eDepsNode_Type component_type,
                     const char *component_name,
                     eDepsOperation_Code opcode,
                     const char *name,
-                    int name_tag = -1)
-               : id(id),
-                 component_type(component_type),
-                 component_name(component_name),
-                 opcode(opcode),
-                 name(name),
-                 name_tag(name_tag)
-       {}
-
-       string identifier() const
-       {
-               char typebuf[5];
-               BLI_snprintf(typebuf, sizeof(typebuf), "%d", component_type);
-
-               return string("OperationKey(") + "t: " + typebuf + ", cn: '" + component_name + "', c: " + DEG_OPNAMES[opcode] + ", n: '" + name + "')";
-       }
+                    int name_tag = -1);
 
+       string identifier() const;
 
        ID *id;
        eDepsNode_Type component_type;
@@ -225,21 +152,12 @@ struct OperationKey
 
 struct RNAPathKey
 {
-       // Note: see depsgraph_build.cpp for implementation
+       /* NOTE: see depsgraph_build.cpp for implementation */
        RNAPathKey(ID *id, const char *path);
 
-       RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop) :
-           id(id), ptr(ptr), prop(prop)
-       {}
-
-       string identifier() const
-       {
-               const char *id_name   = (id) ?  id->name : "<No ID>";
-               const char *prop_name = (prop) ? RNA_property_identifier(prop) : "<No Prop>";
-
-               return string("RnaPathKey(") + "id: " + id_name + ", prop: " + prop_name +  "')";
-       }
+       RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop);
 
+       string identifier() const;
 
        ID *id;
        PointerRNA ptr;
diff --git a/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc b/source/blender/depsgraph/intern/builder/deg_builder_relations_keys.cc
new file mode 100644 (file)
index 0000000..7ada04e
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * The Original Code is Copyright (C) 2013 Blender Foundation.
+ * All rights reserved.
+ *
+ * Original Author: Joshua Leung
+ * Contributor(s): Based on original depsgraph.c code - Blender Foundation (2005-2013)
+ *
+ * ***** END GPL LICENSE BLOCK *****
+ */
+
+/** \file blender/depsgraph/intern/builder/deg_builder_relations.cc
+ *  \ingroup depsgraph
+ *
+ * Methods for constructing depsgraph
+ */
+
+#include "intern/builder/deg_builder_relations.h"
+
+namespace DEG {
+
+/////////////////////////////////////////
+// Root.
+
+RootKey::RootKey()
+{
+}
+
+/////////////////////////////////////////
+// Time source.
+
+TimeSourceKey::TimeSourceKey()
+        : id(NULL)
+{
+}
+
+TimeSourceKey::TimeSourceKey(ID *id)
+        : id(id)
+{
+}
+
+string TimeSourceKey::identifier() const
+{
+       return string("TimeSourceKey");
+}
+
+/////////////////////////////////////////
+// Component.
+
+ComponentKey::ComponentKey()
+        : id(NULL),
+          type(DEPSNODE_TYPE_UNDEFINED),
+          name("")
+{
+}
+
+ComponentKey::ComponentKey(ID *id, eDepsNode_Type type, const char *name)
+        : id(id),
+          type(type),
+          name(name)
+{
+}
+
+string ComponentKey::identifier() const
+{
+       const char *idname = (id) ? id->name : "<None>";
+       char typebuf[5];
+       BLI_snprintf(typebuf, sizeof(typebuf), "%d", type);
+       return string("ComponentKey(") +
+              idname + ", " + typebuf + ", '" + name + "')";
+}
+
+/////////////////////////////////////////
+// Operation.
+
+OperationKey::OperationKey()
+        : id(NULL),
+          component_type(DEPSNODE_TYPE_UNDEFINED),
+          component_name(""),
+          opcode(DEG_OPCODE_OPERATION),
+          name(""),
+          name_tag(-1)
+{
+}
+
+OperationKey::OperationKey(ID *id,
+                           eDepsNode_Type component_type,
+                           const char *name,
+                           int name_tag)
+        : id(id),
+          component_type(component_type),
+          component_name(""),
+          opcode(DEG_OPCODE_OPERATION),
+          name(name),
+          name_tag(name_tag)
+{
+}
+
+OperationKey::OperationKey(ID *id,
+                           eDepsNode_Type component_type,
+                           const char *component_name,
+                           const char *name,
+                           int name_tag)
+        : id(id),
+          component_type(component_type),
+          component_name(component_name),
+          opcode(DEG_OPCODE_OPERATION),
+          name(name),
+          name_tag(name_tag)
+{
+}
+
+OperationKey::OperationKey(ID *id,
+                           eDepsNode_Type component_type,
+                           eDepsOperation_Code opcode)
+        : id(id),
+          component_type(component_type),
+          component_name(""),
+          opcode(opcode),
+          name(""),
+          name_tag(-1)
+{
+}
+
+OperationKey::OperationKey(ID *id,
+                           eDepsNode_Type component_type,
+                           const char *component_name,
+                           eDepsOperation_Code opcode)
+        : id(id),
+          component_type(component_type),
+          component_name(component_name),
+          opcode(opcode),
+          name(""),
+          name_tag(-1)
+{
+}
+
+OperationKey::OperationKey(ID *id,
+                           eDepsNode_Type component_type,
+                           eDepsOperation_Code opcode,
+                           const char *name,
+                           int name_tag)
+        : id(id),
+          component_type(component_type),
+          component_name(""),
+          opcode(opcode),
+          name(name),
+          name_tag(name_tag)
+{
+}
+
+OperationKey::OperationKey(ID *id,
+                           eDepsNode_Type component_type,
+                           const char *component_name,
+                           eDepsOperation_Code opcode,
+                           const char *name,
+                           int name_tag)
+        : id(id),
+          component_type(component_type),
+          component_name(component_name),
+          opcode(opcode),
+          name(name),
+          name_tag(name_tag)
+{
+}
+
+string OperationKey::identifier() const
+{
+       char typebuf[5];
+       BLI_snprintf(typebuf, sizeof(typebuf), "%d", component_type);
+       return string("OperationKey(") +
+              "t: " + typebuf +
+              ", cn: '" + component_name +
+              "', c: " + DEG_OPNAMES[opcode] +
+              ", n: '" + name + "')";
+}
+
+/////////////////////////////////////////
+// RNA path.
+
+RNAPathKey::RNAPathKey(ID *id, const PointerRNA &ptr, PropertyRNA *prop)
+        : id(id),
+          ptr(ptr),
+          prop(prop)
+{
+}
+
+string RNAPathKey::identifier() const
+{
+       const char *id_name   = (id) ?  id->name : "<No ID>";
+       const char *prop_name = (prop) ? RNA_property_identifier(prop) : "<No Prop>";
+       return string("RnaPathKey(") + "id: " + id_name +
+                                      ", prop: " + prop_name +  "')";
+}
+
+}  // namespace DEG