[Bf-blender-cvs] [b1fb402e1b5] functions: cleanup VTreeDataGraph

Jacques Lucke noreply at git.blender.org
Wed Jul 31 18:45:07 CEST 2019


Commit: b1fb402e1b543f41d4537306b0d2b87baede3cb9
Author: Jacques Lucke
Date:   Wed Jul 31 17:11:26 2019 +0200
Branches: functions
https://developer.blender.org/rBb1fb402e1b543f41d4537306b0d2b87baede3cb9

cleanup VTreeDataGraph

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

M	source/blender/functions/frontends/data_flow_nodes/builder.cpp
M	source/blender/functions/frontends/data_flow_nodes/builder.hpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
M	source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp

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

diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.cpp b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
index c73f16e6986..32c8f2213a6 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.cpp
@@ -28,17 +28,18 @@ static PyObject *get_py_bnode(bNodeTree *btree, bNode *bnode)
 namespace FN {
 namespace DataFlowNodes {
 
-VTreeDataGraphBuilder::VTreeDataGraphBuilder(VirtualNodeTree &vtree,
-                                             DataFlowGraphBuilder &graph,
-                                             Map<VirtualSocket *, DFGB_Socket> &socket_map)
-    : m_graph(graph),
-      m_vtree(vtree),
-      m_socket_map(socket_map),
+VTreeDataGraphBuilder::VTreeDataGraphBuilder(VirtualNodeTree &vtree)
+    : m_vtree(vtree),
       m_type_by_idname(get_type_by_idname_map()),
       m_type_by_data_type(get_type_by_data_type_map())
 {
 }
 
+DataFlowGraph::BuildResult VTreeDataGraphBuilder::build()
+{
+  return DataFlowGraph::FromBuilder(m_graph_builder);
+}
+
 class NodeSource : public SourceInfo {
  private:
   bNodeTree *m_btree;
@@ -78,7 +79,7 @@ class NodeSource : public SourceInfo {
 
 DFGB_Node *VTreeDataGraphBuilder::insert_function(SharedFunction &fn)
 {
-  return m_graph.insert_function(fn);
+  return m_graph_builder.insert_function(fn);
 }
 
 DFGB_Node *VTreeDataGraphBuilder::insert_matching_function(SharedFunction &fn, VirtualNode *vnode)
@@ -91,13 +92,13 @@ DFGB_Node *VTreeDataGraphBuilder::insert_matching_function(SharedFunction &fn, V
 DFGB_Node *VTreeDataGraphBuilder::insert_function(SharedFunction &fn, VirtualNode *vnode)
 {
   BLI_assert(vnode != nullptr);
-  NodeSource *source = m_graph.new_source_info<NodeSource>(vnode->btree(), vnode->bnode());
-  return m_graph.insert_function(fn, source);
+  NodeSource *source = m_graph_builder.new_source_info<NodeSource>(vnode->btree(), vnode->bnode());
+  return m_graph_builder.insert_function(fn, source);
 }
 
 void VTreeDataGraphBuilder::insert_link(DFGB_Socket a, DFGB_Socket b)
 {
-  m_graph.insert_link(a, b);
+  m_graph_builder.insert_link(a, b);
 }
 
 void VTreeDataGraphBuilder::insert_links(ArrayRef<DFGB_Socket> a, ArrayRef<DFGB_Socket> b)
diff --git a/source/blender/functions/frontends/data_flow_nodes/builder.hpp b/source/blender/functions/frontends/data_flow_nodes/builder.hpp
index cf8a2d3c1b8..0442b2d7917 100644
--- a/source/blender/functions/frontends/data_flow_nodes/builder.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/builder.hpp
@@ -16,16 +16,21 @@ using BKE::VirtualSocket;
 
 class VTreeDataGraphBuilder {
  private:
-  DataFlowGraphBuilder &m_graph;
   VirtualNodeTree &m_vtree;
-  Map<VirtualSocket *, DFGB_Socket> &m_socket_map;
+  DataFlowGraphBuilder m_graph_builder;
+  Map<VirtualSocket *, DFGB_Socket> m_socket_map;
   StringMap<SharedType> &m_type_by_idname;
   StringMap<SharedType> &m_type_by_data_type;
 
  public:
-  VTreeDataGraphBuilder(VirtualNodeTree &vtree,
-                        DataFlowGraphBuilder &graph,
-                        Map<VirtualSocket *, DFGB_Socket> &socket_map);
+  VTreeDataGraphBuilder(VirtualNodeTree &vtree);
+
+  DataFlowGraph::BuildResult build();
+
+  Map<VirtualSocket *, DFGB_Socket> &socket_map()
+  {
+    return m_socket_map;
+  }
 
   /* Insert Function */
   DFGB_Node *insert_function(SharedFunction &fn);
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
index 1d00d60383f..e00e089f1fe 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.cpp
@@ -119,10 +119,7 @@ class BasicUnlinkedInputsHandler : public UnlinkedInputsHandler {
 
 ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree)
 {
-  DataFlowGraphBuilder graph_builder;
-  Map<VirtualSocket *, DFGB_Socket> socket_map;
-
-  VTreeDataGraphBuilder builder(vtree, graph_builder, socket_map);
+  VTreeDataGraphBuilder builder(vtree);
   GraphInserters &inserters = get_standard_inserters();
 
   if (!insert_functions_for_bnodes(builder, inserters)) {
@@ -137,9 +134,10 @@ ValueOrError<VTreeDataGraph> generate_graph(VirtualNodeTree &vtree)
 
   insert_unlinked_inputs(builder, unlinked_inputs_handler);
 
-  auto build_result = DataFlowGraph::FromBuilder(graph_builder);
-  return VTreeDataGraph(std::move(build_result.graph),
-                        build_mapping_for_original_sockets(socket_map, build_result.mapping));
+  auto build_result = builder.build();
+  return VTreeDataGraph(
+      std::move(build_result.graph),
+      build_mapping_for_original_sockets(builder.socket_map(), build_result.mapping));
 }
 
 VTreeDataGraph::PlaceholderDependencies VTreeDataGraph::find_placeholder_dependencies(
diff --git a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
index 2ac9fc9e4bc..dfe4f4b621d 100644
--- a/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
+++ b/source/blender/functions/frontends/data_flow_nodes/graph_generation.hpp
@@ -24,11 +24,11 @@ class UnlinkedInputsHandler {
 class VTreeDataGraph {
  private:
   SharedDataFlowGraph m_graph;
-  Map<VirtualSocket *, DFGraphSocket> m_mapping;
+  Map<VirtualSocket *, DFGraphSocket> m_socket_map;
 
  public:
   VTreeDataGraph(SharedDataFlowGraph graph, Map<VirtualSocket *, DFGraphSocket> mapping)
-      : m_graph(std::move(graph)), m_mapping(std::move(mapping))
+      : m_graph(std::move(graph)), m_socket_map(std::move(mapping))
   {
   }
 
@@ -39,17 +39,17 @@ class VTreeDataGraph {
 
   DFGraphSocket *lookup_socket_ptr(VirtualSocket *vsocket)
   {
-    return m_mapping.lookup_ptr(vsocket);
+    return m_socket_map.lookup_ptr(vsocket);
   }
 
   DFGraphSocket lookup_socket(VirtualSocket *vsocket)
   {
-    return m_mapping.lookup(vsocket);
+    return m_socket_map.lookup(vsocket);
   }
 
   bool uses_socket(VirtualSocket *vsocket)
   {
-    return m_mapping.contains(vsocket);
+    return m_socket_map.contains(vsocket);
   }
 
   struct PlaceholderDependencies {



More information about the Bf-blender-cvs mailing list