[Bf-blender-cvs] [de7094a9308] functions: new SourceInfo class to keep track of where functions come from

Jacques Lucke noreply at git.blender.org
Tue Mar 26 11:22:18 CET 2019


Commit: de7094a93082c0d6f3efe4b0cabd81f27a6d6b95
Author: Jacques Lucke
Date:   Tue Mar 26 10:02:57 2019 +0100
Branches: functions
https://developer.blender.org/rBde7094a93082c0d6f3efe4b0cabd81f27a6d6b95

new SourceInfo class to keep track of where functions come from

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

M	source/blender/functions/CMakeLists.txt
M	source/blender/functions/FN_core.hpp
M	source/blender/functions/core/data_flow_graph.cpp
M	source/blender/functions/core/data_flow_graph.hpp
A	source/blender/functions/core/source_info.hpp

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

diff --git a/source/blender/functions/CMakeLists.txt b/source/blender/functions/CMakeLists.txt
index d92519da7b9..719a21d3cd0 100644
--- a/source/blender/functions/CMakeLists.txt
+++ b/source/blender/functions/CMakeLists.txt
@@ -31,6 +31,7 @@ set(SRC
 	core/function.cpp
 	core/data_flow_graph.hpp
 	core/data_flow_graph.cpp
+	core/source_info.hpp
 	core/dot_export.cpp
 
 	backends/tuple_call/cpp_types.hpp
diff --git a/source/blender/functions/FN_core.hpp b/source/blender/functions/FN_core.hpp
index 47b2e4322d4..4719aaea787 100644
--- a/source/blender/functions/FN_core.hpp
+++ b/source/blender/functions/FN_core.hpp
@@ -4,4 +4,5 @@
 #include "core/parameter.hpp"
 #include "core/signature.hpp"
 #include "core/function.hpp"
-#include "core/data_flow_graph.hpp"
\ No newline at end of file
+#include "core/data_flow_graph.hpp"
+#include "core/source_info.hpp"
\ No newline at end of file
diff --git a/source/blender/functions/core/data_flow_graph.cpp b/source/blender/functions/core/data_flow_graph.cpp
index 49fddd65e2d..469c5367834 100644
--- a/source/blender/functions/core/data_flow_graph.cpp
+++ b/source/blender/functions/core/data_flow_graph.cpp
@@ -35,12 +35,12 @@ namespace FN {
 		delete m_node_pool;
 	}
 
-	Node *DataFlowGraph::insert(SharedFunction &function)
+	Node *DataFlowGraph::insert(SharedFunction &function, SourceInfo *source)
 	{
 		BLI_assert(this->can_modify());
 
 		void *ptr = m_node_pool->allocate();
-		Node *node = new(ptr) Node(this, function);
+		Node *node = new(ptr) Node(this, function, source);
 		m_nodes.add(node);
 		return node;
 	}
diff --git a/source/blender/functions/core/data_flow_graph.hpp b/source/blender/functions/core/data_flow_graph.hpp
index f38e46f52f8..60c700010f4 100644
--- a/source/blender/functions/core/data_flow_graph.hpp
+++ b/source/blender/functions/core/data_flow_graph.hpp
@@ -1,6 +1,7 @@
 #pragma once
 
 #include "function.hpp"
+#include "source_info.hpp"
 
 #include "BLI_small_set.hpp"
 #include "BLI_small_set_vector.hpp"
@@ -51,8 +52,20 @@ namespace FN {
 
 	class Node {
 	public:
-		Node(DataFlowGraph *graph, SharedFunction &function)
-			: m_graph(graph), m_function(function) {}
+		Node(
+			DataFlowGraph *graph,
+			SharedFunction &function,
+			SourceInfo *source)
+			: m_graph(graph),
+			  m_function(function),
+			  m_source(source) {}
+
+		~Node()
+		{
+			if (m_source != nullptr) {
+				delete m_source;
+			}
+		}
 
 		Socket input(uint index)
 		{
@@ -156,6 +169,7 @@ namespace FN {
 	private:
 		DataFlowGraph *m_graph;
 		SharedFunction m_function;
+		SourceInfo *m_source;
 	};
 
 	class Link {
@@ -244,7 +258,7 @@ namespace FN {
 
 		~DataFlowGraph();
 
-		Node *insert(SharedFunction &function);
+		Node *insert(SharedFunction &function, SourceInfo *source = nullptr);
 		void link(Socket a, Socket b);
 
 		inline bool can_modify() const
diff --git a/source/blender/functions/core/source_info.hpp b/source/blender/functions/core/source_info.hpp
new file mode 100644
index 00000000000..3c9090576b0
--- /dev/null
+++ b/source/blender/functions/core/source_info.hpp
@@ -0,0 +1,14 @@
+#pragma once
+
+#include <string>
+
+namespace FN {
+
+	class SourceInfo {
+	public:
+		virtual ~SourceInfo() {}
+
+		virtual std::string to_string() const = 0;
+	};
+
+} /* namespace FN */
\ No newline at end of file



More information about the Bf-blender-cvs mailing list