[Bf-blender-cvs] [d31da8e8702] functions: data graph can own arbitrary resources now

Jacques Lucke noreply at git.blender.org
Thu Sep 26 18:08:10 CEST 2019


Commit: d31da8e87025cd484df9edf8c1f543666324b488
Author: Jacques Lucke
Date:   Thu Sep 26 17:42:52 2019 +0200
Branches: functions
https://developer.blender.org/rBd31da8e87025cd484df9edf8c1f543666324b488

data graph can own arbitrary resources now

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

M	source/blender/functions/core/data_graph.cpp
M	source/blender/functions/core/data_graph.hpp
M	source/blender/functions/core/data_graph_builder.cpp
M	source/blender/functions/core/data_graph_builder.hpp

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

diff --git a/source/blender/functions/core/data_graph.cpp b/source/blender/functions/core/data_graph.cpp
index 44d541ca33c..c0621dd396a 100644
--- a/source/blender/functions/core/data_graph.cpp
+++ b/source/blender/functions/core/data_graph.cpp
@@ -2,12 +2,14 @@
 
 namespace FN {
 
-DataGraph::DataGraph(Vector<Node> nodes,
+DataGraph::DataGraph(std::unique_ptr<OwnedResources> resources,
+                     Vector<Node> nodes,
                      Vector<InputSocket> inputs,
                      Vector<OutputSocket> outputs,
                      Vector<uint> targets,
                      std::unique_ptr<MonotonicAllocator> source_info_allocator)
-    : m_nodes(std::move(nodes)),
+    : m_resources(std::move(resources)),
+      m_nodes(std::move(nodes)),
       m_inputs(std::move(inputs)),
       m_outputs(std::move(outputs)),
       m_targets(std::move(targets)),
diff --git a/source/blender/functions/core/data_graph.hpp b/source/blender/functions/core/data_graph.hpp
index a8f57e35404..d5aea1390d7 100644
--- a/source/blender/functions/core/data_graph.hpp
+++ b/source/blender/functions/core/data_graph.hpp
@@ -194,6 +194,7 @@ class DataGraph {
   };
 
  private:
+  std::unique_ptr<OwnedResources> m_resources;
   Vector<Node> m_nodes;
   Vector<InputSocket> m_inputs;
   Vector<OutputSocket> m_outputs;
@@ -201,7 +202,8 @@ class DataGraph {
   std::unique_ptr<MonotonicAllocator> m_source_info_allocator;
 
  public:
-  DataGraph(Vector<Node> nodes,
+  DataGraph(std::unique_ptr<OwnedResources> m_resources,
+            Vector<Node> nodes,
             Vector<InputSocket> inputs,
             Vector<OutputSocket> outputs,
             Vector<uint> targets,
diff --git a/source/blender/functions/core/data_graph_builder.cpp b/source/blender/functions/core/data_graph_builder.cpp
index 121eb7ead15..8b46c810dcf 100644
--- a/source/blender/functions/core/data_graph_builder.cpp
+++ b/source/blender/functions/core/data_graph_builder.cpp
@@ -125,7 +125,8 @@ std::unique_ptr<DataGraph> DataGraphBuilder::build()
     }
   }
 
-  DataGraph *data_graph = new DataGraph(std::move(r_nodes),
+  DataGraph *data_graph = new DataGraph(std::move(m_resources),
+                                        std::move(r_nodes),
                                         std::move(r_inputs),
                                         std::move(r_outputs),
                                         std::move(r_targets),
diff --git a/source/blender/functions/core/data_graph_builder.hpp b/source/blender/functions/core/data_graph_builder.hpp
index 470b8da996d..4aae9ed48fe 100644
--- a/source/blender/functions/core/data_graph_builder.hpp
+++ b/source/blender/functions/core/data_graph_builder.hpp
@@ -140,6 +140,7 @@ class BuilderNode {
 
 class DataGraphBuilder {
  private:
+  std::unique_ptr<OwnedResources> m_resources;
   Vector<BuilderNode *> m_nodes;
   uint m_link_counter = 0;
   uint m_input_socket_counter = 0;
@@ -157,6 +158,14 @@ class DataGraphBuilder {
   BuilderNode *insert_function(SharedFunction function, SourceInfo *source_info = nullptr);
   void insert_link(BuilderOutputSocket *from, BuilderInputSocket *to);
 
+  template<typename T> void add_resource(std::unique_ptr<T> resource, const char *name)
+  {
+    if (m_resources.get() == nullptr) {
+      m_resources = make_unique<OwnedResources>();
+    }
+    m_resources->add(std::move(resource), name);
+  }
+
   template<typename T, typename... Args> T *new_source_info(Args &&... args)
   {
     BLI_STATIC_ASSERT((std::is_base_of<SourceInfo, T>::value), "");



More information about the Bf-blender-cvs mailing list